private static IPropertyObserver CreateBaseObserver(Type containingType, XamlName propertyName) { if (propertyName.IsEmpty) { return(null); } containingType = propertyName.ResolveContainingType(containingType); DependencyProperty dependencyProperty = DependencyProperty.GetProperty(containingType, propertyName.MemberName); if (dependencyProperty != null) { return(new DependencyPropertyObserver(dependencyProperty)); } PropertyInfo propertyInfo = containingType.GetInstanceProperty(propertyName.MemberName); if (propertyInfo != null && !propertyInfo.GetIndexParameters().Any()) { return(new ClrPropertyObserver(propertyInfo, new object[0])); } return(null); }
public IndexPropertyPathElement(XamlName propertyName, IEnumerable <string> indexRawValues, XamlNamespaces namespaces, Uri sourceUri) { this.PropertyName = propertyName; this.IndexRawValues = indexRawValues; this.namespaces = namespaces; this.sourceUri = sourceUri; }
public static DependencyProperty GetProperty(Type containingType, XamlName propertyName) { if (propertyName.IsMemberName) { containingType = TypeParser.ParseType(propertyName.ContainingTypeName); } return(GetOwnedProperty(containingType, propertyName.MemberName) ?? GetSingleProperty(containingType.BaseType, propertyName.MemberName)); }
internal XamlTypeName GetXamlTypeName(XamlName typeName) { string xamlNamespace = this.ResolveXamlNameNS(typeName); if (xamlNamespace == null) { throw new XamlParseException(System.Xaml.SR.Get("PrefixNotFound", new object[] { typeName.Prefix })); } return(new XamlTypeName(xamlNamespace, typeName.Name)); }
internal XamlTypeName GetXamlTypeName(XamlName typeName) { string xamlNs = ResolveXamlNameNS(typeName); if (xamlNs == null) { throw new XamlParseException(SR.Get(SRID.PrefixNotFound, typeName.Prefix)); } return(new XamlTypeName(xamlNs, typeName.Name)); }
private XamlPropertyName (XamlName owner, string prefix, string name) : base(name) { if (owner != null) { this.Owner = owner; base._prefix = owner.Prefix ?? string.Empty; } else { base._prefix = prefix ?? string.Empty; } }
public static RoutedEvent GetRoutedEvent(XamlName eventName) { if (!eventName.IsMemberName) { throw new Granular.Exception("Invalid routed event name \"{0}\"", eventName.LocalName); } Type ownerType = TypeParser.ParseType(eventName.ContainingTypeName); return(GetOwnedRoutedEvent(ownerType, eventName.MemberName)); }
public static DependencyProperty GetProperty(Type containingType, XamlName propertyName) { if (!propertyName.IsMemberName) { // containing type wasn't specified, so the property could be owned by a base type return(GetSingleProperty(containingType, propertyName.LocalName)); } Type ownerType = TypeParser.ParseType(propertyName.ContainingTypeName); return(GetOwnedProperty(ownerType, propertyName.MemberName)); }
private PropertyLocator(XamlName owner, string prefix, string propertyName) : base(propertyName) { if (owner != null) { Owner = owner; Prefix = owner.Prefix ?? string.Empty; } else { Prefix = prefix ?? string.Empty; } }
public static string ParseTypeName(this ITypeParser typeParser, XamlName name) { if (XamlLanguage.IsXamlType(name)) { return(String.Empty); } string typeName; if (!typeParser.TryParseTypeName(name.LocalName, name.NamespaceName, out typeName)) { throw new Granular.Exception("Type \"{0}\" wasn't found", name); } return(typeName); }
public object ConvertFrom(XamlNamespaces namespaces, Uri sourceUri, object value) { string text = value.ToString().Trim(); XamlName eventName = XamlName.FromPrefixedName(text, namespaces); Type containingType = eventName.ResolveContainingType(null); if (containingType == null) { throw new Granular.Exception("Invalid routed event name \"{0}\"", eventName.LocalName); } RoutedEvent routedEvent = EventManager.GetEvent(containingType, eventName.MemberName); if (routedEvent == null) { throw new Granular.Exception("Can't find a routed event named \"{0}\"", eventName); } return(routedEvent); }
public object ConvertFrom(XamlNamespaces namespaces, object value) { string text = value.ToString().Trim(); XamlName eventName = XamlName.FromPrefixedName(text, namespaces); if (!eventName.IsMemberName) { throw new Granular.Exception("Invalid routed event name \"{0}\"", eventName.LocalName); } Type containingType = TypeParser.ParseType(eventName.ContainingTypeName); RoutedEvent routedEvent = EventManager.FindRoutedEvent(containingType, eventName.MemberName); if (routedEvent == null) { throw new Granular.Exception("Can't find a routed event named \"{0}\"", eventName); } return(routedEvent); }
public static bool TryGetValue(object target, XamlName propertyName, out object value) { DependencyProperty dependencyProperty = DependencyProperty.GetProperty(target.GetType(), propertyName); if (dependencyProperty != null && target is DependencyObject) { value = ((DependencyObject)target).GetValue(dependencyProperty); return(true); } Type propertyContainingType = propertyName.IsMemberName ? TypeParser.ParseType(propertyName.ContainingTypeName) : target.GetType(); PropertyInfo propertyInfo = propertyContainingType.GetInstanceProperty(propertyName.MemberName); if (propertyInfo != null && !propertyInfo.GetIndexParameters().Any()) { value = propertyInfo.GetValue(target, new object[0]); return(true); } value = null; return(false); }
public static bool TryGetValue(object target, XamlName propertyName, out object value) { Type containingType = propertyName.ResolveContainingType(target.GetType()); DependencyProperty dependencyProperty = DependencyProperty.GetProperty(containingType, propertyName.MemberName); if (dependencyProperty != null && target is DependencyObject) { value = ((DependencyObject)target).GetValue(dependencyProperty); return(true); } PropertyInfo propertyInfo = containingType.GetInstanceProperty(propertyName.MemberName); if (propertyInfo != null && !propertyInfo.GetIndexParameters().Any()) { value = propertyInfo.GetValue(target, new object[0]); return(true); } value = null; return(false); }
private bool IsNameDirective(XamlName propertyLocator, XamlType ownerType) { var metadata = wiringContext.TypeContext.TypeRepository.GetMetadata(ownerType.UnderlyingType); if (metadata == null) return false; return propertyLocator.PropertyName == metadata.RuntimePropertyName; }
public PropertyPathElement(XamlName propertyName) { this.PropertyName = propertyName; }
internal XamlType GetXamlType(XamlName typeName, bool returnUnknownTypesOnFailure) { XamlTypeName xamlTypeName = this.GetXamlTypeName(typeName); return this.GetXamlType(xamlTypeName, returnUnknownTypesOnFailure); }
public object ConvertFrom(XamlNamespaces namespaces, Uri sourceUri, object value) { return(new PropertyPathElement(XamlName.FromPrefixedName((string)value, namespaces))); }
internal XamlType GetXamlType(XamlName typeName, bool returnUnknownTypesOnFailure) { XamlTypeName fullTypeName = GetXamlTypeName(typeName); return(GetXamlType(fullTypeName, returnUnknownTypesOnFailure)); }
private void ReadObjectElement(XamlName name, bool isEmptyTag) { this._typeArgumentAttribute = null; XamlScannerNode node = new XamlScannerNode(this._xmlLineInfo); this.PreprocessAttributes(); node.Prefix = name.Prefix; node.IsEmptyTag = isEmptyTag; string namespaceURI = this._xmlReader.NamespaceURI; if (namespaceURI == null) { this.ReadObjectElement_NoNamespace(name, node); } else { node.TypeNamespace = namespaceURI; XamlMember xamlDirective = this._parserContext.SchemaContext.GetXamlDirective(namespaceURI, name.Name); if (xamlDirective != null) { this.ReadObjectElement_DirectiveProperty(xamlDirective, node); } else if (this.ReadObjectElement_Object(namespaceURI, name.Name, node)) { return; } } this._readNodesQueue.Enqueue(node); while (this.HaveUnprocessedAttributes) { this.EnqueueAnotherAttribute(isEmptyTag); } }
private void ReadObjectElement(XamlName name, bool isEmptyTag) { var attributes = EnqueuePrefixDefinitionsAndGetTheRestOfAttributes(); var node = new ProtoParserNode {Prefix = name.Prefix, IsEmptyTag = isEmptyTag}; var namespaceUri = xmlReader.NamespaceURI; node.TypeNamespace = namespaceUri; var xamlAttributes = ReadObjectElementObject(namespaceUri, name.PropertyName, node, attributes); nodes.Enqueue(node); EnqueueAttributes(xamlAttributes); }
private static string ResolveXamlNameNs(XamlName name) { return name.Namespace; }
internal XamlType GetXamlType(XamlName typeName) { return(this.GetXamlType(typeName, false)); }
internal XamlType GetXamlType(XamlName typeName) { return this.GetXamlType(typeName, false); }
private XamlType CreateErrorXamlType(XamlName name, string xmlns) { return new XamlType(xmlns, name.Name, null, this._parserContext.SchemaContext); }
private void ReadObjectElement_NoNamespace(XamlName name, XamlScannerNode node) { XamlType type = this.CreateErrorXamlType(name, string.Empty); node.Type = type; this.PostprocessAttributes(node); if (!node.IsEmptyTag) { node.NodeType = ScannerNodeType.ELEMENT; this._scannerStack.Push(node.Type, node.TypeNamespace); } else { node.NodeType = ScannerNodeType.EMPTYELEMENT; } }
internal XamlTypeName GetXamlTypeName(XamlName typeName) { string xamlNamespace = this.ResolveXamlNameNS(typeName); if (xamlNamespace == null) { throw new XamlParseException(System.Xaml.SR.Get("PrefixNotFound", new object[] { typeName.Prefix })); } return new XamlTypeName(xamlNamespace, typeName.Name); }
private bool IsNameDirective(XamlName propertyLocator, XamlType ownerType) { return propertyLocator.PropertyName == ownerType.RuntimeNamePropertyMember?.Name; }
private string ResolveXamlNameNS(XamlName name) { return (name.Namespace ?? this.FindNamespaceByPrefix(name.Prefix)); }
internal XamlType GetXamlType(XamlName typeName, bool returnUnknownTypesOnFailure) { XamlTypeName xamlTypeName = this.GetXamlTypeName(typeName); return(this.GetXamlType(xamlTypeName, returnUnknownTypesOnFailure)); }
private bool IsNameDirective(XamlName propertyLocator, XamlType ownerType) { return(propertyLocator.PropertyName == ownerType.RuntimeNamePropertyMember?.Name); }
private string ResolveXamlNameNS(XamlName name) { return(name.Namespace ?? this.FindNamespaceByPrefix(name.Prefix)); }
void AnalyzeElement(XamlContext txt, XElement elem) { foreach (var i in elem.Attributes()) { if (i.Name.NamespaceName == "http://www.w3.org/2000/xmlns/") { txt.namespaces[i.Name.LocalName] = ParseXmlNs(i.Value, txt); } else if (i.Name.LocalName == "xmlns") { txt.namespaces[""] = ParseXmlNs(i.Value, txt); } } XamlName name = XamlName.Parse(elem.Name, txt); name.Xmlns = elem.GetPrefixOfNamespace(name.Xmlns); if (name.TypeDef == null) { Logger._Log("> Could not resolve '" + elem.Name.ToString() + "'!"); } else if (Assemblies.Contains(name.TypeDef.Module.Assembly)) { IXmlLineInfo li = elem as IXmlLineInfo; string line = txt.lines[li.LineNumber - 1]; int end = line.IndexOf(' ', li.LinePosition - 1); if (end == -1) { end = line.IndexOf('>', li.LinePosition - 1); } string str = line.Substring(li.LinePosition - 1, end - li.LinePosition + 1); var r = new XamlNameReference() { Name = name }; txt.refers.Add(new XamlRef() { lineNum = li.LineNumber - 1, index = li.LinePosition - 1, length = end - li.LinePosition + 1, name = name, refer = r }); ((name.TypeDef as IAnnotationProvider).Annotations[RenRef] as List <IReference>).Add(r); } foreach (var i in elem.Attributes()) { if (i.Name.NamespaceName != "http://www.w3.org/2000/xmlns/" && i.Name.LocalName != "xmlns") { AnalyzePropertyAttr(name.TypeDef, txt, i); } } foreach (var i in elem.Elements()) { if (i.Name.LocalName.Contains(".")) { AnalyzePropertyElem(name.TypeDef, txt, i); } else { AnalyzeElement(txt, i); } } }