Beispiel #1
0
        public void Initialize(IXmlNamespace xmlNamespace, Type type, string key)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }
            PlatformTypes platformMetadata = (PlatformTypes)this.PlatformMetadata;

            this.isBuilt      = true;
            this.xmlNamespace = xmlNamespace;
            this.type         = type;
            Type nearestSupportedType = platformMetadata.GetNearestSupportedType(this.type);

            if (nearestSupportedType != null)
            {
                this.nearestSupportedType = platformMetadata.GetType(nearestSupportedType);
            }
            this.lastResolvedType = this.type;
            this.name             = ProjectContextType.GetNameIncludingAnyDeclaringTypes(this.type);
            Assembly  assembly        = this.type.Assembly;
            IAssembly projectAssembly = this.typeResolver.ProjectAssembly;

            if (projectAssembly == null || !projectAssembly.CompareTo(assembly))
            {
                this.assemblyName = AssemblyHelper.GetAssemblyName(assembly).Name;
                if (projectAssembly != null)
                {
                    bool name = this.assemblyName == projectAssembly.Name;
                }
            }
            this.members  = new MemberCollection(this.typeResolver, this);
            this.assembly = this.GetAssembly(this.typeResolver, this.assemblyName);
            if (type.IsArray)
            {
                this.arrayItemType = ProjectContextType.GetItemType(this.typeResolver, type);
                this.arrayRank     = type.GetArrayRank();
            }
            this.genericTypeArguments = PlatformTypeHelper.GetGenericTypeArguments(this.typeResolver, this.type);
            if (this.genericTypeArguments.Count > 0)
            {
                foreach (IType genericTypeArgument in this.genericTypeArguments)
                {
                    ProjectContextType projectContextType = genericTypeArgument as ProjectContextType;
                    if (projectContextType == null)
                    {
                        continue;
                    }
                    this.genericDepth = Math.Max(projectContextType.genericDepth + 1, this.genericDepth);
                }
            }
            this.Cache();
            this.hashCode = key.GetHashCode();
        }