System.Type.Init C# (CSharp) Method

Init() public method

public Init ( string fullName, int flags, JsTypeFunction thisType, JsTypeFunction baseType, JsTypeFunction interfaces, JsTypeFunction typeArguments, FieldInfo fields, MethodInfo methods, ConstructorInfo constructors, PropertyInfo properties, EventInfo events, JsTypeFunction elementType, JsTypeFunction unconstructedType ) : void
fullName string
flags int
thisType JsTypeFunction
baseType JsTypeFunction
interfaces JsTypeFunction
typeArguments JsTypeFunction
fields FieldInfo
methods MethodInfo
constructors ConstructorInfo
properties PropertyInfo
events EventInfo
elementType JsTypeFunction
unconstructedType JsTypeFunction
return void
        public void Init(string fullName, int flags, JsTypeFunction thisType, JsTypeFunction baseType, JsTypeFunction[] interfaces, 
            JsTypeFunction[] typeArguments, FieldInfo[] fields, MethodInfo[] methods, ConstructorInfo[] constructors, 
            PropertyInfo[] properties, EventInfo[] events, JsTypeFunction elementType, JsTypeFunction unconstructedType)
        {
            FullName = fullName;

            typeFlags = (TypeFlags)flags;
            if ((typeFlags & TypeFlags.GenericType) != 0)
                isGenericType = true;
            if ((typeFlags & TypeFlags.ValueType) != 0)
                isValueType = true;
            if ((typeFlags & TypeFlags.Primitive) != 0)
                isPrimitive = true;
            if ((typeFlags & TypeFlags.Abstract) != 0)
                isAbstract = true;
            if ((typeFlags & TypeFlags.Interface) != 0)
                isInterface = true;
            if ((typeFlags & TypeFlags.Sealed) != 0)
                isSealed = true;
            if ((typeFlags & TypeFlags.Public) != 0)
                isPublic = true;
            if ((typeFlags & TypeFlags.Enum) != 0)
                isEnum = true;
            if ((typeFlags & TypeFlags.GenericTypeDefenition) != 0)
                isGenericTypeDefinition = true;
            if ((typeFlags & TypeFlags.GenericParameter) != 0)
                isGenericParameter = true;

//            this.typeAttributes = typeAttributes;
            this.thisType = thisType;
            this.baseType = baseType;
            this.interfaces = interfaces;
            this.typeArguments = typeArguments;
            this.fields = fields ?? new FieldInfo[0];
            this.methods = methods ?? new MethodInfo[0];
            this.properties = properties ?? new PropertyInfo[0];
            this.constructors = constructors ?? new ConstructorInfo[0];
            this.events = events ?? new EventInfo[0];
            this.elementType = elementType;
            this.unconstructedType = unconstructedType;

            foreach (var field in this.fields)
                field.declaringType = this;
            foreach (var method in this.methods)
                method.declaringType = this;
            foreach (var property in this.properties)
            {
                property.declaringType = this;
                if (property.GetMethod != null)
                    property.GetMethod.declaringType = this;
                if (property.SetMethod != null)
                    property.SetMethod.declaringType = this;
            }
            foreach (var constructor in this.constructors)
                constructor.declaringType = this;
        }

Usage Example

Ejemplo n.º 1
0
 public static Type CreateTypeParameter(string fullName, JsTypeFunction baseType)
 {
     var type = new Type(fullName, new Attribute[0]);
     type.Init(fullName, (int)TypeFlags.GenericParameter, null, baseType, new JsTypeFunction[0], new JsTypeFunction[0],
         new FieldInfo[0], new MethodInfo[0], new ConstructorInfo[0], new PropertyInfo[0],
         new EventInfo[0], null, null);
     return type;
 }