public void loadManyTypes(string types) { string[] array = types.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); StringBuilder stringBuilder = new StringBuilder(); typeDescriptor.addUsingsStatements(stringBuilder); Dictionary <Type, type_1> dictionary = new Dictionary <Type, type_1>(); string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string typeName = array2[i]; Type typeOrGenericType = this.getTypeOrGenericType(typeName); typeDescriptor typeDescriptor = new typeDescriptor(typeOrGenericType, typeName, false); if (!typeDescriptor.isCompiled()) { string staticClass = ""; string instanceClass = ""; typeDescriptor.precompile(stringBuilder, ref staticClass, ref instanceClass); dictionary[typeOrGenericType] = new type_1 { td = typeDescriptor, staticClass = staticClass, instanceClass = instanceClass, t = typeOrGenericType }; } } stringBuilder.AppendLine("class program{public static void main(){}}"); csharplanguage csharplanguage = (csharplanguage)language.defaultLanguage.create(); if (dictionary.Count > 0) { csharplanguage.runScript(stringBuilder.ToString(), typeDescriptor.generateInMemory); } foreach (KeyValuePair <Type, type_1> current in dictionary) { type_1 value = current.Value; Type type = csharplanguage.getCompiledAssembly().GetType("jxshell.dotnet4." + value.staticClass); ConstructorInfo constructor = type.GetConstructor(new Type[] { typeof(Type), typeof(typeDescriptor) }); value.td.setCompiledWrapper((wrapperStatic)constructor.Invoke(new object[] { value.t, value.td })); } }
public void loadManyTypes(Type[] types) { StringBuilder stringBuilder = new StringBuilder(); jxshell.dotnet4.typeDescriptor.addUsingsStatements(stringBuilder); Dictionary <Type, type_1> dictionary = new Dictionary <Type, type_1>(); Type[] typeArray = types; for (int i = 0; i < (int)typeArray.Length; i++) { Type type = typeArray[i]; if (!type.IsGenericType && type.IsPublic) { jxshell.dotnet4.typeDescriptor typeDescriptor = new jxshell.dotnet4.typeDescriptor(type, jxshell.dotnet4.typeDescriptor.getNameForType(type), false); if (!typeDescriptor.isCompiled()) { string staticClass = ""; string instanceClass = ""; typeDescriptor.precompile(stringBuilder, ref staticClass, ref instanceClass); dictionary[type] = new type_1() { td = typeDescriptor, staticClass = staticClass, instanceClass = instanceClass, t = type }; } } } stringBuilder.AppendLine("class program{public static void main(){}}"); jxshell.csharplanguage csharplanguage = (jxshell.csharplanguage)language.defaultLanguage.create(); if (dictionary.Count > 0) { csharplanguage.runScript(stringBuilder.ToString(), jxshell.dotnet4.typeDescriptor.generateInMemory); } foreach (KeyValuePair <Type, type_1> item in dictionary) { type_1 value = item.Value; Type type2 = csharplanguage.getCompiledAssembly().GetType(string.Concat("jxshell.dotnet4.", value.staticClass)); ConstructorInfo constructor = type2.GetConstructor(new Type[] { typeof(Type), typeof(jxshell.dotnet4.typeDescriptor) }); value.td.setCompiledWrapper((wrapperStatic)constructor.Invoke(new object[] { value.t, value.td })); } }