상속: MetaMetadataNestedField
예제 #1
0
        public int GetFieldType()
        {
            if (metadataFieldDescriptor != null)
            {
                return(metadataFieldDescriptor.FdType);
            }
            Type thisType = GetType();

            if (thisType == typeof(MetaMetadataCompositeField))
            {
                return(FieldTypes.CompositeElement);
            }
            if (thisType == typeof(MetaMetadataCollectionField))
            {
                MetaMetadataCollectionField coll = (MetaMetadataCollectionField)this;
                if (coll.ChildScalarType != null)
                {
                    return(FieldTypes.CollectionScalar);
                }
                else
                {
                    return(FieldTypes.CollectionElement);
                }
            }
            else
            {
                return(FieldTypes.Scalar);
            }
        }
        public override String GetTypeName()
        {
            String result   = null;
            Type   thisType = GetType();

            if (thisType == typeof(MetaMetadataCompositeField))
            {
                MetaMetadataCompositeField mmcf = (MetaMetadataCompositeField)this;
                if (mmcf.Type != null)
                {
                    result = mmcf.Type;
                }
            }
            else if (thisType == typeof(MetaMetadataCollectionField))
            {
                MetaMetadataCollectionField mmcf = (MetaMetadataCollectionField)this;
                if (mmcf.ChildType != null)
                {
                    result = mmcf.ChildType;
                }
                else if (mmcf.ChildScalarType != null)
                {
                    result = mmcf.ChildScalarType.CSharpTypeName;
                }
            }

            if (result == null)
            {
                MetaMetadataField inherited = SuperField;
                if (inherited != null)
                {
                    // use inherited field's type
                    result = inherited.GetTypeName();
                }
            }

            return(result ?? (Name));
        }
예제 #3
0
        public override void DeserializationPostHook(TranslationContext translationContext)
        {
            int typeCode = this.GetFieldType();

            if (typeCode == FieldTypes.CollectionScalar || this.inheritDone)
            {
                return;
            }

            String childCompositeName             = ChildType ?? UNRESOLVED_NAME;
            MetaMetadataCollectionField thisField = this;
            var composite = new MetaMetadataCompositeField(childCompositeName, Kids);

            composite.TypeChangeListener    += (newType) => this.childType = newType;
            composite.ExtendsChangeListener += (newExtends) => this.childExtends = newExtends;
            composite.TagChangeListener     += (newTag) => this.childTag = newTag;

            composite.Parent           = this;
            composite.Type             = childType;
            composite.ExtendsAttribute = this.childExtends;
            kids.Clear();
            kids.Add(composite.Name, composite);
            composite.PromoteChildren = this.PromoteChildren;
        }