Пример #1
0
        public PropertyType(FProperty prop)
        {
            Type = prop.GetType().Name.Substring(1);
            switch (prop)
            {
            case FArrayProperty array:
                var inner = array.Inner;
                if (inner != null)
                {
                    InnerType = new PropertyType(inner);
                }
                break;

            case FByteProperty b:
                EnumName = b.Enum.Load()?.Name;     // TODO if enum is UserDefinedEnum it will fail
                break;

            case FEnumProperty e:
                EnumName = e.Enum.Load()?.Name;
                break;

            case FMapProperty map:
                var key   = map.KeyProp;
                var value = map.ValueProp;
                if (key != null)
                {
                    InnerType = new PropertyType(key);
                }
                if (value != null)
                {
                    ValueType = new PropertyType(value);
                }
                break;

            case FSetProperty set:
                var element = set.ElementProp;
                if (element != null)
                {
                    InnerType = new PropertyType(element);
                }
                break;

            case FStructProperty struc:
            {
                var structClass = struc.Struct.Load <UStruct>();
                if (structClass != null)
                {
                    Struct     = structClass;
                    StructType = structClass.Name;
                }

                break;
            }
            }
        }
Пример #2
0
        private void ApplyEnum(FProperty prop, FPackageIndex enumIndex)
        {
            var enumObj = enumIndex.ResolvedObject;

            Enum      = enumObj?.Object?.Value as UEnum;
            EnumName  = enumObj?.Name.Text;
            InnerType = prop.ElementSize switch
            {
                4 => new PropertyType("IntProperty"),
                _ => null
            };
        }
    }
Пример #3
0
        public PropertyType(FProperty prop)
        {
            Type = prop.GetType().Name.Substring(1);
            switch (prop)
            {
            case FArrayProperty array:
                var inner = array.Inner;
                if (inner != null)
                {
                    InnerType = new PropertyType(inner);
                }
                break;

            case FByteProperty b:
                ApplyEnum(prop, b.Enum);
                break;

            case FEnumProperty e:
                ApplyEnum(prop, e.Enum);
                break;

            case FMapProperty map:
                var key   = map.KeyProp;
                var value = map.ValueProp;
                if (key != null)
                {
                    InnerType = new PropertyType(key);
                }
                if (value != null)
                {
                    ValueType = new PropertyType(value);
                }
                break;

            case FSetProperty set:
                var element = set.ElementProp;
                if (element != null)
                {
                    InnerType = new PropertyType(element);
                }
                break;

            case FStructProperty struc:
                var structObj = struc.Struct.ResolvedObject;
                Struct     = structObj?.Object?.Value as UStruct;
                StructType = structObj?.Name.Text;
                break;
            }
        }