This topic has not yet been rated - Rate this topic

XamlMember Class

Provides the XAML type system identifier for members of XAML types. The identifier is used by XAML readers and XAML writers during processing of member nodes (when the XAML reader is positioned on a StartMember) and also for general XAML type system logic.

System.Object
  System.Xaml.XamlMember
    System.Xaml.XamlDirective

Namespace:  System.Xaml
Assembly:  System.Xaml (in System.Xaml.dll)
public class XamlMember : IEquatable<XamlMember>

The XamlMember type exposes the following members.

  Name Description
Public method XamlMember(EventInfo, XamlSchemaContext) Initializes a new instance of the XamlMember class using CLR type system EventInfo and a XamlSchemaContext.
Public method XamlMember(PropertyInfo, XamlSchemaContext) Initializes a new instance of the XamlMember class using CLR type system PropertyInfo and a XamlSchemaContext.
Public method XamlMember(EventInfo, XamlSchemaContext, XamlMemberInvoker) Initializes a new instance of the XamlMember class using CLR type system EventInfo and a XamlSchemaContext, including XamlMemberInvoker information.
Public method XamlMember(PropertyInfo, XamlSchemaContext, XamlMemberInvoker) Initializes a new instance of the XamlMember class using reflection PropertyInfo and a XamlSchemaContext, including XamlMemberInvoker information.
Public method XamlMember(String, MethodInfo, XamlSchemaContext) Initializes a new instance of the XamlMember class for a XamlMember that represents an attachable event.
Public method XamlMember(String, XamlType, Boolean) Initializes a new instance of the XamlMember class using a string name and declaring XamlType information. A XamlMember that is constructed with this signature has significant limitations; see Remarks.
Public method XamlMember(String, MethodInfo, MethodInfo, XamlSchemaContext) Initializes a new instance of the XamlMember class for a XamlMember that represents an attachable property.
Public method XamlMember(String, MethodInfo, XamlSchemaContext, XamlMemberInvoker) Initializes a new instance of the XamlMember class for a XamlMember that represents an attachable event, including XamlMemberInvoker information.
Public method XamlMember(String, MethodInfo, MethodInfo, XamlSchemaContext, XamlMemberInvoker) Initializes a new instance of the XamlMember class for a XamlMember that represents an attachable property, including XamlMemberInvoker information.
Top
  Name Description
Public property DeclaringType Gets the XamlType for the type that declares the member that is associated with this XamlMember.
Public property DeferringLoader Gets a XamlValueConverter<TConverterBase> object, which is used for deferred loading of XAML declared objects.
Public property DependsOn Gets a list of XamlMember objects. These report the members where dependency relationships for initialization order exist relative to this XamlMember.
Public property Invoker Gets the XamlMemberInvoker implementation that is associated with this XamlMember.
Public property IsAmbient Gets a value that indicates whether this XamlMember is reported as an ambient property.
Public property IsAttachable Gets a value that indicates whether this XamlMember is an attachable member.
Public property IsDirective Gets a value that indicates whether this XamlMember is a XAML directive.
Public property IsEvent Gets a value that indicates whether this XamlMember represents an event member.
Public property IsNameValid Gets a value that indicates whether this XamlMember is initialized with a valid xamlName string as its Name.
Public property IsReadOnly Gets a value that indicates whether this XamlMember represents a read-only member.
Public property IsReadPublic Gets a value that indicates whether this XamlMember represents a member with a callable public get accessor.
Public property IsUnknown Gets a value that indicates whether the member is not resolvable by the backing system that is used for type and member resolution.
Public property IsWriteOnly Gets a value that indicates whether this XamlMember represents a write-only member.
Public property IsWritePublic Gets a value that indicates whether this XamlMember represents a member that has a callable public set accessor.
Public property Name Gets the xamlName name string that declares this XamlMember.
Public property PreferredXamlNamespace Gets the single XAML namespace URI that identifies the primary XAML namespace for this XamlMember.
Public property SerializationVisibility Gets a DesignerSerializationVisibility value, which indicates how a visual designer should process the member.
Public property TargetType Gets the XamlType of the type where the XamlMember can exist.
Public property Type Gets the XamlType of the type that is used by the member.
Public property TypeConverter Gets a XamlValueConverter<TConverterBase> object, which can be used for type conversion construction of XAML declared objects.
Public property UnderlyingMember Gets the CLR type system MemberInfo that is available for a member that is constructed by PropertyInfo, MethodInfo, or EventInfo.
Public property ValueSerializer Gets a XamlValueConverter<TConverterBase> object, which is used for value serialization of XAML declared objects.
Top
  Name Description
Public method Equals(Object) Indicates whether the current object is equal to another object. (Overrides Object.Equals(Object).)
Public method Equals(XamlMember) Indicates whether the current object is equal to another object of the same type.
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Returns the hash code for this object. (Overrides Object.GetHashCode().)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method GetXamlNamespaces Returns a list of XAML namespaces where this XAML member can exist.
Protected method LookupCustomAttributeProvider When implemented in a derived class, returns an ICustomAttributeProvider implementation.
Protected method LookupDeferringLoader Returns a XamlValueConverter<TConverterBase> object, which is used for deferred loading of XAML declared objects.
Protected method LookupDependsOn Returns a list of XamlMember objects. Items in the list report the members where dependency relationships for initialization order exist relative to this XamlMember.
Protected method LookupInvoker Returns a XamlMemberInvoker that is associated with this XamlMember.
Protected method LookupIsAmbient Returns whether this XamlMember is reported as an ambient property.
Protected method LookupIsEvent Returns whether this XamlMember represents an event.
Protected method LookupIsReadOnly Returns whether this XamlMember represents an intended read-only property.
Protected method LookupIsReadPublic Returns whether this XamlMember represents a property that has a public get accessor.
Protected method LookupIsUnknown Returns whether this XamlMember represents a member that is not resolvable by the backing system that is used for type and member resolution.
Protected method LookupIsWriteOnly Returns whether this XamlMember represents a member that has a public set accessor but not a public get accessor.
Protected method LookupIsWritePublic Returns whether this XamlMember represents a member that has a public set accessor.
Protected method LookupTargetType Returns the XamlType of the type where the XamlMember can exist.
Protected method LookupType Returns the XamlType of the type that is used by the member. See Remarks.
Protected method LookupTypeConverter Returns a type converter implementation that is associated with this XamlMember.
Protected method LookupUnderlyingGetter Returns a get accessor that is associated with this XamlMember.
Protected method LookupUnderlyingMember Returns a CLR type system MemberInfo that is associated with this XamlMember.
Protected method LookupUnderlyingSetter Returns a set accessor that is associated with this XamlMember.
Protected method LookupValueSerializer Returns a value serializer implementation that is associated with this XamlMember.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string representation of this XamlMember. (Overrides Object.ToString().)
Top
  Name Description
Public operator Static member Equality Determines whether two specified XamlMember objects have the same value.
Public operator Static member Inequality Determines whether two specified XamlMember objects have different values.
Top

XamlMember can use three methodologies for returning information about a XAML member: standard common language runtime (CLR) reflection; a reference-only reflection technique calling internal APIs that use optimized bit flags; or calling into virtual overrides of the Lookup* API that is provided by possible XamlMember subclasses. For most uses of .NET Framework XAML Services APIs and the XamlMember API, you use the default XAML schema context. The default XAML schema context for .NET Framework XAML Services uses CLR backing for the type system. This enables the XAML readers and XAML writers to work with any type or member that is defined in, or otherwise available to, the CLR and its reflection techniques.

Lookup* APIs and XamlMember Derived Classes

XamlMember defines several virtual members that derived classes might override. These members have names that always start with the string Lookup. The remainder of the API name then references the property that the virtual method influences. For example, a XamlMember derived class might override LookupTargetType to influence what the base-defined property TargetType returns in a derived class. You can predict return values for such properties in XamlMember or existing derived classes by reading the documentation for the relevant Lookup* methods.

The purpose of the Lookup* methods is to provide a XAML type system extension technique that incorporates the XamlMember base class. By deriving from XamlMember and overriding the Lookup virtual members, you can define the concept of a XAML member for a XAML schema in a XAML type system without being tied to the specifics of a backing type system or technology. You can also use a provided XAML schema context under this scheme and still return the results you want.

As an example, consider the XamlMember property IsWritePublic. This property informs callers that operations such as using a XamlWriter for serialization can write a value for this member on a target object. In the default implementation, the determination of whether the member is writable is made by using reflection techniques against the backing CLR Type and its members (the MemberInfo). Therefore, by default, the XAML type system depends on the CLR type system. However, you can remove this dependency for your XAML type system reporting of IsWritePublic by overriding the API LookupIsWritePublic. Within your override, you can use other determinations, such as metadata that is specific to your technology, a master lookup table that is optimized for a fixed XAML vocabulary, or a variety of other strategies for determining whether a XAML member is writable in your XAML vocabulary.

Constructing XamlMember Without XAML Schema Context

Most constructors of XamlMember require a XamlSchemaContext as part of their initialization. The XamlSchemaContext is also necessary for many internal XamlSchemaContext operations, such as obtaining information that is being forwarded from the backing type. When you are working with the XamlMember API, you typically have a XamlSchemaContext that is available from a surrounding construct such as a XamlWriter. In this case, you can pass the XamlSchemaContext reference through to all XAML type system calls that require a XAML schema context.

One specific constructor, XamlMember(String, XamlType, Boolean), does not require a XamlSchemaContext. However, a XamlMember that is constructed with the XamlMember(String, XamlType, Boolean) signature returns true for IsUnknown.

For a load path that involves XamlObjectWriter, such a member cannot be written into an object graph. Using the .NET Framework XAML services implementation, the XamlObjectWriter.WriteStartMember call throws a XamlObjectWriterException when the relevant XamlMember reports true for IsUnknown.

You should not construct a XamlMember that has a value of true for IsUnknown unless your implementation can handle the exceptions from XamlObjectWriter, or you have other ways to adjust the XamlObjectWriter behavior. For example, one or more of the following might be true of your implementation:

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ