コード例 #1
0
        public wrapperStatic compile()
        {
            if (this.compiled)
            {
                return(this.compiledWrapper);
            }
            StringBuilder stringBuilder = new StringBuilder();
            string        staticClass   = "";
            string        instanceClass = "";

            typeDescriptor.addUsingsStatements(stringBuilder);
            this.precompile(stringBuilder, ref staticClass, ref instanceClass);
            stringBuilder.AppendLine("class program{public static void main(){}}");
            try
            {
                jxshell.csharplanguage csharplanguage = typeDescriptor.language;
                csharplanguage.runScript(stringBuilder.ToString(), typeDescriptor.generateInMemory);
                Type            type            = csharplanguage.getCompiledAssembly().GetType(string.Concat("jxshell.dotnet4.", staticClass));
                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 exception)
            {
                Exception ex = exception;
                throw new Exception(string.Concat("No se puede obtener un wrapper para el tipo ", this.type.ToString(), ". ", ex.Message), ex);
            }
            return(this.compiledWrapper);
        }
コード例 #2
0
        public wrapperStatic compile()
        {
            wrapperStatic _wrapperStatic;

            if (!this.compiled)
            {
                // generar un archivo  por cada tipo
                string   name = GetSHA1(this.type.AssemblyQualifiedName).ToUpper();
                string   file = environment.getCompilationFile(name);
                FileInfo f    = new FileInfo(file);

                try
                {
                    if (f.Exists)
                    {
                        string str  = "C" + GetSHA1(type.AssemblyQualifiedName);
                        string str1 = "C" + GetSHA1(type.AssemblyQualifiedName) + "_static";

                        Type            _type        = Assembly.LoadFile(file).GetType(string.Concat("jxshell.dotnet4.", str1));
                        ConstructorInfo _constructor = _type.GetConstructor(new Type[] { typeof(Type), typeof(typeDescriptor) });

                        this.compiledWrapper = (wrapperStatic)_constructor.Invoke(new object[] { this.type, this });
                        this.compiled        = true;
                    }
                    else
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        string        str           = "";
                        string        str1          = "";
                        typeDescriptor.addUsingsStatements(stringBuilder);
                        this.precompile(stringBuilder, ref str, ref str1);
                        stringBuilder.AppendLine("class program{public static void main(){}}");

                        csharplanguage _csharplanguage = typeDescriptor.language;
                        _csharplanguage.runScriptWithId(stringBuilder.ToString(), name);

                        Type            _type        = _csharplanguage.getCompiledAssembly().GetType(string.Concat("jxshell.dotnet4.", str));
                        ConstructorInfo _constructor = _type.GetConstructor(new Type[] { typeof(Type), typeof(typeDescriptor) });

                        this.compiledWrapper = (wrapperStatic)_constructor.Invoke(new object[] { this.type, this });
                        this.compiled        = true;
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    throw new Exception(string.Concat("No se puede obtener un wrapper para el tipo ", this.type.ToString(), ". ", exception.Message), exception);
                }
                _wrapperStatic = this.compiledWrapper;
            }
            else
            {
                _wrapperStatic = this.compiledWrapper;
            }
            return(_wrapperStatic);
        }
コード例 #3
0
ファイル: typeDescriptor.cs プロジェクト: voxsoftware/jxshell
        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);
        }
コード例 #4
0
ファイル: typeDescriptor.cs プロジェクト: voxsoftware/jxshell
 public void setCompiledWrapper(wrapperStatic ww)
 {
     this.compiled        = true;
     this.compiledWrapper = ww;
 }