public void GetAliasedProperty() { XamlMember xm; var xt = new XamlType(typeof(SeverlyAliasedClass), new XamlSchemaContext(null, null)); xm = xt.GetAliasedProperty(XamlLanguage.Key); Assert.IsNotNull(xm, "#1"); xm = xt.GetAliasedProperty(XamlLanguage.Name); Assert.IsNotNull(xm, "#2"); xm = xt.GetAliasedProperty(XamlLanguage.Uid); Assert.IsNotNull(xm, "#3"); xm = xt.GetAliasedProperty(XamlLanguage.Lang); Assert.IsNotNull(xm, "#4"); xt = new XamlType(typeof(Dictionary <int, string>), xt.SchemaContext); Assert.IsNull(xt.GetAliasedProperty(XamlLanguage.Key), "#5"); }
// This can only be done after the XmlNs's have be scanned and loaded public void Initialize(XamlParserContext context, XamlType tagType, string ownerNamespace, bool tagIsRoot) { // Namespaces are already flagged (but not the other kinds). if (Kind == ScannerAttributeKind.Namespace) { return; } Property = GetXamlAttributeProperty(context, Name, tagType, ownerNamespace, tagIsRoot); if (Property.IsUnknown) { Kind = ScannerAttributeKind.Unknown; } else if (Property.IsEvent) { Kind = ScannerAttributeKind.Event; } else if (Property.IsDirective) { if (Property == XamlLanguage.Space) { Kind = ScannerAttributeKind.XmlSpace; } else if ((Property == XamlLanguage.FactoryMethod) || (Property == XamlLanguage.Arguments) || (Property == XamlLanguage.TypeArguments) || (Property == XamlLanguage.Base) // || (Property == XamlLanguage.Initialization) // doesn't appear in Xml Text // || (Property == XamlLanguage.PositionalParameters) // doesn't appear in Xml Text ) { Kind = ScannerAttributeKind.CtorDirective; } else { Kind = ScannerAttributeKind.Directive; } } else if (Property.IsAttachable) { Kind = ScannerAttributeKind.AttachableProperty; } else if (Property == tagType.GetAliasedProperty(XamlLanguage.Name)) { Kind = ScannerAttributeKind.Name; } else { Kind = ScannerAttributeKind.Property; } }
public void Initialize(XamlParserContext context, XamlType tagType, string ownerNamespace, bool tagIsRoot) { if (this.Kind != ScannerAttributeKind.Namespace) { this.Property = this.GetXamlAttributeProperty(context, this.Name, tagType, ownerNamespace, tagIsRoot); if (this.Property.IsUnknown) { this.Kind = ScannerAttributeKind.Unknown; } else if (this.Property.IsEvent) { this.Kind = ScannerAttributeKind.Event; } else if (this.Property.IsDirective) { if (this.Property == XamlLanguage.Space) { this.Kind = ScannerAttributeKind.XmlSpace; } else if (((this.Property == XamlLanguage.FactoryMethod) || (this.Property == XamlLanguage.Arguments)) || ((this.Property == XamlLanguage.TypeArguments) || (this.Property == XamlLanguage.Base))) { this.Kind = ScannerAttributeKind.CtorDirective; } else { this.Kind = ScannerAttributeKind.Directive; } } else if (this.Property.IsAttachable) { this.Kind = ScannerAttributeKind.AttachableProperty; } else if (this.Property == tagType.GetAliasedProperty(XamlLanguage.Name)) { this.Kind = ScannerAttributeKind.Name; } else { this.Kind = ScannerAttributeKind.Property; } } }
public void GetAliasedProperty () { XamlMember xm; var xt = new XamlType (typeof (SeverlyAliasedClass), new XamlSchemaContext (null, null)); xm = xt.GetAliasedProperty (XamlLanguage.Key); Assert.IsNotNull (xm, "#1"); xm = xt.GetAliasedProperty (XamlLanguage.Name); Assert.IsNotNull (xm, "#2"); xm = xt.GetAliasedProperty (XamlLanguage.Uid); Assert.IsNotNull (xm, "#3"); xm = xt.GetAliasedProperty (XamlLanguage.Lang); Assert.IsNotNull (xm, "#4"); xt = new XamlType (typeof (Dictionary<int,string>), xt.SchemaContext); Assert.IsNull (xt.GetAliasedProperty (XamlLanguage.Key), "#5"); }
private bool IsDirectiveAllowedOnNullInstance(XamlMember xamlMember, XamlType xamlType) { return ((xamlMember == XamlLanguage.Key) || ((xamlMember == XamlLanguage.Uid) && (null == xamlType.GetAliasedProperty(XamlLanguage.Uid)))); }
private object GetKeyFromInstance(object instance, XamlType instanceType, IAddLineInfo lineInfo) { XamlMember aliasedProperty = instanceType.GetAliasedProperty(XamlLanguage.Key); if ((aliasedProperty == null) || (instance == null)) { throw lineInfo.WithLineInfo(new XamlObjectWriterException(System.Xaml.SR.Get("MissingKey", new object[] { instanceType.Name }))); } return this.Runtime.GetValue(instance, aliasedProperty); }
internal static bool IsNameProperty(XamlMember member, XamlType owner) { if (member == owner.GetAliasedProperty(XamlLanguage.Name) || XamlLanguage.Name == member) { return true; } return false; }
public void Initialize(XamlParserContext context, XamlType tagType, string ownerNamespace, bool tagIsRoot) { if (this.Kind != ScannerAttributeKind.Namespace) { this.Property = this.GetXamlAttributeProperty(context, this.Name, tagType, ownerNamespace, tagIsRoot); if (this.Property.IsUnknown) { this.Kind = ScannerAttributeKind.Unknown; } else if (this.Property.IsEvent) { this.Kind = ScannerAttributeKind.Event; } else if (this.Property.IsDirective) { if (this.Property == XamlLanguage.Space) { this.Kind = ScannerAttributeKind.XmlSpace; } else if (((this.Property == XamlLanguage.FactoryMethod) || (this.Property == XamlLanguage.Arguments)) || ((this.Property == XamlLanguage.TypeArguments) || (this.Property == XamlLanguage.Base))) { this.Kind = ScannerAttributeKind.CtorDirective; } else { this.Kind = ScannerAttributeKind.Directive; } } else if (this.Property.IsAttachable) { this.Kind = ScannerAttributeKind.AttachableProperty; } else if (this.Property == tagType.GetAliasedProperty(XamlLanguage.Name)) { this.Kind = ScannerAttributeKind.Name; } else { this.Kind = ScannerAttributeKind.Property; } } }