Example #1
0
 public typeDescriptor(Type t, string typeName, bool compile = true)
 {
     typeDescriptor.loadEvaluator();
     if (typeDescriptor.language == null)
     {
         typeDescriptor.language = (csharplanguage)jxshell.language.defaultLanguage.create();
     }
     this.typeString = typeName;
     MethodInfo[] array  = t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod);
     MethodInfo[] array2 = array;
     for (int i = 0; i < array2.Length; i++)
     {
         MethodInfo methodInfo = array2[i];
         if (!methodInfo.Name.StartsWith("get_") && !methodInfo.Name.StartsWith("set_"))
         {
             methodDescriptor methodDescriptor = null;
             if (methodInfo.IsGenericMethod)
             {
                 string text = "generic_" + methodInfo.Name;
                 if (!this.instanceMethods.TryGetValue(text, out methodDescriptor))
                 {
                     methodDescriptor = new methodDescriptor();
                     methodDescriptor.isGenericMethod = true;
                     this.instanceMethods[text]       = methodDescriptor;
                     this.methods.Add(methodDescriptor);
                     methodDescriptor.methodOrder = this.methods.Count - 1;
                     methodDescriptor.name        = text;
                 }
             }
             else if (!this.instanceMethods.TryGetValue(methodInfo.Name, out methodDescriptor))
             {
                 methodDescriptor = new methodDescriptor();
                 this.instanceMethods[methodInfo.Name] = methodDescriptor;
                 this.methods.Add(methodDescriptor);
                 methodDescriptor.methodOrder = this.methods.Count - 1;
                 methodDescriptor.name        = methodInfo.Name;
             }
             methodDescriptor.baseMethods.Add(methodInfo);
             methodDescriptor.maxParameterCount = Math.Max(methodDescriptor.maxParameterCount, methodInfo.GetParameters().Length);
             if (methodInfo.IsGenericMethod)
             {
                 methodDescriptor.genericParameterCount = Math.Max(methodDescriptor.genericParameterCount, methodInfo.GetGenericArguments().Length);
             }
         }
     }
     PropertyInfo[] array3 = t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
     PropertyInfo[] array4 = array3;
     for (int j = 0; j < array4.Length; j++)
     {
         PropertyInfo       propertyInfo       = array4[j];
         propertyDescriptor propertyDescriptor = null;
         if (!this.instanceProperties.TryGetValue(propertyInfo.Name, out propertyDescriptor))
         {
             propertyDescriptor = new propertyDescriptor();
             this.instanceProperties[propertyInfo.Name] = propertyDescriptor;
             this.properties.Add(propertyDescriptor);
             propertyDescriptor.propertyOrder = this.properties.Count - 1;
             propertyDescriptor.name          = propertyInfo.Name;
         }
         propertyDescriptor.properties.Add(propertyInfo);
         propertyDescriptor.maxParameterCount = Math.Max(propertyDescriptor.maxParameterCount, propertyInfo.GetIndexParameters().Length);
     }
     FieldInfo[] array5 = t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.SetField);
     FieldInfo[] array6 = array5;
     for (int k = 0; k < array6.Length; k++)
     {
         FieldInfo       fieldInfo       = array6[k];
         fieldDescriptor fieldDescriptor = null;
         if (!this.instanceFields.TryGetValue(fieldInfo.Name, out fieldDescriptor))
         {
             fieldDescriptor = new fieldDescriptor();
             this.instanceFields[fieldInfo.Name] = fieldDescriptor;
             this.fields.Add(fieldDescriptor);
             fieldDescriptor.fieldOrder = this.fields.Count - 1;
             fieldDescriptor.name       = fieldInfo.Name;
         }
         fieldDescriptor.fieldInfo = fieldInfo;
     }
     ConstructorInfo[] constructors = t.GetConstructors();
     ConstructorInfo[] array7       = constructors;
     for (int l = 0; l < array7.Length; l++)
     {
         ConstructorInfo  constructorInfo = array7[l];
         methodDescriptor methodDescriptor2;
         if (this.constructor == null)
         {
             methodDescriptor2 = new methodDescriptor();
             this.constructor  = methodDescriptor2;
             this.methods.Add(methodDescriptor2);
             methodDescriptor2.name        = "construct";
             methodDescriptor2.methodOrder = this.methods.Count - 1;
         }
         else
         {
             methodDescriptor2 = this.constructor;
         }
         methodDescriptor2.baseMethods.Add(constructorInfo);
         methodDescriptor2.maxParameterCount = Math.Max(methodDescriptor2.maxParameterCount, constructorInfo.GetParameters().Length);
     }
     array = t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod);
     MethodInfo[] array8 = array;
     for (int m = 0; m < array8.Length; m++)
     {
         MethodInfo methodInfo2 = array8[m];
         if (!methodInfo2.Name.StartsWith("get_") && !methodInfo2.Name.StartsWith("set_"))
         {
             methodDescriptor methodDescriptor3 = null;
             if (methodInfo2.IsGenericMethod)
             {
                 string text2 = "generic_" + methodInfo2.Name;
                 if (!this.instanceMethods.TryGetValue(text2, out methodDescriptor3))
                 {
                     methodDescriptor3                 = new methodDescriptor();
                     this.staticMethods[text2]         = methodDescriptor3;
                     methodDescriptor3.isGenericMethod = true;
                     this.methods.Add(methodDescriptor3);
                     methodDescriptor3.methodOrder = this.methods.Count - 1;
                     methodDescriptor3.name        = text2;
                 }
             }
             else if (!this.staticMethods.TryGetValue(methodInfo2.Name, out methodDescriptor3))
             {
                 methodDescriptor3 = new methodDescriptor();
                 this.staticMethods[methodInfo2.Name] = methodDescriptor3;
                 this.methods.Add(methodDescriptor3);
                 methodDescriptor3.name        = methodInfo2.Name;
                 methodDescriptor3.methodOrder = this.methods.Count - 1;
             }
             methodDescriptor3.baseMethods.Add(methodInfo2);
             methodDescriptor3.maxParameterCount = Math.Max(methodDescriptor3.maxParameterCount, methodInfo2.GetParameters().Length);
             if (methodInfo2.IsGenericMethod)
             {
                 methodDescriptor3.genericParameterCount = Math.Max(methodDescriptor3.genericParameterCount, methodInfo2.GetGenericArguments().Length);
             }
         }
     }
     array3 = t.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
     PropertyInfo[] array9 = array3;
     for (int n = 0; n < array9.Length; n++)
     {
         PropertyInfo       propertyInfo2       = array9[n];
         propertyDescriptor propertyDescriptor2 = null;
         if (!this.staticProperties.TryGetValue(propertyInfo2.Name, out propertyDescriptor2))
         {
             propertyDescriptor2 = new propertyDescriptor();
             this.staticProperties[propertyInfo2.Name] = propertyDescriptor2;
             this.properties.Add(propertyDescriptor2);
             propertyDescriptor2.propertyOrder = this.properties.Count - 1;
             propertyDescriptor2.name          = propertyInfo2.Name;
         }
         propertyDescriptor2.properties.Add(propertyInfo2);
         propertyDescriptor2.maxParameterCount = Math.Max(propertyDescriptor2.maxParameterCount, propertyInfo2.GetIndexParameters().Length);
     }
     array5 = t.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.SetField);
     FieldInfo[] array10 = array5;
     for (int num = 0; num < array10.Length; num++)
     {
         FieldInfo       fieldInfo2       = array10[num];
         fieldDescriptor fieldDescriptor2 = null;
         if (!this.instanceFields.TryGetValue(fieldInfo2.Name, out fieldDescriptor2))
         {
             fieldDescriptor2 = new fieldDescriptor();
             this.staticFields[fieldInfo2.Name] = fieldDescriptor2;
             this.fields.Add(fieldDescriptor2);
             fieldDescriptor2.fieldOrder = this.fields.Count - 1;
             fieldDescriptor2.name       = fieldInfo2.Name;
         }
         fieldDescriptor2.fieldInfo = fieldInfo2;
     }
     this.type = t;
     typeDescriptor.loadedTypes[t] = this;
     if (compile && typeDescriptor.gencompile)
     {
         this.compile();
     }
 }
Example #2
0
        public void precompile(StringBuilder sb, ref string staticClass, ref string instanceClass)
        {
            sb.AppendLine("namespace jxshell.dotnet4{");
            string text  = "_" + environment.uniqueId();
            string text2 = "_" + environment.uniqueId();

            sb.AppendLine();
            sb.AppendLine("[ComVisible(true)]");
            sb.Append("public class ").Append(text2).Append(" : ");
            if (typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType))
            {
                sb.Append("delegateWrapperStatic{");
            }
            else
            {
                sb.Append("wrapperStatic{");
            }
            sb.AppendLine();
            sb.Append("public ").Append(text2).Append("(Type t, typeDescriptor td):base(t,td){");
            if (this.type.IsEnum)
            {
                sb.Append("__initEnum();");
            }
            sb.Append("}");
            sb.AppendLine();
            sb.Append("public override ").Append("wrapper").Append(" getWrapper(object o){return new ").Append(text).Append("(o,typeD);}");
            sb.AppendLine();
            if (!this.type.IsEnum)
            {
                sb.AppendLine("/* FIELDS */");
                foreach (KeyValuePair <string, fieldDescriptor> current in this.staticFields)
                {
                    sb.Append("public object ").Append(current.Value.name).Append("{");
                    sb.Append("get{");
                    sb.Append("var fielD = typeD.fields[").Append(current.Value.fieldOrder).Append("];");
                    sb.Append("return fielD.getValue(null);");
                    sb.Append("}");
                    sb.AppendLine();
                    sb.Append("set{");
                    sb.Append("var fielD = typeD.fields[").Append(current.Value.fieldOrder).Append("];");
                    sb.Append("fielD.setValue(value, null);");
                    sb.Append("}");
                    sb.AppendLine();
                    sb.AppendLine("}");
                }
            }
            sb.AppendLine("/* MÉTODOS */");
            foreach (KeyValuePair <string, methodDescriptor> current2 in this.staticMethods)
            {
                sb.Append("public object ").Append(current2.Value.name).Append("(");
                StringBuilder stringBuilder   = new StringBuilder();
                bool          isGenericMethod = current2.Value.isGenericMethod;
                if (isGenericMethod)
                {
                    stringBuilder.Append("System.Collections.Generic.List<System.Type> genericArguments=new System.Collections.Generic.List<System.Type>(1);");
                    for (int i = 0; i < current2.Value.genericParameterCount; i++)
                    {
                        if (i > 0)
                        {
                            sb.Append(",");
                        }
                        stringBuilder.Append("if(type").Append(i).Append("!=null){if(type").Append(i);
                        stringBuilder.Append(" is wrapper){genericArguments.Add((System.Type)(((wrapper)type").Append(i).Append(").wrappedObject));}else{");
                        stringBuilder.Append("genericArguments.Add(Manager.lastManager.getTypeOrGenericType(type").Append(i).Append(".ToString()));}").Append("}");
                        sb.Append("[Optional] object ").Append("type").Append(i);
                        stringBuilder.AppendLine();
                    }
                }
                stringBuilder.Append("object[] args = {");
                for (int j = 0; j < current2.Value.maxParameterCount; j++)
                {
                    if (j > 0)
                    {
                        stringBuilder.Append(",");
                    }
                    if (j > 0 || isGenericMethod)
                    {
                        sb.Append(",");
                    }
                    stringBuilder.Append("a").Append(j);
                    sb.Append("[Optional] object ").Append("a").Append(j);
                }
                sb.Append("){");
                stringBuilder.Append("}");
                sb.AppendLine();
                sb.Append(stringBuilder).Append(";");
                sb.AppendLine();
                sb.Append("var m = typeD.methods[").Append(current2.Value.methodOrder).Append("];");
                sb.AppendLine();
                if (isGenericMethod)
                {
                    sb.Append("var method = m.getGenericMethodForParameters(genericArguments.ToArray(), ref args);");
                }
                else
                {
                    sb.Append("var method = m.getMethodForParameters(ref args);");
                }
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.Append("return __process(method.Invoke(null,args));");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
            }
            sb.AppendLine("/* PROPIEDADES  */");
            foreach (KeyValuePair <string, propertyDescriptor> current3 in this.staticProperties)
            {
                sb.Append("public object ");
                if (current3.Value.maxParameterCount > 0)
                {
                    sb.Append("this[");
                }
                else
                {
                    sb.Append(current3.Value.name);
                }
                StringBuilder stringBuilder2 = new StringBuilder();
                if (current3.Value.maxParameterCount > 0)
                {
                    stringBuilder2.Append("object[] args = {");
                    for (int k = 0; k < current3.Value.maxParameterCount; k++)
                    {
                        if (k > 0)
                        {
                            stringBuilder2.Append(",");
                            sb.Append(",");
                        }
                        stringBuilder2.Append("a").Append(k);
                        sb.Append("[Optional] object ").Append("a").Append(k);
                    }
                    sb.Append("]");
                    stringBuilder2.Append("};");
                }
                else
                {
                    stringBuilder2.Append("object[] args = {};");
                }
                sb.Append("{");
                sb.AppendLine();
                sb.AppendLine("get{");
                sb.Append(stringBuilder2);
                sb.AppendLine();
                sb.Append("var m = typeD.properties[").Append(current3.Value.propertyOrder).Append("];");
                sb.AppendLine();
                sb.Append("var method = m.getPropertyForParameters(ref args);");
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.Append("return __process(method.GetValue(null,args));");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
                sb.AppendLine("set{");
                sb.Append(stringBuilder2);
                sb.AppendLine();
                sb.Append("var m = typeD.properties[").Append(current3.Value.propertyOrder).Append("];");
                sb.AppendLine();
                sb.Append("var method = m.getPropertyForParameters(ref args);");
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.AppendLine("if(value is wrapper){value=((wrapper)value).wrappedObject;}");
                sb.Append("method.SetValue(null,value,args);");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
                sb.AppendLine("}");
            }
            if (this.type.IsEnum)
            {
                string[]      names          = Enum.GetNames(this.type);
                StringBuilder stringBuilder3 = new StringBuilder();
                stringBuilder3.Append("Type ty = typeof(").Append(typeDescriptor.getNameForType(this.type)).Append(");");
                stringBuilder3.Append("Array values = global::System.Enum.GetValues(ty);");
                stringBuilder3.AppendLine();
                int      num   = 0;
                string[] array = names;
                for (int l = 0; l < array.Length; l++)
                {
                    string value = array[l];
                    sb.Append("public ").Append(text).Append(" ").Append(value).Append("= new ").Append(text).Append("();").AppendLine();
                    stringBuilder3.Append(value).Append(".wrappedObject = values.GetValue(").Append(num).Append(");");
                    stringBuilder3.AppendLine();
                    stringBuilder3.Append(value).Append(".wrappedType = ty;");
                    stringBuilder3.AppendLine();
                    stringBuilder3.Append(value).Append(".typeD = typeD;");
                    stringBuilder3.AppendLine();
                    num++;
                }
                sb.Append("public void __initEnum(){").AppendLine().Append(stringBuilder3.ToString()).AppendLine().Append("}");
            }
            methodDescriptor methodDescriptor = this.constructor;

            if (methodDescriptor != null)
            {
                if (typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType))
                {
                    sb.Append("public override delegateWrapper getThisWrapper(){");
                    sb.Append("var o = new ").Append(text).Append("();return o;");
                    sb.Append("}");
                }
                else
                {
                    sb.Append("public object ").Append(methodDescriptor.name).Append("(");
                    StringBuilder stringBuilder4 = new StringBuilder();
                    stringBuilder4.Append("object[] args = {");
                    for (int m = 0; m < methodDescriptor.maxParameterCount; m++)
                    {
                        if (m > 0)
                        {
                            stringBuilder4.Append(",");
                            sb.Append(",");
                        }
                        stringBuilder4.Append("a").Append(m);
                        sb.Append("[Optional] object ").Append("a").Append(m);
                    }
                    sb.Append("){");
                    stringBuilder4.Append("}");
                    sb.AppendLine();
                    sb.Append(stringBuilder4).Append(";");
                    sb.AppendLine();
                    sb.Append("var m = typeD.methods[").Append(methodDescriptor.methodOrder).Append("];");
                    sb.AppendLine();
                    sb.Append("var method = m.getConstructorForParameters(ref args);");
                    sb.AppendLine();
                    sb.AppendLine("try{");
                    sb.Append("return getWrapper(method.Invoke(args));");
                    sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                    sb.AppendLine();
                    sb.AppendLine("}");
                }
            }
            sb.AppendLine("}");
            sb.AppendLine();
            sb.AppendLine("[ComVisible(true)]");
            sb.Append("public class ").Append(text).Append(" : ");
            if (this.type.IsEnum)
            {
                sb.Append("enumW");
            }
            else if (typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType))
            {
                sb.Append("delegateW");
            }
            else
            {
                sb.Append("w");
            }
            sb.Append("rapper{").AppendLine();
            sb.Append("public ").Append(text).Append("(object o, typeDescriptor td):base(o,td){}");
            sb.Append("public ").Append(text).Append("():base(){}");
            sb.AppendLine();
            if (typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType))
            {
            }
            sb.AppendLine();
            sb.AppendLine("/* FIELDS */");
            foreach (KeyValuePair <string, fieldDescriptor> current4 in this.instanceFields)
            {
                sb.Append("public object ").Append(current4.Value.name).Append("{");
                sb.Append("get{");
                sb.Append("var fielD = typeD.fields[").Append(current4.Value.fieldOrder).Append("];");
                sb.Append("return fielD.getValue(wrappedObject);");
                sb.Append("}");
                sb.AppendLine();
                sb.Append("set{");
                sb.Append("var fielD = typeD.fields[").Append(current4.Value.fieldOrder).Append("];");
                sb.Append("fielD.setValue(value, wrappedObject);");
                sb.Append("}");
                sb.AppendLine();
                sb.AppendLine("}");
            }
            sb.AppendLine("/* MÉTODOS */");
            foreach (KeyValuePair <string, methodDescriptor> current5 in this.instanceMethods)
            {
                if (typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType) && current5.Value.name == "Invoke")
                {
                    sb.Append("public object call(");
                    StringBuilder stringBuilder5 = new StringBuilder();
                    StringBuilder stringBuilder6 = new StringBuilder();
                    stringBuilder5.Append("");
                    for (int n = 0; n < current5.Value.maxParameterCount; n++)
                    {
                        if (n > 0)
                        {
                            stringBuilder5.Append(",");
                            stringBuilder6.Append(",");
                            sb.Append(",");
                        }
                        stringBuilder6.Append("wrapper.getFromObject(a").Append(n).Append(")");
                        stringBuilder5.Append("a").Append(n);
                        sb.Append("[Optional] object ").Append("a").Append(n);
                    }
                    sb.Append("){");
                    sb.AppendLine();
                    int maxParameterCount = current5.Value.maxParameterCount;
                    sb.Append("invokerparam").Append(maxParameterCount).Append(" invoker = new invokerparam").Append(maxParameterCount).Append("(__internalMethod);");
                    sb.Append("object o =null;");
                    MethodInfo methodInfo = (MethodInfo)current5.Value.baseMethods[0];
                    if (methodInfo.ReturnType == typeof(void))
                    {
                        sb.Append("invoker.invokeasVoid");
                    }
                    else
                    {
                        sb.Append("o=invoker.invoke");
                    }
                    sb.Append("(__internalTarget");
                    if (current5.Value.maxParameterCount > 0)
                    {
                        sb.Append(",");
                    }
                    sb.Append(stringBuilder5.ToString()).Append(");");
                    sb.AppendLine();
                    sb.AppendLine("return o;}");
                    sb.Append("public ");
                    if (methodInfo.ReturnType == typeof(void))
                    {
                        sb.Append("void ");
                    }
                    else
                    {
                        sb.Append(typeDescriptor.getNameForType(methodInfo.ReturnType));
                    }
                    sb.Append(" __internalInvoke(");
                    ParameterInfo[] parameters = methodInfo.GetParameters();
                    for (int num2 = 0; num2 < parameters.Length; num2++)
                    {
                        ParameterInfo parameterInfo = parameters[num2];
                        if (num2 > 0)
                        {
                            sb.Append(",");
                        }
                        string value2;
                        if (parameterInfo.ParameterType.IsPointer)
                        {
                            value2 = "object";
                        }
                        else
                        {
                            value2 = typeDescriptor.getNameForType(parameterInfo.ParameterType);
                        }
                        sb.Append(value2).Append(" a").Append(num2);
                    }
                    sb.Append("){");
                    sb.AppendLine();
                    if (methodInfo.ReturnType == typeof(void))
                    {
                        sb.Append("call(").Append(stringBuilder6.ToString()).Append(");");
                    }
                    else
                    {
                        sb.Append("object o= ");
                        sb.Append("call(").Append(stringBuilder6.ToString()).Append(");");
                        sb.AppendLine();
                        sb.Append("if(o is wrapper){o = ((wrapper)o).wrappedObject;}");
                        sb.AppendLine();
                        sb.Append("return (").Append(typeDescriptor.getNameForType(methodInfo.ReturnType)).Append(")o;");
                        sb.AppendLine();
                    }
                    sb.Append("}\n");
                }
                else
                {
                    sb.Append("public object ").Append(current5.Value.name).Append("(");
                    StringBuilder stringBuilder7   = new StringBuilder();
                    bool          isGenericMethod2 = current5.Value.isGenericMethod;
                    if (isGenericMethod2)
                    {
                        stringBuilder7.Append("System.Collections.Generic.List<System.Type> genericArguments=new System.Collections.Generic.List<System.Type>(1);");
                        for (int num3 = 0; num3 < current5.Value.genericParameterCount; num3++)
                        {
                            if (num3 > 0)
                            {
                                sb.Append(",");
                            }
                            stringBuilder7.Append("if(type").Append(num3).Append("!=null){if(type").Append(num3);
                            stringBuilder7.Append(" is wrapper){genericArguments.Add((System.Type)(((wrapper)type").Append(num3).Append(").wrappedObject));}else{");
                            stringBuilder7.Append("genericArguments.Add(Manager.lastManager.getTypeOrGenericType(type").Append(num3).Append(".ToString()));}").Append("}");
                            sb.Append("[Optional] object ").Append("type").Append(num3);
                            stringBuilder7.AppendLine();
                        }
                    }
                    stringBuilder7.Append("object[] args = {");
                    for (int num4 = 0; num4 < current5.Value.maxParameterCount; num4++)
                    {
                        if (num4 > 0)
                        {
                            stringBuilder7.Append(",");
                        }
                        if (num4 > 0 || isGenericMethod2)
                        {
                            sb.Append(",");
                        }
                        stringBuilder7.Append("a").Append(num4);
                        sb.Append("[Optional] object ").Append("a").Append(num4);
                    }
                    sb.Append("){");
                    stringBuilder7.Append("}");
                    sb.AppendLine();
                    sb.Append(stringBuilder7).Append(";");
                    sb.AppendLine();
                    sb.Append("var m = typeD.methods[").Append(current5.Value.methodOrder).Append("];");
                    sb.AppendLine();
                    sb.AppendLine("try{");
                    sb.Append("var method = m.getMethodForParameters(ref args);");
                    sb.AppendLine();
                    sb.Append("return __process(method.Invoke(wrappedObject,args));");
                    sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                    sb.AppendLine();
                    sb.AppendLine("}");
                }
            }
            sb.AppendLine("/* PROPIEDADES  */");
            foreach (KeyValuePair <string, propertyDescriptor> current6 in this.instanceProperties)
            {
                sb.Append("public object ");
                if (current6.Value.maxParameterCount > 0)
                {
                    sb.Append("this[");
                }
                else
                {
                    sb.Append(current6.Value.name);
                }
                StringBuilder stringBuilder8 = new StringBuilder();
                if (current6.Value.maxParameterCount > 0)
                {
                    stringBuilder8.Append("object[] args = {");
                    for (int num5 = 0; num5 < current6.Value.maxParameterCount; num5++)
                    {
                        if (num5 > 0)
                        {
                            stringBuilder8.Append(",");
                            sb.Append(",");
                        }
                        stringBuilder8.Append("a").Append(num5);
                        sb.Append("[Optional] object ").Append("a").Append(num5);
                    }
                    sb.Append("]");
                    stringBuilder8.Append("};");
                }
                else
                {
                    stringBuilder8.Append("object[] args = {};");
                }
                sb.Append("{");
                sb.AppendLine();
                sb.AppendLine("get{");
                sb.Append(stringBuilder8);
                sb.AppendLine();
                sb.Append("var m = typeD.properties[").Append(current6.Value.propertyOrder).Append("];");
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.Append("var method = m.getPropertyForParameters(ref args);");
                sb.AppendLine();
                sb.Append("object o= method.GetValue(wrappedObject,args);");
                sb.AppendLine("return __process(o);");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
                sb.AppendLine("set{");
                sb.Append(stringBuilder8);
                sb.AppendLine();
                sb.Append("var m = typeD.properties[").Append(current6.Value.propertyOrder).Append("];");
                sb.AppendLine();
                sb.Append("var method = m.getPropertyForParameters(ref args);");
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.AppendLine("if(value is wrapper){value=((wrapper)value).wrappedObject;}");
                sb.Append("method.SetValue(wrappedObject,value,args);");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
                sb.AppendLine("}");
            }
            sb.AppendLine("}}");
            staticClass   = text2;
            instanceClass = text;
        }
Example #3
0
        public MethodBase getStaticMethodForParameters(string method, ref object[] parameters)
        {
            methodDescriptor methodDescriptor = this.staticMethods[method];

            return(methodDescriptor.getMethodForParameters(ref parameters, null));
        }
Example #4
0
 public typeDescriptor(Type t, string typeName, bool compile = true)
 {
     jxshell.dotnet4.methodDescriptor methodDescriptor;
     typeDescriptor.loadEvaluator();
     if (typeDescriptor.language == null)
     {
         typeDescriptor.language = (csharplanguage)jxshell.language.defaultLanguage.create();
     }
     this.typeString = typeName;
     MethodInfo[] methods = t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod);
     for (int i = 0; i < (int)methods.Length; i++)
     {
         MethodInfo methodInfo = methods[i];
         if (!methodInfo.Name.StartsWith("get_") && !methodInfo.Name.StartsWith("set_"))
         {
             jxshell.dotnet4.methodDescriptor value = null;
             if (methodInfo.IsGenericMethod)
             {
                 string text = string.Concat("generic_", methodInfo.Name);
                 if (!this.instanceMethods.TryGetValue(text, out value))
                 {
                     value = new jxshell.dotnet4.methodDescriptor()
                     {
                         isGenericMethod = true
                     };
                     this.instanceMethods[text] = value;
                     this.methods.Add(value);
                     value.methodOrder = this.methods.Count - 1;
                     value.name        = text;
                 }
             }
             else if (!this.instanceMethods.TryGetValue(methodInfo.Name, out value))
             {
                 value = new jxshell.dotnet4.methodDescriptor();
                 this.instanceMethods[methodInfo.Name] = value;
                 this.methods.Add(value);
                 value.methodOrder = this.methods.Count - 1;
                 value.name        = methodInfo.Name;
             }
             value.baseMethods.Add(methodInfo);
             value.maxParameterCount = Math.Max(value.maxParameterCount, (int)methodInfo.GetParameters().Length);
             if (methodInfo.IsGenericMethod)
             {
                 value.genericParameterCount = Math.Max(value.genericParameterCount, (int)methodInfo.GetGenericArguments().Length);
             }
         }
     }
     PropertyInfo[] properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
     for (int j = 0; j < (int)properties.Length; j++)
     {
         PropertyInfo       propertyInfo = properties[j];
         propertyDescriptor value2       = null;
         if (!this.instanceProperties.TryGetValue(propertyInfo.Name, out value2))
         {
             value2 = new propertyDescriptor();
             this.instanceProperties[propertyInfo.Name] = value2;
             this.properties.Add(value2);
             value2.propertyOrder = this.properties.Count - 1;
             value2.name          = propertyInfo.Name;
         }
         value2.properties.Add(propertyInfo);
         value2.maxParameterCount = Math.Max(value2.maxParameterCount, (int)propertyInfo.GetIndexParameters().Length);
     }
     FieldInfo[] fields = t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.SetField);
     for (int k = 0; k < (int)fields.Length; k++)
     {
         FieldInfo       fieldInfo = fields[k];
         fieldDescriptor value3    = null;
         if (!this.instanceFields.TryGetValue(fieldInfo.Name, out value3))
         {
             value3 = new fieldDescriptor();
             this.instanceFields[fieldInfo.Name] = value3;
             this.fields.Add(value3);
             value3.fieldOrder = this.fields.Count - 1;
             value3.name       = fieldInfo.Name;
         }
         value3.fieldInfo = fieldInfo;
     }
     ConstructorInfo[] constructors = t.GetConstructors();
     for (int l = 0; l < (int)constructors.Length; l++)
     {
         ConstructorInfo constructorInfo = constructors[l];
         if (this.constructor != null)
         {
             methodDescriptor = this.constructor;
         }
         else
         {
             jxshell.dotnet4.methodDescriptor _methodDescriptor  = new jxshell.dotnet4.methodDescriptor();
             jxshell.dotnet4.methodDescriptor _methodDescriptor1 = _methodDescriptor;
             this.constructor = _methodDescriptor;
             methodDescriptor = _methodDescriptor1;
             this.methods.Add(methodDescriptor);
             methodDescriptor.name        = "construct";
             methodDescriptor.methodOrder = this.methods.Count - 1;
         }
         methodDescriptor.baseMethods.Add(constructorInfo);
         methodDescriptor.maxParameterCount = Math.Max(methodDescriptor.maxParameterCount, (int)constructorInfo.GetParameters().Length);
     }
     MethodInfo[] methodInfoArray = t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod);
     for (int m = 0; m < (int)methodInfoArray.Length; m++)
     {
         MethodInfo methodInfo2 = methodInfoArray[m];
         if (!methodInfo2.Name.StartsWith("get_") && !methodInfo2.Name.StartsWith("set_"))
         {
             jxshell.dotnet4.methodDescriptor value4 = null;
             if (methodInfo2.IsGenericMethod)
             {
                 string text2 = string.Concat("generic_", methodInfo2.Name);
                 if (!this.instanceMethods.TryGetValue(text2, out value4))
                 {
                     value4 = new jxshell.dotnet4.methodDescriptor();
                     this.staticMethods[text2] = value4;
                     value4.isGenericMethod    = true;
                     this.methods.Add(value4);
                     value4.methodOrder = this.methods.Count - 1;
                     value4.name        = text2;
                 }
             }
             else if (!this.staticMethods.TryGetValue(methodInfo2.Name, out value4))
             {
                 value4 = new jxshell.dotnet4.methodDescriptor();
                 this.staticMethods[methodInfo2.Name] = value4;
                 this.methods.Add(value4);
                 value4.name        = methodInfo2.Name;
                 value4.methodOrder = this.methods.Count - 1;
             }
             value4.baseMethods.Add(methodInfo2);
             value4.maxParameterCount = Math.Max(value4.maxParameterCount, (int)methodInfo2.GetParameters().Length);
             if (methodInfo2.IsGenericMethod)
             {
                 value4.genericParameterCount = Math.Max(value4.genericParameterCount, (int)methodInfo2.GetGenericArguments().Length);
             }
         }
     }
     PropertyInfo[] propertyInfoArray = t.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
     for (int n = 0; n < (int)propertyInfoArray.Length; n++)
     {
         PropertyInfo       propertyInfo2 = propertyInfoArray[n];
         propertyDescriptor value5        = null;
         if (!this.staticProperties.TryGetValue(propertyInfo2.Name, out value5))
         {
             value5 = new propertyDescriptor();
             this.staticProperties[propertyInfo2.Name] = value5;
             this.properties.Add(value5);
             value5.propertyOrder = this.properties.Count - 1;
             value5.name          = propertyInfo2.Name;
         }
         value5.properties.Add(propertyInfo2);
         value5.maxParameterCount = Math.Max(value5.maxParameterCount, (int)propertyInfo2.GetIndexParameters().Length);
     }
     FieldInfo[] fieldInfoArray = t.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.SetField);
     for (int o = 0; o < (int)fieldInfoArray.Length; o++)
     {
         FieldInfo       fieldInfo2 = fieldInfoArray[o];
         fieldDescriptor value6     = null;
         if (!this.instanceFields.TryGetValue(fieldInfo2.Name, out value6))
         {
             value6 = new fieldDescriptor();
             this.staticFields[fieldInfo2.Name] = value6;
             this.fields.Add(value6);
             value6.fieldOrder = this.fields.Count - 1;
             value6.name       = fieldInfo2.Name;
         }
         value6.fieldInfo = fieldInfo2;
     }
     this.type = t;
     typeDescriptor.loadedTypes[t] = this;
     if (compile && typeDescriptor.gencompile)
     {
         this.compile();
     }
 }
        public typeDescriptor(Type t, string typeName, bool compile = true)
        {
            methodDescriptor count;

            typeDescriptor.loadEvaluator();
            if (typeDescriptor.language == null)
            {
                typeDescriptor.language = (csharplanguage)jxshell.language.defaultLanguage.create();
            }
            this.typeString = typeName;
            MethodInfo[] methods = t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod);
            for (int i = 0; i < (int)methods.Length; i++)
            {
                MethodInfo methodInfo = methods[i];
                if ((methodInfo.Name.StartsWith("get_") ? false : !methodInfo.Name.StartsWith("set_")))
                {
                    methodDescriptor _methodDescriptor = null;
                    if (methodInfo.IsGenericMethod)
                    {
                        string str = string.Concat("generic_", methodInfo.Name);
                        if (!this.instanceMethods.TryGetValue(str, out _methodDescriptor))
                        {
                            _methodDescriptor = new methodDescriptor()
                            {
                                isGenericMethod = true
                            };
                            this.instanceMethods[str] = _methodDescriptor;
                            this.methods.Add(_methodDescriptor);
                            _methodDescriptor.methodOrder = this.methods.Count - 1;
                            _methodDescriptor.name        = str;
                        }
                    }
                    else if (!this.instanceMethods.TryGetValue(methodInfo.Name, out _methodDescriptor))
                    {
                        _methodDescriptor = new methodDescriptor();
                        this.instanceMethods[methodInfo.Name] = _methodDescriptor;
                        this.methods.Add(_methodDescriptor);
                        _methodDescriptor.methodOrder = this.methods.Count - 1;
                        _methodDescriptor.name        = methodInfo.Name;
                    }
                    _methodDescriptor.baseMethods.Add(methodInfo);
                    _methodDescriptor.maxParameterCount = Math.Max(_methodDescriptor.maxParameterCount, (int)methodInfo.GetParameters().Length);
                    if (methodInfo.IsGenericMethod)
                    {
                        _methodDescriptor.genericParameterCount = Math.Max(_methodDescriptor.genericParameterCount, (int)methodInfo.GetGenericArguments().Length);
                    }
                }
            }
            PropertyInfo[] properties = t.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy);
            for (int j = 0; j < (int)properties.Length; j++)
            {
                PropertyInfo       propertyInfo        = properties[j];
                propertyDescriptor _propertyDescriptor = null;
                if (!this.instanceProperties.TryGetValue(propertyInfo.Name, out _propertyDescriptor))
                {
                    _propertyDescriptor = new propertyDescriptor();
                    this.instanceProperties[propertyInfo.Name] = _propertyDescriptor;
                    this.properties.Add(_propertyDescriptor);
                    _propertyDescriptor.propertyOrder = this.properties.Count - 1;
                    _propertyDescriptor.name          = propertyInfo.Name;
                }
                _propertyDescriptor.properties.Add(propertyInfo);
                _propertyDescriptor.maxParameterCount = Math.Max(_propertyDescriptor.maxParameterCount, (int)propertyInfo.GetIndexParameters().Length);
            }
            FieldInfo[] fields = t.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.SetField);
            for (int k = 0; k < (int)fields.Length; k++)
            {
                FieldInfo       fieldInfo        = fields[k];
                fieldDescriptor _fieldDescriptor = null;
                if (!this.instanceFields.TryGetValue(fieldInfo.Name, out _fieldDescriptor))
                {
                    _fieldDescriptor = new fieldDescriptor();
                    this.instanceFields[fieldInfo.Name] = _fieldDescriptor;
                    this.fields.Add(_fieldDescriptor);
                    _fieldDescriptor.fieldOrder = this.fields.Count - 1;
                    _fieldDescriptor.name       = fieldInfo.Name;
                }
                _fieldDescriptor.fieldInfo = fieldInfo;
            }
            ConstructorInfo[] constructors = t.GetConstructors();
            for (int l = 0; l < (int)constructors.Length; l++)
            {
                ConstructorInfo constructorInfo = constructors[l];
                if (this.constructor == null)
                {
                    methodDescriptor _methodDescriptor1 = new methodDescriptor();
                    methodDescriptor _methodDescriptor2 = _methodDescriptor1;
                    this.constructor = _methodDescriptor1;
                    count            = _methodDescriptor2;
                    this.methods.Add(count);
                    count.name        = "construct";
                    count.methodOrder = this.methods.Count - 1;
                }
                else
                {
                    count = this.constructor;
                }
                count.baseMethods.Add(constructorInfo);
                count.maxParameterCount = Math.Max(count.maxParameterCount, (int)constructorInfo.GetParameters().Length);
            }
            MethodInfo[] methodInfoArray = t.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.InvokeMethod);
            for (int m = 0; m < (int)methodInfoArray.Length; m++)
            {
                MethodInfo methodInfo1 = methodInfoArray[m];
                if ((methodInfo1.Name.StartsWith("get_") ? false : !methodInfo1.Name.StartsWith("set_")))
                {
                    methodDescriptor name = null;
                    if (methodInfo1.IsGenericMethod)
                    {
                        string str1 = string.Concat("generic_", methodInfo1.Name);
                        if (!this.instanceMethods.TryGetValue(str1, out name))
                        {
                            name = new methodDescriptor();
                            this.staticMethods[str1] = name;
                            name.isGenericMethod     = true;
                            this.methods.Add(name);
                            name.methodOrder = this.methods.Count - 1;
                            name.name        = str1;
                        }
                    }
                    else if (!this.staticMethods.TryGetValue(methodInfo1.Name, out name))
                    {
                        name = new methodDescriptor();
                        this.staticMethods[methodInfo1.Name] = name;
                        this.methods.Add(name);
                        name.name        = methodInfo1.Name;
                        name.methodOrder = this.methods.Count - 1;
                    }
                    name.baseMethods.Add(methodInfo1);
                    name.maxParameterCount = Math.Max(name.maxParameterCount, (int)methodInfo1.GetParameters().Length);
                    if (methodInfo1.IsGenericMethod)
                    {
                        name.genericParameterCount = Math.Max(name.genericParameterCount, (int)methodInfo1.GetGenericArguments().Length);
                    }
                }
            }
            PropertyInfo[] propertyInfoArray = t.GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
            for (int n = 0; n < (int)propertyInfoArray.Length; n++)
            {
                PropertyInfo       propertyInfo1        = propertyInfoArray[n];
                propertyDescriptor _propertyDescriptor1 = null;
                if (!this.staticProperties.TryGetValue(propertyInfo1.Name, out _propertyDescriptor1))
                {
                    _propertyDescriptor1 = new propertyDescriptor();
                    this.staticProperties[propertyInfo1.Name] = _propertyDescriptor1;
                    this.properties.Add(_propertyDescriptor1);
                    _propertyDescriptor1.propertyOrder = this.properties.Count - 1;
                    _propertyDescriptor1.name          = propertyInfo1.Name;
                }
                _propertyDescriptor1.properties.Add(propertyInfo1);
                _propertyDescriptor1.maxParameterCount = Math.Max(_propertyDescriptor1.maxParameterCount, (int)propertyInfo1.GetIndexParameters().Length);
            }
            FieldInfo[] fieldInfoArray = t.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.GetField | BindingFlags.SetField);
            for (int o = 0; o < (int)fieldInfoArray.Length; o++)
            {
                FieldInfo       fieldInfo1        = fieldInfoArray[o];
                fieldDescriptor _fieldDescriptor1 = null;
                if (!this.instanceFields.TryGetValue(fieldInfo1.Name, out _fieldDescriptor1))
                {
                    _fieldDescriptor1 = new fieldDescriptor();
                    this.staticFields[fieldInfo1.Name] = _fieldDescriptor1;
                    this.fields.Add(_fieldDescriptor1);
                    _fieldDescriptor1.fieldOrder = this.fields.Count - 1;
                    _fieldDescriptor1.name       = fieldInfo1.Name;
                }
                _fieldDescriptor1.fieldInfo = fieldInfo1;
            }
            this.type = t;
            typeDescriptor.loadedTypes[t] = this;
            if ((!compile ? false : typeDescriptor.gencompile))
            {
                this.compile();
            }
        }
        public void precompile(StringBuilder sb, ref string staticClass, ref string instanceClass)
        {
            sb.AppendLine("namespace jxshell.dotnet4{");


            //string str = string.Concat("_", environment.uniqueId());
            //string str1 = string.Concat("_", environment.uniqueId());
            string str  = "C" + GetSHA1(type.AssemblyQualifiedName);
            string str1 = "C" + GetSHA1(type.AssemblyQualifiedName) + "_static";

            sb.AppendLine();
            sb.AppendLine("[ComVisible(true)]");
            sb.Append("public class ").Append(str1).Append(" : ");
            if (typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType))
            {
                sb.Append("delegateWrapperStatic{");
            }
            else
            {
                sb.Append("wrapperStatic{");
            }
            sb.AppendLine();
            sb.Append("public ").Append(str1).Append("(Type t, typeDescriptor td):base(t,td){");
            if (this.type.IsEnum)
            {
                sb.Append("__initEnum();");
            }
            sb.Append("}");
            sb.AppendLine();
            sb.AppendLine("static invoker __invoker= new invoker();");
            sb.Append("public override ").Append("wrapper").Append(" getWrapper(object o){return new ").Append(str).Append("(o,typeD);}");
            sb.AppendLine();
            if (!this.type.IsEnum)
            {
                sb.AppendLine("/* FIELDS */");
                foreach (KeyValuePair <string, fieldDescriptor> staticField in this.staticFields)
                {
                    sb.Append("public object ").Append(staticField.Value.name).Append("{");
                    sb.Append("get{");
                    sb.Append("var fielD = typeD.fields[").Append(staticField.Value.fieldOrder).Append("];");
                    sb.Append("return fielD.getValue(null);");
                    sb.Append("}");
                    sb.AppendLine();
                    sb.Append("set{");
                    sb.Append("var fielD = typeD.fields[").Append(staticField.Value.fieldOrder).Append("];");
                    sb.Append("fielD.setValue(value, null);");
                    sb.Append("}");
                    sb.AppendLine();
                    sb.AppendLine("}");
                }
            }
            sb.AppendLine("/* MÉTODOS */");
            foreach (KeyValuePair <string, methodDescriptor> staticMethod in this.staticMethods)
            {
                sb.Append("public object ").Append(staticMethod.Value.name).Append("(");
                StringBuilder stringBuilder = new StringBuilder();
                bool          value         = staticMethod.Value.isGenericMethod;
                if (value)
                {
                    stringBuilder.Append("System.Collections.Generic.List<System.Type> genericArguments=new System.Collections.Generic.List<System.Type>(1);");
                    for (int i = 0; i < staticMethod.Value.genericParameterCount; i++)
                    {
                        if (i > 0)
                        {
                            sb.Append(",");
                        }
                        stringBuilder.Append("if(type").Append(i).Append("!=null){if(type").Append(i);
                        stringBuilder.Append(" is wrapper){genericArguments.Add((System.Type)(((wrapper)type").Append(i).Append(").wrappedObject));}else{");
                        stringBuilder.Append("genericArguments.Add(Manager.lastManager.getTypeOrGenericType(type").Append(i).Append(".ToString()));}").Append("}");
                        sb.Append("[Optional] object ").Append("type").Append(i);
                        stringBuilder.AppendLine();
                    }
                }
                stringBuilder.Append("object[] args = {");
                for (int j = 0; j < staticMethod.Value.maxParameterCount; j++)
                {
                    if (j > 0)
                    {
                        stringBuilder.Append(",");
                    }
                    if (j > 0 | value)
                    {
                        sb.Append(",");
                    }
                    stringBuilder.Append("a").Append(j);
                    sb.Append("[Optional] object ").Append("a").Append(j);
                }
                sb.Append("){");
                stringBuilder.Append("}");
                sb.AppendLine();
                sb.Append(stringBuilder).Append(";");
                sb.AppendLine();
                sb.Append("var m = typeD.methods[").Append(staticMethod.Value.methodOrder).Append("];");
                sb.AppendLine();
                if (value)
                {
                    sb.Append("var method = m.getGenericMethodForParameters(genericArguments.ToArray(), ref args);");
                }
                else
                {
                    sb.Append("var method = m.getMethodForParameters(ref args);");
                }
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.AppendLine("return __process(method.Invoke(null,args));");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
            }
            sb.AppendLine("/* PROPIEDADES  */");
            foreach (KeyValuePair <string, propertyDescriptor> staticProperty in this.staticProperties)
            {
                sb.Append("public object ");
                if (staticProperty.Value.maxParameterCount > 0)
                {
                    sb.Append("this[");
                }
                else
                {
                    sb.Append(staticProperty.Value.name);
                }
                StringBuilder stringBuilder1 = new StringBuilder();
                if (staticProperty.Value.maxParameterCount > 0)
                {
                    stringBuilder1.Append("object[] args = {");
                    for (int k = 0; k < staticProperty.Value.maxParameterCount; k++)
                    {
                        if (k > 0)
                        {
                            stringBuilder1.Append(",");
                            sb.Append(",");
                        }
                        stringBuilder1.Append("a").Append(k);
                        sb.Append("[Optional] object ").Append("a").Append(k);
                    }
                    sb.Append("]");
                    stringBuilder1.Append("};");
                }
                else
                {
                    stringBuilder1.Append("object[] args = {};");
                }
                sb.Append("{");
                sb.AppendLine();
                sb.AppendLine("get{");
                sb.Append(stringBuilder1);
                sb.AppendLine();
                sb.Append("var m = typeD.properties[").Append(staticProperty.Value.propertyOrder).Append("];");
                sb.AppendLine();
                sb.Append("var method = m.getPropertyForParameters(ref args);");
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.Append("return __process(method.GetValue(null,args));");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
                sb.AppendLine("set{");
                sb.Append(stringBuilder1);
                sb.AppendLine();
                sb.Append("var m = typeD.properties[").Append(staticProperty.Value.propertyOrder).Append("];");
                sb.AppendLine();
                sb.Append("var method = m.getPropertyForParameters(ref args);");
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.AppendLine("if(value is wrapper){value=((wrapper)value).wrappedObject;}");
                sb.Append("method.SetValue(null,value,args);");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
                sb.AppendLine("}");
            }
            if (this.type.IsEnum)
            {
                string[]      names          = Enum.GetNames(this.type);
                StringBuilder stringBuilder2 = new StringBuilder();
                stringBuilder2.Append("Type ty = typeof(").Append(typeDescriptor.getNameForType(this.type)).Append(");");
                stringBuilder2.Append("Array values = global::System.Enum.GetValues(ty);");
                stringBuilder2.AppendLine();
                int      num       = 0;
                string[] strArrays = names;
                for (int l = 0; l < (int)strArrays.Length; l++)
                {
                    string str2 = strArrays[l];
                    sb.Append("public ").Append(str).Append(" ").Append(str2).Append("= new ").Append(str).Append("();").AppendLine();
                    stringBuilder2.Append(str2).Append(".wrappedObject = values.GetValue(").Append(num).Append(");");
                    stringBuilder2.AppendLine();
                    stringBuilder2.Append(str2).Append(".wrappedType = ty;");
                    stringBuilder2.AppendLine();
                    stringBuilder2.Append(str2).Append(".typeD = typeD;");
                    stringBuilder2.AppendLine();
                    num++;
                }
                sb.Append("public void __initEnum(){").AppendLine().Append(stringBuilder2.ToString()).AppendLine().Append("}");
            }
            methodDescriptor _methodDescriptor = this.constructor;

            if (_methodDescriptor != null)
            {
                if (typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType))
                {
                    sb.Append("public override delegateWrapper getThisWrapper(){");
                    sb.Append("var o = new ").Append(str).Append("();return o;");
                    sb.Append("}");
                }
                else
                {
                    sb.Append("public object ").Append(_methodDescriptor.name).Append("(");
                    StringBuilder stringBuilder3 = new StringBuilder();
                    stringBuilder3.Append("object[] args = {");
                    for (int m = 0; m < _methodDescriptor.maxParameterCount; m++)
                    {
                        if (m > 0)
                        {
                            stringBuilder3.Append(",");
                            sb.Append(",");
                        }
                        stringBuilder3.Append("a").Append(m);
                        sb.Append("[Optional] object ").Append("a").Append(m);
                    }
                    sb.Append("){");
                    stringBuilder3.Append("}");
                    sb.AppendLine();
                    sb.Append(stringBuilder3).Append(";");
                    sb.AppendLine();
                    sb.Append("var m = typeD.methods[").Append(_methodDescriptor.methodOrder).Append("];");
                    sb.AppendLine();
                    sb.Append("var method = m.getConstructorForParameters(ref args);");
                    sb.AppendLine();
                    sb.AppendLine("try{");
                    sb.Append("return getWrapper(method.Invoke(args));");
                    sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                    sb.AppendLine();
                    sb.AppendLine("}");
                }
            }
            sb.AppendLine("}");
            sb.AppendLine();
            sb.AppendLine("[ComVisible(true)]");
            sb.Append("public class ").Append(str).Append(" : ");
            if (this.type.IsEnum)
            {
                sb.Append("enumW");
            }
            else if (typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType))
            {
                sb.Append("delegateW");
            }
            else
            {
                sb.Append("w");
            }
            sb.Append("rapper{").AppendLine();
            sb.Append("public ").Append(str).Append("(object o, typeDescriptor td):base(o,td){}");
            sb.Append("public ").Append(str).Append("():base(){}");
            sb.AppendLine();
            typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType);
            sb.AppendLine("static jxshell.dotnet4.invoker __invoker= new invoker();");
            sb.AppendLine("/* FIELDS */");
            foreach (KeyValuePair <string, fieldDescriptor> instanceField in this.instanceFields)
            {
                sb.Append("public object ").Append(instanceField.Value.name).Append("{");
                sb.Append("get{");
                sb.Append("var fielD = typeD.fields[").Append(instanceField.Value.fieldOrder).Append("];");
                sb.Append("return fielD.getValue(wrappedObject);");
                sb.Append("}");
                sb.AppendLine();
                sb.Append("set{");
                sb.Append("var fielD = typeD.fields[").Append(instanceField.Value.fieldOrder).Append("];");
                sb.Append("fielD.setValue(value, wrappedObject);");
                sb.Append("}");
                sb.AppendLine();
                sb.AppendLine("}");
            }
            sb.AppendLine("/* MÉTODOS */");
            foreach (KeyValuePair <string, methodDescriptor> instanceMethod in this.instanceMethods)
            {
                if ((!typeof(MulticastDelegate).IsAssignableFrom(this.type.BaseType) ? false : instanceMethod.Value.name == "Invoke"))
                {
                    sb.Append("public object call(");
                    StringBuilder stringBuilder4 = new StringBuilder();
                    StringBuilder stringBuilder5 = new StringBuilder();
                    stringBuilder4.Append("");
                    for (int n = 0; n < instanceMethod.Value.maxParameterCount; n++)
                    {
                        if (n > 0)
                        {
                            stringBuilder4.Append(",");
                            stringBuilder5.Append(",");
                            sb.Append(",");
                        }
                        stringBuilder5.Append("wrapper.getFromObject(a").Append(n).Append(")");
                        stringBuilder4.Append("a").Append(n);
                        sb.Append("[Optional] object ").Append("a").Append(n);
                    }
                    sb.Append("){");
                    sb.AppendLine();
                    int value1 = instanceMethod.Value.maxParameterCount;
                    sb.AppendLine("if(disposed) return null;");
                    sb.Append("invokerparam").Append(value1).Append(" invoker = new invokerparam").Append(value1).Append("(__internalMethod);");
                    sb.Append("object o =null;");
                    MethodInfo item = (MethodInfo)instanceMethod.Value.baseMethods[0];
                    if (item.ReturnType == typeof(void))
                    {
                        sb.Append("invoker.invokeasVoid");
                    }
                    else
                    {
                        sb.Append("o=invoker.invoke");
                    }
                    sb.Append("(__internalTarget");
                    if (instanceMethod.Value.maxParameterCount > 0)
                    {
                        sb.Append(",");
                    }
                    sb.Append(stringBuilder4.ToString()).Append(");");
                    sb.AppendLine();
                    sb.AppendLine("return o;}");
                    sb.Append("public ");
                    if (item.ReturnType == typeof(void))
                    {
                        sb.Append("void ");
                    }
                    else
                    {
                        sb.Append(typeDescriptor.getNameForType(item.ReturnType));
                    }
                    sb.Append(" __internalInvoke(");
                    ParameterInfo[] parameters = item.GetParameters();
                    for (int o = 0; o < (int)parameters.Length; o++)
                    {
                        ParameterInfo parameterInfo = parameters[o];
                        if (o > 0)
                        {
                            sb.Append(",");
                        }
                        string str3 = (!parameterInfo.ParameterType.IsPointer ? typeDescriptor.getNameForType(parameterInfo.ParameterType) : "object");
                        sb.Append(str3).Append(" a").Append(o);
                    }
                    sb.Append("){");
                    sb.AppendLine();
                    if (item.ReturnType == typeof(void))
                    {
                        sb.Append("call(").Append(stringBuilder5.ToString()).Append(");");
                    }
                    else
                    {
                        sb.Append("object o= ");
                        sb.Append("call(").Append(stringBuilder5.ToString()).Append(");");
                        sb.AppendLine();
                        sb.Append("if(o is wrapper){o = ((wrapper)o).wrappedObject;}");
                        sb.AppendLine();
                        sb.Append("return (").Append(typeDescriptor.getNameForType(item.ReturnType)).Append(")o;");
                        sb.AppendLine();
                    }
                    sb.Append("}\n");
                }
                else
                {
                    sb.Append("public object ").Append(instanceMethod.Value.name).Append("(");
                    StringBuilder stringBuilder6 = new StringBuilder();
                    bool          flag           = instanceMethod.Value.isGenericMethod;
                    if (flag)
                    {
                        stringBuilder6.Append("System.Collections.Generic.List<System.Type> genericArguments=new System.Collections.Generic.List<System.Type>(1);");
                        for (int p = 0; p < instanceMethod.Value.genericParameterCount; p++)
                        {
                            if (p > 0)
                            {
                                sb.Append(",");
                            }
                            stringBuilder6.Append("if(type").Append(p).Append("!=null){if(type").Append(p);
                            stringBuilder6.Append(" is wrapper){genericArguments.Add((System.Type)(((wrapper)type").Append(p).Append(").wrappedObject));}else{");
                            stringBuilder6.Append("genericArguments.Add(Manager.lastManager.getTypeOrGenericType(type").Append(p).Append(".ToString()));}").Append("}");
                            sb.Append("[Optional] object ").Append("type").Append(p);
                            stringBuilder6.AppendLine();
                        }
                    }
                    stringBuilder6.Append("object[] args = {");
                    for (int q = 0; q < instanceMethod.Value.maxParameterCount; q++)
                    {
                        if (q > 0)
                        {
                            stringBuilder6.Append(",");
                        }
                        if (q > 0 | flag)
                        {
                            sb.Append(",");
                        }
                        stringBuilder6.Append("a").Append(q);
                        sb.Append("[Optional] object ").Append("a").Append(q);
                    }
                    sb.Append("){");
                    stringBuilder6.Append("}");
                    sb.AppendLine();
                    sb.Append(stringBuilder6).Append(";");
                    sb.AppendLine();
                    sb.Append("var m = typeD.methods[").Append(instanceMethod.Value.methodOrder).Append("];");
                    sb.AppendLine();
                    sb.AppendLine("try{");
                    sb.Append("var method = m.getMethodForParameters(ref args);");
                    sb.AppendLine();
                    sb.AppendLine("if(typeDescriptor.isSpecialMethod(method)){");
                    sb.AppendLine("return __process(method.Invoke(wrappedObject,args));");
                    sb.AppendLine("}else{");
                    sb.AppendLine("object ret= null;");
                    sb.AppendLine("System.Reflection.MethodInfo mi= (System.Reflection.MethodInfo) method;");
                    sb.AppendLine("if(mi.ReturnType == typeof(void))");
                    sb.AppendLine("__invoker.invokeMethodVoid(wrappedObject,mi.Name,args);");
                    sb.AppendLine("else");
                    sb.AppendLine("ret= __invoker.invokeMethod(wrappedObject,mi.Name,args);");
                    sb.AppendLine("return __process(ret); }");
                    sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                    sb.AppendLine();
                    sb.AppendLine("}");
                }
            }
            sb.AppendLine("/* PROPIEDADES  */");
            foreach (KeyValuePair <string, propertyDescriptor> instanceProperty in this.instanceProperties)
            {
                sb.Append("public object ");
                if (instanceProperty.Value.maxParameterCount > 0)
                {
                    sb.Append("this[");
                }
                else
                {
                    sb.Append(instanceProperty.Value.name);
                }
                StringBuilder stringBuilder7 = new StringBuilder();
                if (instanceProperty.Value.maxParameterCount > 0)
                {
                    stringBuilder7.Append("object[] args = {");
                    for (int r = 0; r < instanceProperty.Value.maxParameterCount; r++)
                    {
                        if (r > 0)
                        {
                            stringBuilder7.Append(",");
                            sb.Append(",");
                        }
                        stringBuilder7.Append("a").Append(r);
                        sb.Append("[Optional] object ").Append("a").Append(r);
                    }
                    sb.Append("]");
                    stringBuilder7.Append("};");
                }
                else
                {
                    stringBuilder7.Append("object[] args = {};");
                }
                sb.Append("{");
                sb.AppendLine();
                sb.AppendLine("get{");
                sb.Append(stringBuilder7);
                sb.AppendLine();
                sb.Append("var m = typeD.properties[").Append(instanceProperty.Value.propertyOrder).Append("];");
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.Append("var method = m.getPropertyForParameters(ref args);");
                sb.AppendLine();
                sb.Append("object o= method.GetValue(wrappedObject,args);");
                sb.AppendLine("return __process(o);");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
                sb.AppendLine("set{");
                sb.Append(stringBuilder7);
                sb.AppendLine();
                sb.Append("var m = typeD.properties[").Append(instanceProperty.Value.propertyOrder).Append("];");
                sb.AppendLine();
                sb.Append("var method = m.getPropertyForParameters(ref args);");
                sb.AppendLine();
                sb.AppendLine("try{");
                sb.AppendLine("if(value is wrapper){value=((wrapper)value).wrappedObject;}");
                sb.Append("method.SetValue(wrappedObject,value,args);");
                sb.AppendLine("}catch(Exception e){if(e.InnerException!=null){throw e.InnerException;}throw e;}");
                sb.AppendLine();
                sb.AppendLine("}");
                sb.AppendLine("}");
            }
            sb.AppendLine("}}");
            staticClass   = str1;
            instanceClass = str;
        }