コード例 #1
0
ファイル: PropertyObserver.cs プロジェクト: Ref12/Grazor
        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);
        }
コード例 #2
0
ファイル: PropertyPath.cs プロジェクト: will8886/Granular
 public IndexPropertyPathElement(XamlName propertyName, IEnumerable <string> indexRawValues, XamlNamespaces namespaces, Uri sourceUri)
 {
     this.PropertyName   = propertyName;
     this.IndexRawValues = indexRawValues;
     this.namespaces     = namespaces;
     this.sourceUri      = sourceUri;
 }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
ファイル: XamlContext.cs プロジェクト: xhowar/lindexi_gd
        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));
        }
コード例 #6
0
ファイル: XamlPropertyName.cs プロジェクト: Athari/Alba.Jaml
 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;
     }
 }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
        }
コード例 #9
0
 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;
     }
 }
コード例 #10
0
 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;
     }
 }
コード例 #11
0
ファイル: TypeParser.cs プロジェクト: llenroc/Granular
        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);
        }
コード例 #12
0
ファイル: RoutedEvent.cs プロジェクト: will8886/Granular
        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);
        }
コード例 #13
0
ファイル: RoutedEvent.cs プロジェクト: portalninja/Granular
        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);
        }
コード例 #14
0
ファイル: PropertyPath.cs プロジェクト: llenroc/Granular
        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);
        }
コード例 #15
0
ファイル: PropertyPath.cs プロジェクト: will8886/Granular
        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);
        }
コード例 #16
0
        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;
        }
コード例 #17
0
ファイル: PropertyPath.cs プロジェクト: will8886/Granular
 public PropertyPathElement(XamlName propertyName)
 {
     this.PropertyName = propertyName;
 }
コード例 #18
0
 internal XamlType GetXamlType(XamlName typeName, bool returnUnknownTypesOnFailure)
 {
     XamlTypeName xamlTypeName = this.GetXamlTypeName(typeName);
     return this.GetXamlType(xamlTypeName, returnUnknownTypesOnFailure);
 }
コード例 #19
0
ファイル: PropertyPath.cs プロジェクト: will8886/Granular
 public object ConvertFrom(XamlNamespaces namespaces, Uri sourceUri, object value)
 {
     return(new PropertyPathElement(XamlName.FromPrefixedName((string)value, namespaces)));
 }
コード例 #20
0
ファイル: XamlContext.cs プロジェクト: xhowar/lindexi_gd
        internal XamlType GetXamlType(XamlName typeName, bool returnUnknownTypesOnFailure)
        {
            XamlTypeName fullTypeName = GetXamlTypeName(typeName);

            return(GetXamlType(fullTypeName, returnUnknownTypesOnFailure));
        }
コード例 #21
0
 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);
     }
 }
コード例 #22
0
ファイル: ProtoParser.cs プロジェクト: danwalmsley/OmniXAML
        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);
        }
コード例 #23
0
ファイル: ProtoParser.cs プロジェクト: danwalmsley/OmniXAML
 private static string ResolveXamlNameNs(XamlName name)
 {
     return name.Namespace;
 }
コード例 #24
0
 internal XamlType GetXamlType(XamlName typeName)
 {
     return(this.GetXamlType(typeName, false));
 }
コード例 #25
0
 internal XamlType GetXamlType(XamlName typeName)
 {
     return this.GetXamlType(typeName, false);
 }
コード例 #26
0
 private XamlType CreateErrorXamlType(XamlName name, string xmlns)
 {
     return new XamlType(xmlns, name.Name, null, this._parserContext.SchemaContext);
 }
コード例 #27
0
 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;
     }
 }
コード例 #28
0
 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);
 }
コード例 #29
0
 private bool IsNameDirective(XamlName propertyLocator, XamlType ownerType)
 {
     return propertyLocator.PropertyName == ownerType.RuntimeNamePropertyMember?.Name;
 }
コード例 #30
0
 private string ResolveXamlNameNS(XamlName name)
 {
     return (name.Namespace ?? this.FindNamespaceByPrefix(name.Prefix));
 }
コード例 #31
0
        internal XamlType GetXamlType(XamlName typeName, bool returnUnknownTypesOnFailure)
        {
            XamlTypeName xamlTypeName = this.GetXamlTypeName(typeName);

            return(this.GetXamlType(xamlTypeName, returnUnknownTypesOnFailure));
        }
コード例 #32
0
 private bool IsNameDirective(XamlName propertyLocator, XamlType ownerType)
 {
     return(propertyLocator.PropertyName == ownerType.RuntimeNamePropertyMember?.Name);
 }
コード例 #33
0
 private string ResolveXamlNameNS(XamlName name)
 {
     return(name.Namespace ?? this.FindNamespaceByPrefix(name.Prefix));
 }
コード例 #34
0
        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);
                }
            }
        }