コード例 #1
0
        private void Cache()
        {
            Type          runtimeType;
            ITypeMetadata metadata;

            if (this.isBuilt)
            {
                this.baseType = null;
                if (this.type != null)
                {
                    Type baseType = this.type.BaseType;
                    if (baseType != null)
                    {
                        this.baseType = this.typeResolver.GetType(baseType);
                    }
                }
                else if (this.lastResolvedType != null && this.lastResolvedType.BaseType != null)
                {
                    this.baseType = this.typeResolver.GetType(this.lastResolvedType.BaseType);
                }
                if (this.baseType == null && !this.IsInterface)
                {
                    this.baseType = this.typeResolver.ResolveType(PlatformTypes.Object);
                }
            }
            if (this.NearestResolvedType != null)
            {
                runtimeType = this.NearestResolvedType.RuntimeType;
            }
            else
            {
                runtimeType = null;
            }
            Type type = runtimeType;

            if (type == null)
            {
                type = typeof(object);
            }
            if (this.typeResolver.MetadataFactory != null)
            {
                metadata = this.typeResolver.MetadataFactory.GetMetadata(type);
            }
            else
            {
                metadata = null;
            }
            this.metadata = metadata;
            if (this.metadata == null || this.genericDepth >= 10)
            {
                this.nameProperty           = null;
                this.defaultContentProperty = null;
            }
            else
            {
                this.nameProperty           = this.metadata.NameProperty;
                this.defaultContentProperty = this.metadata.DefaultContentProperty;
            }
            this.itemType     = ProjectContextType.GetItemType(this.typeResolver, type);
            this.nullableType = null;
            Type nullableType = PlatformTypeHelper.GetNullableType(type);

            if (nullableType != null)
            {
                this.nullableType = this.typeResolver.GetType(nullableType);
            }
            if (this.PlatformMetadata != null)
            {
                this.typeConverter = this.PlatformMetadata.GetTypeConverter(type);
            }
        }