Beispiel #1
0
 public int RegisterType(Type t, bool recursive)
 {
     int num = this.scripter.RegisteredTypes.FindRegisteredTypeId(t);
     if (num <= 0)
     {
         char ch;
         int typeByName;
         string fullName = t.FullName;
         if (fullName == null)
         {
             return 0x10;
         }
         string str2 = CSLite_System.ExtractOwner(fullName, out ch);
         if (str2 == "System")
         {
             typeByName = this.system_namespace_id;
         }
         else if (str2 == "")
         {
             typeByName = this.root_namespace_id;
         }
         else if (ch == '.')
         {
             typeByName = this.RegisterNamespace(str2);
         }
         else
         {
             typeByName = this.LookupTypeByName(str2, false);
             if (typeByName == 0)
             {
                 Type type = Type.GetType(str2);
                 if (type != null)
                 {
                     typeByName = this.RegisterType(type, false);
                 }
             }
         }
         ClassKind ck = ClassKind.Class;
         if (t.IsArray)
         {
             ck = ClassKind.Array;
         }
         else if (t.IsEnum)
         {
             ck = ClassKind.Enum;
         }
         else if (t.IsInterface)
         {
             ck = ClassKind.Interface;
         }
         else if (t.IsValueType)
         {
             ck = ClassKind.Struct;
         }
         else if (t.BaseType == typeof(MulticastDelegate))
         {
             ck = ClassKind.Delegate;
         }
         num = this.AppType(t.Name);
         if (t == typeof(Type))
         {
             this.type_class_id = num;
         }
         else if (t == typeof(object))
         {
             this.object_class_id = num;
         }
         ClassObject m = new ClassObject(this.scripter, num, typeByName, ck);
         m.Modifiers.Add(Modifier.Public);
         m.Modifiers.Add(Modifier.Static);
         if (t.IsSealed)
         {
             m.Modifiers.Add(Modifier.Sealed);
         }
         if (t.IsAbstract)
         {
             m.Modifiers.Add(Modifier.Abstract);
         }
         m.Imported = true;
         m.ImportedType = t;
         this[num].Value = m;
         this[num].Level = typeByName;
         ((ClassObject) this[typeByName].Val).AddMember(m);
         if (t.BaseType == typeof(MulticastDelegate))
         {
             int num3 = this.AppVar();
             FunctionObject obj4 = new FunctionObject(this.scripter, num3, m.Id);
             this[num3].Kind = MemberKind.Method;
             this[num3].Level = m.Id;
             this[num3].Val = obj4;
             int num4 = this.AppLabel();
             this[num4].Level = num3;
             num4 = this.AppVar();
             this[num4].Level = num3;
             num4 = this.AppVar();
             this[num4].Level = num3;
             m.AddMember(obj4);
             m.PatternMethod = obj4;
         }
         this.scripter.RegisteredTypes.RegisterType(t, num);
         if (recursive)
         {
             this.RegisterMemberTypes(t, m);
         }
     }
     return num;
 }
Beispiel #2
0
 public void RegisterMemberTypes(Type t, ClassObject c)
 {
     foreach (ConstructorInfo info in t.GetConstructors())
     {
         foreach (ParameterInfo info2 in info.GetParameters())
         {
             this.RegisterType(info2.ParameterType, true);
         }
     }
     foreach (MethodInfo info3 in t.GetMethods())
     {
         this.RegisterType(info3.ReturnType, false);
         foreach (ParameterInfo info4 in info3.GetParameters())
         {
             this.RegisterType(info4.ParameterType, false);
         }
     }
     foreach (FieldInfo info5 in t.GetFields())
     {
         this.RegisterType(info5.FieldType, false);
     }
     foreach (Type type in t.GetNestedTypes(BindingFlags.Public))
     {
         int id = this.RegisterType(type, true);
         this[id].Level = c.Id;
         c.AddMember(this.scripter.GetClassObject(id));
     }
     foreach (Type type2 in t.GetInterfaces())
     {
         int avalue = this.RegisterType(type2, false);
         c.AncestorIds.Add(avalue);
     }
     if (t.IsEnum)
     {
         Type underlyingType = Enum.GetUnderlyingType(t);
         int num3 = this.RegisterType(underlyingType, false);
         c.UnderlyingType = this.scripter.GetClassObject(num3);
     }
     Type baseType = t.BaseType;
     if ((baseType != null) && (baseType != typeof(object)))
     {
         int num4 = this.RegisterType(baseType, true);
         c.AncestorIds.Add(num4);
     }
 }