Пример #1
0
        static bool IsElementChildACollectionForProperty(XamlTypeFinder typeFinder, XmlElement element,
                                                         XamlPropertyInfo propertyInfo)
        {
            var nodes = element.ChildNodes.Cast <XmlNode>().Where(x => !(x is XmlWhitespace)).ToList();

            return(nodes.Count == 1 &&
                   propertyInfo.ReturnType.IsAssignableFrom(
                       FindType(typeFinder, nodes[0].NamespaceURI, nodes[0].LocalName)));
        }
Пример #2
0
 static WpfTypeFinder()
 {
     Instance = new XamlTypeFinder();
     Instance.RegisterDesignerNamespaces();
     Instance.RegisterAssembly(typeof(MarkupExtension).Assembly); // WindowsBase
     Instance.RegisterAssembly(typeof(IAddChild).Assembly);       // PresentationCore
     Instance.RegisterAssembly(typeof(XamlReader).Assembly);      // PresentationFramework
     Instance.RegisterAssembly(typeof(XamlType).Assembly);        // System.Xaml
     Instance.RegisterAssembly(typeof(Type).Assembly);            // mscorelib
 }
Пример #3
0
        static Type FindType(XamlTypeFinder typeFinder, string namespaceUri, string localName)
        {
            Type elementType = typeFinder.GetType(namespaceUri, localName);

            if (elementType == null)
            {
                elementType = typeFinder.GetType(namespaceUri, localName + "Extension");
            }
            if (elementType == null)
            {
                throw new XamlLoadException("Cannot find type " + localName + " in " + namespaceUri);
            }
            return(elementType);
        }
Пример #4
0
 /// <summary>
 /// Import information from another XamlTypeFinder.
 /// Use this if you override Clone().
 /// </summary>
 protected void ImportFrom(XamlTypeFinder source)
 {
     if (source == null)
     {
         throw new ArgumentNullException("source");
     }
     foreach (KeyValuePair <string, XamlNamespace> pair in source.namespaces)
     {
         this.namespaces.Add(pair.Key, pair.Value.Clone());
     }
     foreach (KeyValuePair <AssemblyNamespaceMapping, string> pair in source.reverseDict)
     {
         this.reverseDict.Add(pair.Key, pair.Value);
     }
     foreach (KeyValuePair <AssemblyNamespaceMapping, List <string> > pair in source.reverseDictList)
     {
         this.reverseDictList.Add(pair.Key, pair.Value.ToList());
     }
 }
Пример #5
0
        static XamlPropertyInfo GetPropertyInfo(object elementInstance, Type elementType, XmlAttribute attribute,
                                                XamlTypeFinder typeFinder)
        {
            var ret = GetXamlSpecialProperty(attribute);

            if (ret != null)
            {
                return(ret);
            }
            if (attribute.LocalName.Contains("."))
            {
                return(GetPropertyInfo(typeFinder, elementInstance, elementType, GetAttributeNamespace(attribute),
                                       attribute.LocalName));
            }
            else
            {
                return(FindProperty(elementInstance, elementType, attribute.LocalName));
            }
        }