Beispiel #1
0
        public List <uint> GetFieldOrder(Type type)
        {
            List <uint> parentFields = new List <uint>();

            if (type.BaseType != typeof(STUInstance))
            {
                parentFields = GetFieldOrder(type.BaseType);
            }
            List <uint> fields = new List <uint>();

            foreach (FieldInfo field in type.GetFields(BindingFlags.Public
                                                       | BindingFlags.Instance
                                                       | BindingFlags.DeclaredOnly))
            {
                STUFieldAttribute fieldAttribute = field.GetCustomAttribute <STUFieldAttribute>();
                if (fieldAttribute == null)
                {
                    continue;
                }
                if (fieldAttribute.Hash == 0)
                {
                    continue;
                }
                fields.Add(fieldAttribute.Hash);
            }
            var temp = parentFields.Concat(fields).ToList();

            //var temp = fields.Concat(parentFields).ToList();
            return(temp);
        }
Beispiel #2
0
        public void AddInstance(Type type)
        {
            STUAttribute attribute = type.GetCustomAttribute <STUAttribute>();

            if (attribute == null)
            {
                return;
            }
            if (attribute.Hash == 0)
            {
                return;
            }

            InstanceAttributes[attribute.Hash] = attribute;
            Instances[attribute.Hash]          = type;
            InstancesInverted[type]            = attribute.Hash;
            FieldAttributes[attribute.Hash]    = new Dictionary <uint, KeyValuePair <FieldInfo, STUFieldAttribute> >();
            //List<uint> fieldOrderTemp = new List<uint>();

            foreach (FieldInfo field in type.GetFields())
            {
                STUFieldAttribute fieldAttribute = field.GetCustomAttribute <STUFieldAttribute>();
                if (fieldAttribute == null)
                {
                    continue;
                }
                if (fieldAttribute.Hash == 0)
                {
                    continue;
                }
                //fieldOrderTemp.Add(fieldAttribute.Hash);

                FieldAttributes[attribute.Hash][fieldAttribute.Hash] = new KeyValuePair <FieldInfo, STUFieldAttribute>(field, fieldAttribute);
            }

            //InstanceFields[attribute.Hash] = fieldOrderTemp.ToArray();
            InstanceFields[attribute.Hash] = GetFieldOrder(type).ToArray();  // shrug
        }