コード例 #1
0
        private IType GetType(string key, IAssembly assembly, Type type)
        {
            ProjectContextType projectContextType;
            IType type1 = this.platformTypes.GetType(type);

            if (type1 != null)
            {
                return(type1);
            }
            if (assembly == null)
            {
                assembly = this.GetAssembly(type.Assembly);
                if (assembly == null)
                {
                    IAssembly assembly1 = this.platformTypes.CreateAssembly(type.Assembly, AssemblySource.Unknown);
                    foreach (IAssembly assemblyReference in this.AssemblyReferences)
                    {
                        if (!assembly1.Name.StartsWith(assemblyReference.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        string str = assembly1.Name.Substring(assemblyReference.Name.Length);
                        if (string.Compare(str, ".design", StringComparison.OrdinalIgnoreCase) != 0 && string.Compare(str, ".expression.design", StringComparison.OrdinalIgnoreCase) != 0)
                        {
                            continue;
                        }
                        assembly = assembly1;
                    }
                    if (assembly == null)
                    {
                        return(null);
                    }
                }
            }
            if (key == null)
            {
                key = this.GetKey(assembly, type);
                if (key == null)
                {
                    return(null);
                }
            }
            if (!this.typeIds.TryGetValue(key, out projectContextType))
            {
                projectContextType = new ProjectContextType(this, key);
                this.typeIds.Add(key, projectContextType);
                IXmlNamespace @namespace = this.ProjectNamespaces.GetNamespace(assembly, type);
                projectContextType.Initialize(@namespace, type, key);
            }
            return(projectContextType);
        }
コード例 #2
0
        public IType GetType(string assemblyName, string typeName)
        {
            IAssembly              assembly;
            ProjectContextType     projectContextType;
            UnbuiltTypeDescription unbuiltTypeDescription;
            IType type = null;

            if (string.IsNullOrEmpty(typeName))
            {
                throw new ArgumentException(ExceptionStringTable.GetTypeCannotBeCalledWithNullOrEmptyTypeName, "typeName");
            }
            assembly = (!string.IsNullOrEmpty(assemblyName) ? this.GetAssembly(assemblyName) : this.ProjectAssembly);
            if (assembly != null)
            {
                string key = this.GetKey(assembly, typeName);
                if (this.typeIds.TryGetValue(key, out projectContextType))
                {
                    return(projectContextType);
                }
                Type type1 = null;
                try
                {
                    type1 = PlatformTypeHelper.GetType(assembly, typeName);
                }
                catch (Exception exception)
                {
                }
                if (type1 != null)
                {
                    type = this.GetType(key, assembly, type1);
                }
                if (type == null && this.unbuiltTypeInfo.TryGetValue(key, out unbuiltTypeDescription))
                {
                    projectContextType = new ProjectContextType(this, key);
                    this.typeIds.Add(key, projectContextType);
                    projectContextType.Initialize(unbuiltTypeDescription, key);
                    type = projectContextType;
                }
            }
            return(type);
        }