Ejemplo n.º 1
0
 protected RootNode(XmlType xmlType, IXmlNamespaceResolver nsResolver, int linenumber = -1, int lineposition = -1) : base(xmlType, xmlType.NamespaceUri, nsResolver, linenumber: linenumber, lineposition: lineposition)
 {
 }
Ejemplo n.º 2
0
 public RuntimeRootNode(XmlType xmlType, object root, IXmlNamespaceResolver resolver) : base(xmlType, resolver)
 {
     Root = root;
 }
Ejemplo n.º 3
0
        public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly,
                                          out XamlParseException exception)
        {
#if NETSTANDARD2_0
            bool hasRetriedNsSearch = false;
#endif
            IList <XamlLoader.FallbackTypeInfo> potentialTypes;

#if NETSTANDARD2_0
retry:
#endif
            if (s_xmlnsDefinitions == null)
            {
                GatherXmlnsDefinitionAttributes();
            }

            Type type = xmlType.GetTypeReference(
                s_xmlnsDefinitions,
                currentAssembly?.FullName,
                (typeInfo) =>
                Type.GetType($"{typeInfo.ClrNamespace}.{typeInfo.TypeName}, {typeInfo.AssemblyName}"),
                out potentialTypes);

            var typeArguments = xmlType.TypeArguments;
            exception = null;

#if NETSTANDARD2_0
            if (type == null)
            {
                // This covers the scenario where the AppDomain's loaded
                // assemblies might have changed since this method was first
                // called. This occurred during unit test runs and could
                // conceivably occur in the field.
                if (!hasRetriedNsSearch)
                {
                    hasRetriedNsSearch = true;
                    s_xmlnsDefinitions = null;
                    goto retry;
                }
            }
#endif

            if (XamlLoader.FallbackTypeResolver != null)
            {
                type = XamlLoader.FallbackTypeResolver(potentialTypes, type);
            }

            if (type != null && typeArguments != null)
            {
                XamlParseException innerexception = null;
                var args = typeArguments.Select(delegate(XmlType xmltype) {
                    var t = GetElementType(xmltype, xmlInfo, currentAssembly, out XamlParseException xpe);
                    if (xpe != null)
                    {
                        innerexception = xpe;
                        return(null);
                    }
                    return(t);
                }).ToArray();
                if (innerexception != null)
                {
                    exception = innerexception;
                    return(null);
                }

                try {
                    type = type.MakeGenericType(args);
                } catch (InvalidOperationException) {
                    exception = new XamlParseException($"Type {type} is not a GenericTypeDefinition", xmlInfo);
                }
            }

            if (type == null)
            {
                exception = new XamlParseException($"Type {xmlType.Name} not found in xmlns {xmlType.NamespaceUri}", xmlInfo);
            }

            return(type);
        }
Ejemplo n.º 4
0
        public static T GetTypeReference <T>(
            this XmlType xmlType,
            IEnumerable <XmlnsDefinitionAttribute> xmlnsDefinitions,
            string defaultAssemblyName,
            Func <XamlLoader.FallbackTypeInfo, T> refFromTypeInfo,
            out IList <XamlLoader.FallbackTypeInfo> potentialTypes)
            where T : class
        {
            var lookupAssemblies = new List <XmlnsDefinitionAttribute>();
            var namespaceURI     = xmlType.NamespaceUri;
            var elementName      = xmlType.Name;
            var typeArguments    = xmlType.TypeArguments;

            potentialTypes = null;

            foreach (var xmlnsDef in xmlnsDefinitions)
            {
                if (xmlnsDef.XmlNamespace != namespaceURI)
                {
                    continue;
                }
                lookupAssemblies.Add(xmlnsDef);
            }

            if (lookupAssemblies.Count == 0)
            {
                XmlnsHelper.ParseXmlns(namespaceURI, out _, out var ns, out var asmstring, out _);
                asmstring = asmstring ?? defaultAssemblyName;
                if (namespaceURI != null && ns != null)
                {
                    lookupAssemblies.Add(new XmlnsDefinitionAttribute(namespaceURI, ns)
                    {
                        AssemblyName = asmstring
                    });
                }
            }

            var lookupNames = new List <string>();

            if (elementName != "DataTemplate" && !elementName.EndsWith("Extension", StringComparison.Ordinal))
            {
                lookupNames.Add(elementName + "Extension");
            }
            lookupNames.Add(elementName);

            for (var i = 0; i < lookupNames.Count; i++)
            {
                var name = lookupNames[i];
                if (name.Contains(":"))
                {
                    name = name.Substring(name.LastIndexOf(':') + 1);
                }
                if (typeArguments != null)
                {
                    name += "`" + typeArguments.Count;                     //this will return an open generic Type
                }
                lookupNames[i] = name;
            }

            potentialTypes = new List <XamlLoader.FallbackTypeInfo>();
            foreach (string typeName in lookupNames)
            {
                foreach (XmlnsDefinitionAttribute xmlnsDefinitionAttribute in lookupAssemblies)
                {
                    potentialTypes.Add(new XamlLoader.FallbackTypeInfo {
                        ClrNamespace = xmlnsDefinitionAttribute.ClrNamespace,
                        TypeName     = typeName,
                        AssemblyName = xmlnsDefinitionAttribute.AssemblyName,
                        XmlNamespace = xmlnsDefinitionAttribute.XmlNamespace
                    });
                }
            }

            T type = null;

            foreach (XamlLoader.FallbackTypeInfo typeInfo in potentialTypes)
            {
                if ((type = refFromTypeInfo(typeInfo)) != null)
                {
                    break;
                }
            }

            return(type);
        }
Ejemplo n.º 5
0
        public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly,
                                          out XamlParseException exception)
        {
            if (s_xmlnsDefinitions == null)
            {
                GatherXmlnsDefinitionAttributes();
            }

            var namespaceURI  = xmlType.NamespaceUri;
            var elementName   = xmlType.Name;
            var typeArguments = xmlType.TypeArguments;

            exception = null;

            var lookupAssemblies = new List <XmlnsDefinitionAttribute>();
            var lookupNames      = new List <string>();

            foreach (var xmlnsDef in s_xmlnsDefinitions)
            {
                if (xmlnsDef.XmlNamespace != namespaceURI)
                {
                    continue;
                }
                lookupAssemblies.Add(xmlnsDef);
            }

            if (lookupAssemblies.Count == 0)
            {
                string ns, asmstring, _;
                XmlnsHelper.ParseXmlns(namespaceURI, out _, out ns, out asmstring, out _);
                lookupAssemblies.Add(new XmlnsDefinitionAttribute(namespaceURI, ns)
                {
                    AssemblyName = asmstring ?? currentAssembly.FullName
                });
            }

            lookupNames.Add(elementName);
            lookupNames.Add(elementName + "Extension");

            for (var i = 0; i < lookupNames.Count; i++)
            {
                var name = lookupNames[i];
                if (name.Contains(":"))
                {
                    name = name.Substring(name.LastIndexOf(':') + 1);
                }
                if (typeArguments != null)
                {
                    name += "`" + typeArguments.Count;                     //this will return an open generic Type
                }
                lookupNames[i] = name;
            }

            Type type = null;

            foreach (var asm in lookupAssemblies)
            {
                foreach (var name in lookupNames)
                {
                    if ((type = Type.GetType($"{asm.ClrNamespace}.{name}, {asm.AssemblyName}")) != null)
                    {
                        break;
                    }
                }
                if (type != null)
                {
                    break;
                }
            }

            if (type != null && typeArguments != null)
            {
                XamlParseException innerexception = null;
                var args = typeArguments.Select(delegate(XmlType xmltype)
                {
                    XamlParseException xpe;
                    var t = GetElementType(xmltype, xmlInfo, currentAssembly, out xpe);
                    if (xpe != null)
                    {
                        innerexception = xpe;
                        return(null);
                    }
                    return(t);
                }).ToArray();
                if (innerexception != null)
                {
                    exception = innerexception;
                    return(null);
                }
                type = type.MakeGenericType(args);
            }

            if (type == null)
            {
                exception = new XamlParseException($"Type {elementName} not found in xmlns {namespaceURI}", xmlInfo);
            }

            return(type);
        }
            public INode Parse(string match, ref string remaining, IServiceProvider serviceProvider)
            {
                var nsResolver = serviceProvider.GetService(typeof(IXmlNamespaceResolver)) as IXmlNamespaceResolver;

                if (nsResolver == null)
                {
                    throw new ArgumentException();
                }
                IXmlLineInfo xmlLineInfo         = null;
                var          xmlLineInfoProvider = serviceProvider.GetService(typeof(IXmlLineInfoProvider)) as IXmlLineInfoProvider;

                if (xmlLineInfoProvider != null)
                {
                    xmlLineInfo = xmlLineInfoProvider.XmlLineInfo;
                }

                var split = match.Split(':');

                if (split.Length > 2)
                {
                    throw new ArgumentException();
                }

                string prefix;                 //, name;

                if (split.Length == 2)
                {
                    prefix = split[0];
                    //					name = split [1];
                }
                else
                {
                    prefix = "";
                    //					name = split [0];
                }

                Type type;
                var  typeResolver = serviceProvider.GetService(typeof(IXamlTypeResolver)) as IXamlTypeResolver;

                if (typeResolver == null)
                {
                    type = null;
                }
                else
                {
                    //The order of lookup is to look for the Extension-suffixed class name first and then look for the class name without the Extension suffix.
                    if (!typeResolver.TryResolve(match + "Extension", out type) && !typeResolver.TryResolve(match, out type))
                    {
                        var ex = new XamlParseException($"MarkupExtension not found for {match}", serviceProvider);
                        if (ExceptionHandler != null)
                        {
                            ExceptionHandler(ex);
                            return(null);
                        }
                        throw ex;
                    }
                }

                var namespaceuri = nsResolver.LookupNamespace(prefix) ?? "";
                var xmltype      = new XmlType(namespaceuri, type.Name, null);

                if (type == null)
                {
                    throw new NotSupportedException();
                }

                node = xmlLineInfo == null
                                        ? new ElementNode(xmltype, null, nsResolver)
                                        : new ElementNode(xmltype, null, nsResolver, xmlLineInfo.LineNumber, xmlLineInfo.LinePosition);

                if (remaining.StartsWith("}", StringComparison.Ordinal))
                {
                    remaining = remaining.Substring(1);
                    return(node);
                }

                char   next;
                string piece;

                while ((piece = GetNextPiece(ref remaining, out next)) != null)
                {
                    HandleProperty(piece, serviceProvider, ref remaining, next != '=');
                }

                return(node);
            }
Ejemplo n.º 7
0
        public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly,
                                          out XamlParseException exception)
        {
            var namespaceURI  = xmlType.NamespaceUri;
            var elementName   = xmlType.Name;
            var typeArguments = xmlType.TypeArguments;

            exception = null;

            List <Tuple <string, Assembly> > lookupAssemblies = new List <Tuple <string, Assembly> >();
            List <string> lookupNames = new List <string>();

            if (!XmlnsHelper.IsCustom(namespaceURI))
            {
                lookupAssemblies.Add(new Tuple <string, Assembly>("Xamarin.Forms", typeof(View).GetTypeInfo().Assembly));
                lookupAssemblies.Add(new Tuple <string, Assembly>("Xamarin.Forms.Xaml", typeof(XamlLoader).GetTypeInfo().Assembly));
            }
            else if (namespaceURI == "http://schemas.microsoft.com/winfx/2009/xaml" ||
                     namespaceURI == "http://schemas.microsoft.com/winfx/2006/xaml")
            {
                lookupAssemblies.Add(new Tuple <string, Assembly>("Xamarin.Forms.Xaml", typeof(XamlLoader).GetTypeInfo().Assembly));
                lookupAssemblies.Add(new Tuple <string, Assembly>("System", typeof(object).GetTypeInfo().Assembly));
                lookupAssemblies.Add(new Tuple <string, Assembly>("System", typeof(Uri).GetTypeInfo().Assembly));                 //System.dll
            }
            else
            {
                string   ns;
                string   typename;
                string   asmstring;
                Assembly asm;

                XmlnsHelper.ParseXmlns(namespaceURI, out typename, out ns, out asmstring);
                asm = asmstring == null ? currentAssembly : Assembly.Load(new AssemblyName(asmstring));
                lookupAssemblies.Add(new Tuple <string, Assembly>(ns, asm));
            }

            lookupNames.Add(elementName);
            if (namespaceURI == "http://schemas.microsoft.com/winfx/2009/xaml")
            {
                lookupNames.Add(elementName + "Extension");
            }
            for (var i = 0; i < lookupNames.Count; i++)
            {
                var name = lookupNames[i];
                if (name.Contains(":"))
                {
                    name = name.Substring(name.LastIndexOf(':') + 1);
                }
                if (typeArguments != null)
                {
                    name += "`" + typeArguments.Count;                     //this will return an open generic Type
                }
                lookupNames[i] = name;
            }

            Type type = null;

            foreach (var asm in lookupAssemblies)
            {
                if (type != null)
                {
                    break;
                }
                foreach (var name in lookupNames)
                {
                    if (type != null)
                    {
                        break;
                    }
                    type = asm.Item2.GetType(asm.Item1 + "." + name);
                }
            }

            if (type != null && typeArguments != null)
            {
                XamlParseException innerexception = null;
                var args = typeArguments.Select(delegate(XmlType xmltype)
                {
                    XamlParseException xpe;
                    var t = GetElementType(xmltype, xmlInfo, currentAssembly, out xpe);
                    if (xpe != null)
                    {
                        innerexception = xpe;
                        return(null);
                    }
                    return(t);
                }).ToArray();
                if (innerexception != null)
                {
                    exception = innerexception;
                    return(null);
                }
                type = type.MakeGenericType(args);
            }

            if (type == null)
            {
                exception = new XamlParseException(string.Format("Type {0} not found in xmlns {1}", elementName, namespaceURI),
                                                   xmlInfo);
                return(null);
            }

            return(type);
        }
Ejemplo n.º 8
0
        public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly,
                                          out XamlParseException exception)
        {
            var namespaceURI  = xmlType.NamespaceUri;
            var elementName   = xmlType.Name;
            var typeArguments = xmlType.TypeArguments;

            exception = null;

            var lookupAssemblies = new List <Tuple <string, string> >();          //namespace, assemblyqualifiednamed
            var lookupNames      = new List <string>();

            if (!XmlnsHelper.IsCustom(namespaceURI))
            {
                lookupAssemblies.Add(new Tuple <string, string>("Xamarin.Forms", typeof(View).GetTypeInfo().Assembly.FullName));
                lookupAssemblies.Add(new Tuple <string, string>("Xamarin.Forms.Xaml", typeof(XamlLoader).GetTypeInfo().Assembly.FullName));
            }
            else if (namespaceURI == "http://schemas.microsoft.com/winfx/2009/xaml" ||
                     namespaceURI == "http://schemas.microsoft.com/winfx/2006/xaml")
            {
                lookupAssemblies.Add(new Tuple <string, string>("Xamarin.Forms.Xaml", typeof(XamlLoader).GetTypeInfo().Assembly.FullName));
                lookupAssemblies.Add(new Tuple <string, string>("System", typeof(object).GetTypeInfo().Assembly.FullName));              //mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                lookupAssemblies.Add(new Tuple <string, string>("System", typeof(Uri).GetTypeInfo().Assembly.FullName));                 //System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
            }
            else
            {
                string ns, asmstring, _;
                XmlnsHelper.ParseXmlns(namespaceURI, out _, out ns, out asmstring, out _);
                lookupAssemblies.Add(new Tuple <string, string>(ns, asmstring ?? currentAssembly.FullName));
            }

            lookupNames.Add(elementName);
            if (namespaceURI == "http://schemas.microsoft.com/winfx/2009/xaml")
            {
                lookupNames.Add(elementName + "Extension");
            }
            for (var i = 0; i < lookupNames.Count; i++)
            {
                var name = lookupNames[i];
                if (name.Contains(":"))
                {
                    name = name.Substring(name.LastIndexOf(':') + 1);
                }
                if (typeArguments != null)
                {
                    name += "`" + typeArguments.Count;                     //this will return an open generic Type
                }
                lookupNames[i] = name;
            }

            Type type = null;

            foreach (var asm in lookupAssemblies)
            {
                foreach (var name in lookupNames)
                {
                    if ((type = Type.GetType($"{asm.Item1}.{name}, {asm.Item2}")) != null)
                    {
                        break;
                    }
                }
                if (type != null)
                {
                    break;
                }
            }

            if (type != null && typeArguments != null)
            {
                XamlParseException innerexception = null;
                var args = typeArguments.Select(delegate(XmlType xmltype)
                {
                    XamlParseException xpe;
                    var t = GetElementType(xmltype, xmlInfo, currentAssembly, out xpe);
                    if (xpe != null)
                    {
                        innerexception = xpe;
                        return(null);
                    }
                    return(t);
                }).ToArray();
                if (innerexception != null)
                {
                    exception = innerexception;
                    return(null);
                }
                type = type.MakeGenericType(args);
            }

            if (type == null)
            {
                exception = new XamlParseException($"Type {elementName} not found in xmlns {namespaceURI}", xmlInfo);
            }

            return(type);
        }
Ejemplo n.º 9
0
 protected RootNode(XmlType xmlType, IXmlNamespaceResolver nsResolver) : base(xmlType, xmlType.NamespaceUri, nsResolver)
 {
 }
Ejemplo n.º 10
0
			public RuntimeRootNode(XmlType xmlType, object root, IXmlNamespaceResolver resolver) : base (xmlType, resolver)
			{
				Root = root;
			}
Ejemplo n.º 11
0
		static bool GetNameAndTypeRef(ref TypeReference elementType, string namespaceURI, ref string localname,
			ILContext context, IXmlLineInfo lineInfo)
		{
			var dotIdx = localname.IndexOf('.');
			if (dotIdx > 0)
			{
				var typename = localname.Substring(0, dotIdx);
				localname = localname.Substring(dotIdx + 1);
				elementType = new XmlType(namespaceURI, typename, null).GetTypeReference(context.Body.Method.Module, lineInfo);
				return true;
			}
			return false;
		}
Ejemplo n.º 12
0
        public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly,
                                          out XamlParseException exception)
        {
            bool hasRetriedNsSearch = false;

retry:
            if (s_xmlnsDefinitions == null)
            {
                GatherXmlnsDefinitionAttributes();
            }

            var namespaceURI  = xmlType.NamespaceUri;
            var elementName   = xmlType.Name;
            var typeArguments = xmlType.TypeArguments;

            exception = null;

            var lookupAssemblies = new List <XmlnsDefinitionAttribute>();
            var lookupNames      = new List <string>();

            foreach (var xmlnsDef in s_xmlnsDefinitions)
            {
                if (xmlnsDef.XmlNamespace != namespaceURI)
                {
                    continue;
                }
                lookupAssemblies.Add(xmlnsDef);
            }

            if (lookupAssemblies.Count == 0)
            {
                string ns, asmstring, _;
                XmlnsHelper.ParseXmlns(namespaceURI, out _, out ns, out asmstring, out _);
                lookupAssemblies.Add(new XmlnsDefinitionAttribute(namespaceURI, ns)
                {
                    AssemblyName = asmstring ?? currentAssembly.FullName
                });
            }

            lookupNames.Add(elementName);
            lookupNames.Add(elementName + "Extension");

            for (var i = 0; i < lookupNames.Count; i++)
            {
                var name = lookupNames[i];
                if (name.Contains(":"))
                {
                    name = name.Substring(name.LastIndexOf(':') + 1);
                }
                if (typeArguments != null)
                {
                    name += "`" + typeArguments.Count;                     //this will return an open generic Type
                }
                lookupNames[i] = name;
            }

            Type type = null;

            foreach (var asm in lookupAssemblies)
            {
                foreach (var name in lookupNames)
                {
                    if ((type = Type.GetType($"{asm.ClrNamespace}.{name}, {asm.AssemblyName}")) != null)
                    {
                        break;
                    }
                }
                if (type != null)
                {
                    break;
                }
            }

            if (type != null && typeArguments != null)
            {
                XamlParseException innerexception = null;
                var args = typeArguments.Select(delegate(XmlType xmltype)
                {
                    XamlParseException xpe;
                    var t = GetElementType(xmltype, xmlInfo, currentAssembly, out xpe);
                    if (xpe != null)
                    {
                        innerexception = xpe;
                        return(null);
                    }
                    return(t);
                }).ToArray();
                if (innerexception != null)
                {
                    exception = innerexception;
                    return(null);
                }
                type = type.MakeGenericType(args);
            }

            if (type == null)
            {
#if NETSTANDARD2_0
                // This covers the scenario where the AppDomain's loaded
                // assemblies might have changed since this method was first
                // called. This occurred during unit test runs and could
                // conceivably occur in the field.
                if (!hasRetriedNsSearch)
                {
                    hasRetriedNsSearch = true;
                    s_xmlnsDefinitions = null;
                    goto retry;
                }
#endif
                exception = new XamlParseException($"Type {elementName} not found in xmlns {namespaceURI}. Ensure third party control libraries are referenced in the code of your project and not just in XAML.  Third party control authors must also apply the \"Preserve\" attribute on their assemblies or any control classes.", xmlInfo);
            }

            return(type);
        }
Ejemplo n.º 13
0
		protected RootNode(XmlType xmlType, IXmlNamespaceResolver nsResolver) : base(xmlType, xmlType.NamespaceUri, nsResolver)
		{
		}
Ejemplo n.º 14
0
		public ElementNode(XmlType type, string namespaceURI, IXmlNamespaceResolver namespaceResolver, int linenumber = -1,
			int lineposition = -1)
			: base(namespaceResolver, linenumber, lineposition)
		{
			Properties = new Dictionary<XmlName, INode>();
			SkipProperties = new List<XmlName>();
			CollectionItems = new List<INode>();
			XmlType = type;
			NamespaceURI = namespaceURI;
		}
Ejemplo n.º 15
0
		public static Type GetElementType(XmlType xmlType, IXmlLineInfo xmlInfo, Assembly currentAssembly,
			out XamlParseException exception)
		{
			var namespaceURI = xmlType.NamespaceUri;
			var elementName = xmlType.Name;
			var typeArguments = xmlType.TypeArguments;
			exception = null;

			List<Tuple<string, Assembly>> lookupAssemblies = new List<Tuple<string, Assembly>>();
			List<string> lookupNames = new List<string>();

			if (!XmlnsHelper.IsCustom(namespaceURI))
			{
				lookupAssemblies.Add(new Tuple<string, Assembly>("Xamarin.Forms", typeof (View).GetTypeInfo().Assembly));
				lookupAssemblies.Add(new Tuple<string, Assembly>("Xamarin.Forms.Xaml", typeof (XamlLoader).GetTypeInfo().Assembly));
			}
			else if (namespaceURI == "http://schemas.microsoft.com/winfx/2009/xaml" ||
			         namespaceURI == "http://schemas.microsoft.com/winfx/2006/xaml")
			{
				lookupAssemblies.Add(new Tuple<string, Assembly>("Xamarin.Forms.Xaml", typeof (XamlLoader).GetTypeInfo().Assembly));
				lookupAssemblies.Add(new Tuple<string, Assembly>("System", typeof (object).GetTypeInfo().Assembly));
				lookupAssemblies.Add(new Tuple<string, Assembly>("System", typeof (Uri).GetTypeInfo().Assembly)); //System.dll
			}
			else
			{
				string ns;
				string typename;
				string asmstring;
				Assembly asm;

				XmlnsHelper.ParseXmlns(namespaceURI, out typename, out ns, out asmstring);
				asm = asmstring == null ? currentAssembly : Assembly.Load(new AssemblyName(asmstring));
				lookupAssemblies.Add(new Tuple<string, Assembly>(ns, asm));
			}

			lookupNames.Add(elementName);
			if (namespaceURI == "http://schemas.microsoft.com/winfx/2009/xaml")
				lookupNames.Add(elementName + "Extension");
			for (var i = 0; i < lookupNames.Count; i++)
			{
				var name = lookupNames[i];
				if (name.Contains(":"))
					name = name.Substring(name.LastIndexOf(':') + 1);
				if (typeArguments != null)
					name += "`" + typeArguments.Count; //this will return an open generic Type
				lookupNames[i] = name;
			}

			Type type = null;
			foreach (var asm in lookupAssemblies)
			{
				if (type != null)
					break;
				foreach (var name in lookupNames)
				{
					if (type != null)
						break;
					type = asm.Item2.GetType(asm.Item1 + "." + name);
				}
			}

			if (type != null && typeArguments != null)
			{
				XamlParseException innerexception = null;
				var args = typeArguments.Select(delegate(XmlType xmltype)
				{
					XamlParseException xpe;
					var t = GetElementType(xmltype, xmlInfo, currentAssembly, out xpe);
					if (xpe != null)
					{
						innerexception = xpe;
						return null;
					}
					return t;
				}).ToArray();
				if (innerexception != null)
				{
					exception = innerexception;
					return null;
				}
				type = type.MakeGenericType(args);
			}

			if (type == null)
			{
				exception = new XamlParseException(string.Format("Type {0} not found in xmlns {1}", elementName, namespaceURI),
					xmlInfo);
				return null;
			}

			return type;
		}