Ejemplo n.º 1
0
        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 }));
            }
        }
Ejemplo n.º 2
0
 public static wrapper createWrapper(object o)
 {
     jxshell.dotnet4.typeDescriptor typeDescriptor = jxshell.dotnet4.typeDescriptor.loadFromType(o.GetType());
     return(typeDescriptor.compile().getWrapper(o));
 }