Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / cdf / src / NetFx40 / Tools / System.Activities.Presentation / System / Activities / Presentation / Base / Interaction / Model / ModelProperty.cs / 1305376 / ModelProperty.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Activities.Presentation.Model { using System.Activities.Presentation.Internal.Properties; using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime; ////// An ModelProperty represents a property on an item. ModelProperties are /// associated with an instance of an item, which allows them to have simple /// Value get/set properties instead of the more cumbersome GetValue/SetValue /// mechanism of PropertyDescriptor. /// /// A ModelProperty’s value may come from a locally set value, or it may be /// inherited from somewhere higher up in the property mechanism. Because /// all items in the tree contain Source properties, you can /// easily find out the real source of a property value simply using the /// following code: /// /// Console.WriteLine(property.Value.Source); /// /// Value will return null if the property is not set anywhere in the hierarchy. /// /// Type converters and editors defined on the underlying data model are /// wrapped so that they accept ModelItems as parameters. /// public abstract class ModelProperty { ////// Creates a new ModelProperty. /// protected ModelProperty() { } ////// Returns the attributes declared on this property. /// public abstract AttributeCollection Attributes { get; } ////// Returns Value cast as a ModelItemCollection. This property allows you to /// access collection properties easily without cluttering your code with casts: /// /// Property.Collection.Add(myItem); /// /// If the property value is not a collection, this property will return null. /// [Fx.Tag.KnownXamlExternalAttribute] public abstract ModelItemCollection Collection { get; } ////// Returns the currently computed value for this property. Setting a value /// on this property is the same as calling SetValue, but can be used in /// data binding expressions. /// public abstract object ComputedValue { get; set; } ////// Returns the type converter to use with this property. Underlying type /// converters are all wrapped so they accept Item objects. When performing /// a conversion to a particular value, the type converter’s return type is /// not wrapped. Type converters which return standard values also return /// values as Item objects. /// public abstract TypeConverter Converter { get; } ////// Returns the type which defines this property if IsAttached returns true. /// Otherwhise, returns null. /// public abstract Type AttachedOwnerType { get; } ////// Returns the default value for this property. If the property does not /// define a default value this will return null. /// public abstract object DefaultValue { get; } ////// Returns Value cast as a ItemDictionary. This property allows you to /// access dictionary properties easily without cluttering your code with casts: /// /// Property.Dictionary[key] = value; /// /// If the property value is not a dictionary, this property will return null. /// [Fx.Tag.KnownXamlExternalAttribute] public abstract ModelItemDictionary Dictionary { get; } ////// Returns true if the property can be shown in a property window. /// public abstract bool IsBrowsable { get; } ////// Returns true if the value contained in the property is a ItemCollection. /// public abstract bool IsCollection { get; } ////// Returns true if the value contained in the property is a ItemDictionary. /// public abstract bool IsDictionary { get; } ////// Returns true if the property is read only. /// public abstract bool IsReadOnly { get; } ////// Returns true if the property’s value is set locally. /// public abstract bool IsSet { get; } ////// Returns true if the property represents an attached property from a different type. /// public abstract bool IsAttached { get; } ////// Returns the value set into this property. A property may return a /// value that is inherited further up the element hierarchy, in which /// case this property will return a value whose source != this. /// If no value has ever been set for the property Value will return null. /// public abstract ModelItem Value { get; } ////// Returns the name of this property. /// public abstract string Name { get; } ////// Returns the parent of this property. All properties have /// parents, so this never returns null. /// public abstract ModelItem Parent { get; } ////// The data type of the property. /// public abstract Type PropertyType { get; } ////// Clears the local value for the property. /// public abstract void ClearValue(); ////// Sets a local value on a property. If this value is already /// a ModelItem, it will be used directly. If it isn’t, a ModelItem /// will be created. Setting null into a property is valid, but /// this is not the same as calling ClearValue(). /// /// /// The new value to set. /// ////// The input value, if the value is already a ModelItem, or a newly /// created ModelItem wrapping the value. /// public abstract ModelItem SetValue(object value); ////// Equality operator. /// // FXCop: args are validated; fxcop does not seem to understand ReferenceEquals. public static bool operator ==(ModelProperty first, ModelProperty second) { if (object.ReferenceEquals(first, second)) return true; if (object.ReferenceEquals(first, null) || object.ReferenceEquals(second, null)) return false; return (first.Parent == second.Parent && first.Name.Equals(second.Name)); } ////// Inequality operator. /// // FXCop: args are validated; fxcop does not seem to understand ReferenceEquals. public static bool operator !=(ModelProperty first, ModelProperty second) { if (object.ReferenceEquals(first, second)) return false; if (object.ReferenceEquals(first, null) || object.ReferenceEquals(second, null)) return true; return (first.Parent != second.Parent || !first.Name.Equals(second.Name)); } ////// Equality for properties. Properties are equal if /// they have the same name and parent. /// /// ///public override bool Equals(object obj) { if (object.ReferenceEquals(obj, this)) return true; ModelProperty prop = obj as ModelProperty; if (object.ReferenceEquals(prop, null)) return false; if (prop.Parent != Parent) return false; return prop.Name.Equals(Name); } /// /// Standard hashcode implementation. /// ///public override int GetHashCode() { return Parent.GetHashCode() ^ Name.GetHashCode(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Activities.Presentation.Model { using System.Activities.Presentation.Internal.Properties; using System; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Runtime; ////// An ModelProperty represents a property on an item. ModelProperties are /// associated with an instance of an item, which allows them to have simple /// Value get/set properties instead of the more cumbersome GetValue/SetValue /// mechanism of PropertyDescriptor. /// /// A ModelProperty’s value may come from a locally set value, or it may be /// inherited from somewhere higher up in the property mechanism. Because /// all items in the tree contain Source properties, you can /// easily find out the real source of a property value simply using the /// following code: /// /// Console.WriteLine(property.Value.Source); /// /// Value will return null if the property is not set anywhere in the hierarchy. /// /// Type converters and editors defined on the underlying data model are /// wrapped so that they accept ModelItems as parameters. /// public abstract class ModelProperty { ////// Creates a new ModelProperty. /// protected ModelProperty() { } ////// Returns the attributes declared on this property. /// public abstract AttributeCollection Attributes { get; } ////// Returns Value cast as a ModelItemCollection. This property allows you to /// access collection properties easily without cluttering your code with casts: /// /// Property.Collection.Add(myItem); /// /// If the property value is not a collection, this property will return null. /// [Fx.Tag.KnownXamlExternalAttribute] public abstract ModelItemCollection Collection { get; } ////// Returns the currently computed value for this property. Setting a value /// on this property is the same as calling SetValue, but can be used in /// data binding expressions. /// public abstract object ComputedValue { get; set; } ////// Returns the type converter to use with this property. Underlying type /// converters are all wrapped so they accept Item objects. When performing /// a conversion to a particular value, the type converter’s return type is /// not wrapped. Type converters which return standard values also return /// values as Item objects. /// public abstract TypeConverter Converter { get; } ////// Returns the type which defines this property if IsAttached returns true. /// Otherwhise, returns null. /// public abstract Type AttachedOwnerType { get; } ////// Returns the default value for this property. If the property does not /// define a default value this will return null. /// public abstract object DefaultValue { get; } ////// Returns Value cast as a ItemDictionary. This property allows you to /// access dictionary properties easily without cluttering your code with casts: /// /// Property.Dictionary[key] = value; /// /// If the property value is not a dictionary, this property will return null. /// [Fx.Tag.KnownXamlExternalAttribute] public abstract ModelItemDictionary Dictionary { get; } ////// Returns true if the property can be shown in a property window. /// public abstract bool IsBrowsable { get; } ////// Returns true if the value contained in the property is a ItemCollection. /// public abstract bool IsCollection { get; } ////// Returns true if the value contained in the property is a ItemDictionary. /// public abstract bool IsDictionary { get; } ////// Returns true if the property is read only. /// public abstract bool IsReadOnly { get; } ////// Returns true if the property’s value is set locally. /// public abstract bool IsSet { get; } ////// Returns true if the property represents an attached property from a different type. /// public abstract bool IsAttached { get; } ////// Returns the value set into this property. A property may return a /// value that is inherited further up the element hierarchy, in which /// case this property will return a value whose source != this. /// If no value has ever been set for the property Value will return null. /// public abstract ModelItem Value { get; } ////// Returns the name of this property. /// public abstract string Name { get; } ////// Returns the parent of this property. All properties have /// parents, so this never returns null. /// public abstract ModelItem Parent { get; } ////// The data type of the property. /// public abstract Type PropertyType { get; } ////// Clears the local value for the property. /// public abstract void ClearValue(); ////// Sets a local value on a property. If this value is already /// a ModelItem, it will be used directly. If it isn’t, a ModelItem /// will be created. Setting null into a property is valid, but /// this is not the same as calling ClearValue(). /// /// /// The new value to set. /// ////// The input value, if the value is already a ModelItem, or a newly /// created ModelItem wrapping the value. /// public abstract ModelItem SetValue(object value); ////// Equality operator. /// // FXCop: args are validated; fxcop does not seem to understand ReferenceEquals. public static bool operator ==(ModelProperty first, ModelProperty second) { if (object.ReferenceEquals(first, second)) return true; if (object.ReferenceEquals(first, null) || object.ReferenceEquals(second, null)) return false; return (first.Parent == second.Parent && first.Name.Equals(second.Name)); } ////// Inequality operator. /// // FXCop: args are validated; fxcop does not seem to understand ReferenceEquals. public static bool operator !=(ModelProperty first, ModelProperty second) { if (object.ReferenceEquals(first, second)) return false; if (object.ReferenceEquals(first, null) || object.ReferenceEquals(second, null)) return true; return (first.Parent != second.Parent || !first.Name.Equals(second.Name)); } ////// Equality for properties. Properties are equal if /// they have the same name and parent. /// /// ///public override bool Equals(object obj) { if (object.ReferenceEquals(obj, this)) return true; ModelProperty prop = obj as ModelProperty; if (object.ReferenceEquals(prop, null)) return false; if (prop.Parent != Parent) return false; return prop.Name.Equals(Name); } /// /// Standard hashcode implementation. /// ///public override int GetHashCode() { return Parent.GetHashCode() ^ Name.GetHashCode(); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- UnSafeCharBuffer.cs
- SetState.cs
- OperandQuery.cs
- PersistenceTypeAttribute.cs
- XamlPoint3DCollectionSerializer.cs
- AccessDataSource.cs
- InputProviderSite.cs
- AtomMaterializerLog.cs
- ChangeBlockUndoRecord.cs
- Grant.cs
- PathFigureCollection.cs
- PenLineCapValidation.cs
- WindowsSolidBrush.cs
- SoapFaultCodes.cs
- shaperfactoryquerycachekey.cs
- PolygonHotSpot.cs
- TraceUtility.cs
- DataGridViewDataErrorEventArgs.cs
- HttpRequestTraceRecord.cs
- TransactionScope.cs
- NavigationPropertyEmitter.cs
- ClientUrlResolverWrapper.cs
- TableCellCollection.cs
- EntityDataReader.cs
- FixedPageAutomationPeer.cs
- UIElement.cs
- METAHEADER.cs
- XsdCachingReader.cs
- PersonalizationStateQuery.cs
- RadialGradientBrush.cs
- Attribute.cs
- DbConnectionFactory.cs
- X509Certificate2Collection.cs
- ZipPackagePart.cs
- DbParameterCollectionHelper.cs
- InternalTypeHelper.cs
- FragmentQueryKB.cs
- Win32SafeHandles.cs
- XamlTypeMapper.cs
- UInt16.cs
- CodeTypeReferenceCollection.cs
- WindowAutomationPeer.cs
- AdapterDictionary.cs
- HyperLinkField.cs
- FrameworkElementFactoryMarkupObject.cs
- RecognizedAudio.cs
- OdbcConnectionStringbuilder.cs
- ChangeProcessor.cs
- ActivityBuilderHelper.cs
- StylusButton.cs
- EntityViewGenerator.cs
- ApplicationHost.cs
- Invariant.cs
- ProgressBar.cs
- ContentOperations.cs
- sqlmetadatafactory.cs
- _NetRes.cs
- XmlRawWriter.cs
- ProxyFragment.cs
- MultipleViewProviderWrapper.cs
- VarRefManager.cs
- DnsPermission.cs
- ParentQuery.cs
- CustomValidator.cs
- NumberFunctions.cs
- EntityCommandDefinition.cs
- DesignBindingConverter.cs
- XmlSchemaAny.cs
- LinkedResourceCollection.cs
- QilReference.cs
- SerializationEventsCache.cs
- XhtmlBasicCalendarAdapter.cs
- RectConverter.cs
- ClientBuildManagerCallback.cs
- WebUtil.cs
- AttributeQuery.cs
- SiteMapPath.cs
- GrammarBuilder.cs
- ConfigurationElementProperty.cs
- WindowsToolbarAsMenu.cs
- ConfigurationValues.cs
- ResXResourceSet.cs
- ObjectPropertyMapping.cs
- DataGridHyperlinkColumn.cs
- SafeBitVector32.cs
- ColorConverter.cs
- SqlAggregateChecker.cs
- ComponentCollection.cs
- BezierSegment.cs
- WebPartDisplayModeEventArgs.cs
- DynamicRendererThreadManager.cs
- TabletDevice.cs
- RtfControlWordInfo.cs
- FixedTextSelectionProcessor.cs
- Lease.cs
- RenderingEventArgs.cs
- ResourceReferenceKeyNotFoundException.cs
- ImageAnimator.cs
- BrowserCapabilitiesFactory.cs
- TraceContext.cs