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 wrapperStatic compile() { wrapperStatic result; if (this.compiled) { result = this.compiledWrapper; } else { StringBuilder stringBuilder = new StringBuilder(); string str = ""; string text = ""; typeDescriptor.addUsingsStatements(stringBuilder); this.precompile(stringBuilder, ref str, ref text); stringBuilder.AppendLine("class program{public static void main(){}}"); try { csharplanguage csharplanguage = typeDescriptor.language; //Clipboard.SetText(stringBuilder.ToString()); csharplanguage.runScript(stringBuilder.ToString(), typeDescriptor.generateInMemory); Type type = csharplanguage.getCompiledAssembly().GetType("jxshell.dotnet4." + str); ConstructorInfo constructorInfo = type.GetConstructor(new Type[] { typeof(Type), typeof(typeDescriptor) }); this.compiledWrapper = (wrapperStatic)constructorInfo.Invoke(new object[] { this.type, this }); this.compiled = true; } catch (Exception ex) { throw new Exception("No se puede obtener un wrapper para el tipo " + this.type.ToString() + ". " + ex.Message, ex); } result = this.compiledWrapper; } return(result); }