Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / WF / Common / AuthoringOM / PropertyMetadata.cs / 1305376 / PropertyMetadata.cs
using System; using System.Collections.Generic; namespace System.Workflow.ComponentModel { [Flags] public enum DependencyPropertyOptions : byte { Default = 1, ReadOnly = 2, Optional = 4, Metadata = 8, NonSerialized = 16, DelegateProperty = 32 } //overrides so you dont need to do inheritence public delegate object GetValueOverride(DependencyObject d); public delegate void SetValueOverride(DependencyObject d, object value); public class PropertyMetadata { private Attribute[] attributes = null; private object defaultValue = null; private DependencyPropertyOptions options = DependencyPropertyOptions.Default; private bool propertySealed = false; private GetValueOverride getValueOverride = null; private SetValueOverride setValueOverride = null; private bool shouldAlwaysCallOverride = false; public PropertyMetadata() { } public PropertyMetadata(object defaultValue) : this(defaultValue, default(DependencyPropertyOptions)) { } public PropertyMetadata(DependencyPropertyOptions options) : this( null, options) { } public PropertyMetadata(object defaultValue, DependencyPropertyOptions options) : this(defaultValue, options, null, null, new Attribute[] { }) { } public PropertyMetadata(object defaultValue, params Attribute[] attributes) : this( defaultValue, default(DependencyPropertyOptions), null , null, attributes) { } public PropertyMetadata(object defaultValue, DependencyPropertyOptions options, params Attribute[] attributes) : this(defaultValue, options, null, null, attributes) { } public PropertyMetadata(DependencyPropertyOptions options, params Attribute[] attributes) : this(null, options, null, null, attributes) { } public PropertyMetadata(params Attribute[] attributes) : this(null, default(DependencyPropertyOptions), null, null, attributes) { } public PropertyMetadata(object defaultValue, DependencyPropertyOptions options, GetValueOverride getValueOverride, SetValueOverride setValueOverride) : this(defaultValue, options, getValueOverride, setValueOverride, new Attribute[] { }) { } public PropertyMetadata(object defaultValue, DependencyPropertyOptions options, GetValueOverride getValueOverride, SetValueOverride setValueOverride, params Attribute[] attributes) : this(defaultValue, options, getValueOverride, setValueOverride, false, attributes) { } internal PropertyMetadata(object defaultValue, DependencyPropertyOptions options, GetValueOverride getValueOverride, SetValueOverride setValueOverride, bool shouldAlwaysCallOverride, params Attribute[] attributes) { this.defaultValue = defaultValue; this.options = options; this.getValueOverride = getValueOverride; this.setValueOverride = setValueOverride; this.shouldAlwaysCallOverride = shouldAlwaysCallOverride; this.attributes = attributes; } public Attribute[] GetAttributes() { return GetAttributes(null); } public Attribute[] GetAttributes(Type attributeType) { Listattributes = new List (); if (this.attributes != null) { foreach (Attribute attribute in this.attributes) { if (attribute == null) continue; if (attributeType == null || attribute.GetType() == attributeType) attributes.Add(attribute); } } return attributes.ToArray(); } public object DefaultValue { get { return this.defaultValue; } set { if (this.propertySealed) throw new InvalidOperationException(SR.GetString(SR.Error_SealedPropertyMetadata)); this.defaultValue = value; } } public DependencyPropertyOptions Options { get { return this.options; } set { if (this.propertySealed) throw new InvalidOperationException(SR.GetString(SR.Error_SealedPropertyMetadata)); this.options = value; } } public bool IsMetaProperty { get { return (this.options & DependencyPropertyOptions.Metadata) > 0; } } public bool IsNonSerialized { get { return (this.options & DependencyPropertyOptions.NonSerialized) > 0; } } public bool IsReadOnly { get { return (this.options & DependencyPropertyOptions.ReadOnly) > 0; } } public GetValueOverride GetValueOverride { get { return this.getValueOverride; } set { if (this.propertySealed) throw new InvalidOperationException(SR.GetString(SR.Error_SealedPropertyMetadata)); this.getValueOverride = value; } } public SetValueOverride SetValueOverride { get { return this.setValueOverride; } set { if (this.propertySealed) throw new InvalidOperationException(SR.GetString(SR.Error_SealedPropertyMetadata)); this.setValueOverride = value; } } protected virtual void OnApply(DependencyProperty dependencyProperty, Type targetType) { } protected bool IsSealed { get { return this.propertySealed; } } internal bool ShouldAlwaysCallOverride { get { return shouldAlwaysCallOverride; } } internal void Seal(DependencyProperty dependencyProperty, Type targetType) { OnApply(dependencyProperty, targetType); this.propertySealed = true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using System.Collections.Generic; namespace System.Workflow.ComponentModel { [Flags] public enum DependencyPropertyOptions : byte { Default = 1, ReadOnly = 2, Optional = 4, Metadata = 8, NonSerialized = 16, DelegateProperty = 32 } //overrides so you dont need to do inheritence public delegate object GetValueOverride(DependencyObject d); public delegate void SetValueOverride(DependencyObject d, object value); public class PropertyMetadata { private Attribute[] attributes = null; private object defaultValue = null; private DependencyPropertyOptions options = DependencyPropertyOptions.Default; private bool propertySealed = false; private GetValueOverride getValueOverride = null; private SetValueOverride setValueOverride = null; private bool shouldAlwaysCallOverride = false; public PropertyMetadata() { } public PropertyMetadata(object defaultValue) : this(defaultValue, default(DependencyPropertyOptions)) { } public PropertyMetadata(DependencyPropertyOptions options) : this( null, options) { } public PropertyMetadata(object defaultValue, DependencyPropertyOptions options) : this(defaultValue, options, null, null, new Attribute[] { }) { } public PropertyMetadata(object defaultValue, params Attribute[] attributes) : this( defaultValue, default(DependencyPropertyOptions), null , null, attributes) { } public PropertyMetadata(object defaultValue, DependencyPropertyOptions options, params Attribute[] attributes) : this(defaultValue, options, null, null, attributes) { } public PropertyMetadata(DependencyPropertyOptions options, params Attribute[] attributes) : this(null, options, null, null, attributes) { } public PropertyMetadata(params Attribute[] attributes) : this(null, default(DependencyPropertyOptions), null, null, attributes) { } public PropertyMetadata(object defaultValue, DependencyPropertyOptions options, GetValueOverride getValueOverride, SetValueOverride setValueOverride) : this(defaultValue, options, getValueOverride, setValueOverride, new Attribute[] { }) { } public PropertyMetadata(object defaultValue, DependencyPropertyOptions options, GetValueOverride getValueOverride, SetValueOverride setValueOverride, params Attribute[] attributes) : this(defaultValue, options, getValueOverride, setValueOverride, false, attributes) { } internal PropertyMetadata(object defaultValue, DependencyPropertyOptions options, GetValueOverride getValueOverride, SetValueOverride setValueOverride, bool shouldAlwaysCallOverride, params Attribute[] attributes) { this.defaultValue = defaultValue; this.options = options; this.getValueOverride = getValueOverride; this.setValueOverride = setValueOverride; this.shouldAlwaysCallOverride = shouldAlwaysCallOverride; this.attributes = attributes; } public Attribute[] GetAttributes() { return GetAttributes(null); } public Attribute[] GetAttributes(Type attributeType) { List attributes = new List (); if (this.attributes != null) { foreach (Attribute attribute in this.attributes) { if (attribute == null) continue; if (attributeType == null || attribute.GetType() == attributeType) attributes.Add(attribute); } } return attributes.ToArray(); } public object DefaultValue { get { return this.defaultValue; } set { if (this.propertySealed) throw new InvalidOperationException(SR.GetString(SR.Error_SealedPropertyMetadata)); this.defaultValue = value; } } public DependencyPropertyOptions Options { get { return this.options; } set { if (this.propertySealed) throw new InvalidOperationException(SR.GetString(SR.Error_SealedPropertyMetadata)); this.options = value; } } public bool IsMetaProperty { get { return (this.options & DependencyPropertyOptions.Metadata) > 0; } } public bool IsNonSerialized { get { return (this.options & DependencyPropertyOptions.NonSerialized) > 0; } } public bool IsReadOnly { get { return (this.options & DependencyPropertyOptions.ReadOnly) > 0; } } public GetValueOverride GetValueOverride { get { return this.getValueOverride; } set { if (this.propertySealed) throw new InvalidOperationException(SR.GetString(SR.Error_SealedPropertyMetadata)); this.getValueOverride = value; } } public SetValueOverride SetValueOverride { get { return this.setValueOverride; } set { if (this.propertySealed) throw new InvalidOperationException(SR.GetString(SR.Error_SealedPropertyMetadata)); this.setValueOverride = value; } } protected virtual void OnApply(DependencyProperty dependencyProperty, Type targetType) { } protected bool IsSealed { get { return this.propertySealed; } } internal bool ShouldAlwaysCallOverride { get { return shouldAlwaysCallOverride; } } internal void Seal(DependencyProperty dependencyProperty, Type targetType) { OnApply(dependencyProperty, targetType); this.propertySealed = true; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TreeNode.cs
- ActivationArguments.cs
- Contracts.cs
- IPipelineRuntime.cs
- ListViewItem.cs
- UIElement.cs
- ToolStripProgressBar.cs
- DynamicObjectAccessor.cs
- XamlValidatingReader.cs
- ShapeTypeface.cs
- DomainConstraint.cs
- SingleAnimationUsingKeyFrames.cs
- TableLayoutStyle.cs
- TypeConstant.cs
- ConfigXmlAttribute.cs
- DataConnectionHelper.cs
- InvalidFilterCriteriaException.cs
- NamedObject.cs
- TypeLibraryHelper.cs
- GenericUriParser.cs
- SafeNativeMethods.cs
- FileFormatException.cs
- XmlSchemaSimpleContentExtension.cs
- DataFieldConverter.cs
- QuotaExceededException.cs
- QueryContinueDragEventArgs.cs
- StyleSheetComponentEditor.cs
- ColumnHeaderCollectionEditor.cs
- DnsElement.cs
- ColorKeyFrameCollection.cs
- PrintDialogException.cs
- EdmScalarPropertyAttribute.cs
- InternalUserCancelledException.cs
- SQLRoleProvider.cs
- DataObjectCopyingEventArgs.cs
- XPathParser.cs
- RowTypeElement.cs
- StandardTransformFactory.cs
- EasingQuaternionKeyFrame.cs
- Semaphore.cs
- FillRuleValidation.cs
- PageAsyncTask.cs
- SecurityTokenException.cs
- NullableIntMinMaxAggregationOperator.cs
- FileSystemInfo.cs
- BufferAllocator.cs
- Composition.cs
- Environment.cs
- HandlerFactoryCache.cs
- GatewayIPAddressInformationCollection.cs
- GridViewColumnHeaderAutomationPeer.cs
- DetailsView.cs
- OrCondition.cs
- DataGridViewCellMouseEventArgs.cs
- OdbcEnvironmentHandle.cs
- QueryAsyncResult.cs
- DataServiceOperationContext.cs
- UnitySerializationHolder.cs
- ComponentManagerBroker.cs
- FactoryRecord.cs
- XmlDataSourceNodeDescriptor.cs
- UserMapPath.cs
- CookieHandler.cs
- CacheHelper.cs
- BoundColumn.cs
- PKCS1MaskGenerationMethod.cs
- ScrollBarRenderer.cs
- EntityConnectionStringBuilderItem.cs
- MarkupCompiler.cs
- URLBuilder.cs
- Int32RectValueSerializer.cs
- EndpointBehaviorElement.cs
- TransformCollection.cs
- WebRequestModulesSection.cs
- ServiceInstallComponent.cs
- MailDefinition.cs
- CurrencyWrapper.cs
- RepeatInfo.cs
- ToolStripDropDownButton.cs
- WhileDesigner.xaml.cs
- SaveLedgerEntryRequest.cs
- SafeRegistryHandle.cs
- ImageIndexConverter.cs
- PreparingEnlistment.cs
- ProcessInputEventArgs.cs
- ModelPerspective.cs
- Wildcard.cs
- MenuAutomationPeer.cs
- SiteMapDataSourceView.cs
- SQLDateTimeStorage.cs
- DataTableCollection.cs
- FolderLevelBuildProviderAppliesToAttribute.cs
- XsltCompileContext.cs
- AttributeXamlType.cs
- SecureStringHasher.cs
- Triplet.cs
- TransformerInfoCollection.cs
- WebPartManager.cs
- ScriptResourceHandler.cs
- RoutedEventValueSerializer.cs