public static TypeInfo Create(Type T)
        {
            string typeId = NameUtility.GetTypeIdentifier(T);

            return(new TypeInfo()
            {
                typeIdentifier = typeId
            });
        }
Ejemplo n.º 2
0
        public RawTypeInfo(Type T)
        {
            this.fullName      = NameUtility.GetTypeIdentifier(T);
            this.namespaceName = NameUtility.GetTypeNamespaceName(T);
            this.className     = NameUtility.GetTypeClassName(T);
            this.isGeneric     = T.IsGenericType;
            this.isArray       = T.IsArray;

            if (this.isGeneric)
            {
                this.genericArguments.AddRange(T.GenericTypeArguments.Select(t => NameUtility.GetTypeIdentifier(t)));
            }

            if (T.BaseType != null)
            {
                this.baseClass = NameUtility.GetTypeIdentifier(T.BaseType);
            }

            // fields
            foreach (var field in T.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
            {
                var fieldName = field.Name;
                if (!TypeFilter.IsBannedField(field))
                {
                    var rawFieldInfo = new RawFieldInfo(field);
                    fields.Add(rawFieldInfo.Name, rawFieldInfo);
                }
            }

            // attributes
            foreach (var attrib in T.CustomAttributes)
            {
                var type = attrib.AttributeType;
                if (!this.attributes.ContainsKey(type.Name))
                {
                    this.attributes.Add(type.Name, NameUtility.GetTypeIdentifier(type));
                }
            }

            // useful methods
            var methods = T.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            foreach (var method in methods)
            {
                switch (method.Name)
                {
                case "LoadDataFromXmlCustom":
                    this.methods.Add(method.Name);
                    break;
                }
            }
        }
Ejemplo n.º 3
0
        public RawFieldInfo(FieldInfo fieldInfo)
        {
            this.Name          = fieldInfo.Name;
            this.declaringType = NameUtility.GetTypeIdentifier(fieldInfo.DeclaringType);
            this.fieldType     = NameUtility.GetTypeIdentifier(fieldInfo.FieldType);
            this.isPublic      = fieldInfo.IsPublic;
            this.isPrivate     = fieldInfo.IsPrivate;

            foreach (var attrib in fieldInfo.CustomAttributes)
            {
                if (!attrib.AttributeType.IsSpecialName)
                {
                    var attribType = attrib.AttributeType;
                    attributes.Add(attribType.Name, NameUtility.GetTypeIdentifier(attribType));
                }
            }
        }
Ejemplo n.º 4
0
        static void PopulateData()
        {
            foreach (var pair in typeDict)
            {
                var type        = pair.Key;
                var rawTypeInfo = pair.Value;

                if (type.Name.Contains("CompProperties"))
                {
                    var baseType = type;
                    var objType  = typeof(object);
                    while (baseType != null && baseType.BaseType != objType && baseType.Name.Contains("CompProperties"))
                    { // possible bug - baseType was not registered in static typeDict, maybe
                      // also if CompProperties have interface, then it will throw the error cuz baseType is null
                      // I'm just adding baseType != null to avoid critical issues, fix this later
                        baseType = baseType.BaseType;
                    }

                    rawTypeInfo.metadata.compClass.baseClass = NameUtility.GetTypeIdentifier(baseType);
                }

                rawTypeInfo.populated = true;
            }
        }