Esempio n. 1
0
        //Bad... does way too many things, should be moved to respective classes.
        protected override void ExecuteTask()
        {
            if (macrodefs.Contains(_name))
            {
                if (GetUniqueIdentifier() != ((MacroDefTask)macrodefs[_name]).GetUniqueIdentifier())
                {
                    throw new BuildException("Different MacroDef with the name : " + _name + " already exists. Cannot redefine.", Location);
                }
                Log(Level.Info, string.Format("macrodef \"{0}\" already included.", _name));
                return;
            }
            macrodefs[_name] = this;

            SimpleCSharpCompiler simpleCSharpCompiler = new SimpleCSharpCompiler(GetUniqueIdentifier());

            if (simpleCSharpCompiler.PrecompiledDllExists())
            {
                TypeFactory.ScanAssembly(simpleCSharpCompiler.PreCompiledDllPath, this);
            }
            else
            {
                Log(Level.Info, string.Format("\"{0}\" New or Modified. Compiling.", _name));
                CodeCompileUnit compileUnit = GenerateCode();
                compiledAssembly = simpleCSharpCompiler.CompileAssembly(compileUnit);
                LogGeneratedCode(simpleCSharpCompiler, compileUnit);
                TypeFactory.ScanAssembly(compiledAssembly, this);
            }
        }
Esempio n. 2
0
        private void LogGeneratedCode(SimpleCSharpCompiler simpleCSharpCompiler, CodeCompileUnit compileUnit)
        {
            Log(Level.Verbose, simpleCSharpCompiler.GetSourceCode(compileUnit));
            Type compiledType = compiledAssembly.GetType(typeName);

            Log(Level.Verbose, "Created type " + compiledType + " in " + compiledAssembly.Location);
        }
Esempio n. 3
0
        private void LogGeneratedCode(SimpleCSharpCompiler simpleCSharpCompiler, CodeCompileUnit compileUnit)
        {
            Log(Level.Verbose, simpleCSharpCompiler.GetSourceCode(compileUnit));

            var compiledType = _compiledAssembly.GetType(_typeName);

            Log(Level.Verbose, "Created type {0} in {1}", compiledType, _compiledAssembly.Location);
        }
Esempio n. 4
0
        protected override void ExecuteTask()
        {
            if (!macrodefs.Contains(this.name))
            {
                macrodefs.Add(_name, this);

                CodeCompileUnit      compileUnit          = GenerateCode();
                SimpleCSharpCompiler simpleCSharpCompiler = new SimpleCSharpCompiler();

                compiledAssembly = simpleCSharpCompiler.CompileAssembly(compileUnit);
                LogGeneratedCode(simpleCSharpCompiler, compileUnit);

                TypeFactory.ScanAssembly(compiledAssembly, this);
            }
        }
Esempio n. 5
0
        // Bad... does way too many things, should be moved to respective classes.
        protected override void ExecuteTask()
        {
            if (Macrodefs.Contains(TaskName))
            {
                Log(Level.Info, "macrodef \"{0}\" already included.", TaskName);

                return;
            }

            Macrodefs[TaskName] = this;

            var simpleCSharpCompiler = new SimpleCSharpCompiler();

            var compileUnit = GenerateCode();

            _compiledAssembly = simpleCSharpCompiler.CompileAssembly(compileUnit);
            LogGeneratedCode(simpleCSharpCompiler, compileUnit);
            TypeFactory.ScanAssembly(_compiledAssembly, this);
        }
Esempio n. 6
0
 private void LogGeneratedCode(SimpleCSharpCompiler simpleCSharpCompiler, CodeCompileUnit compileUnit)
 {
     Log(Level.Debug, simpleCSharpCompiler.GetSourceCode(compileUnit));
     Type compiledType = compiledAssembly.GetType(typeName);
     Log(Level.Debug, "Created type " + compiledType + " in " + compiledAssembly.Location);
 }
Esempio n. 7
0
        //Bad... does way too many things, should be moved to respective classes.
        protected override void ExecuteTask()
        {
            if(macrodefs.Contains(_name))
            {
                if (GetUniqueIdentifier() != ((MacroDefTask)macrodefs[_name]).GetUniqueIdentifier())
                    throw new BuildException("Different MacroDef with the name : " + _name + " already exists. Cannot redefine.", Location);
                Log(Level.Info, string.Format("macrodef \"{0}\" already included.", _name));
                return;
            }
            macrodefs[_name] = this;

            SimpleCSharpCompiler simpleCSharpCompiler = new SimpleCSharpCompiler(GetUniqueIdentifier());

            if(simpleCSharpCompiler.PrecompiledDllExists())
            {
                TypeFactory.ScanAssembly(simpleCSharpCompiler.PreCompiledDllPath, this);
            }
            else
            {
                Log(Level.Info, string.Format("\"{0}\" New or Modified. Compiling.", _name));
                CodeCompileUnit compileUnit = GenerateCode();
                compiledAssembly = simpleCSharpCompiler.CompileAssembly(compileUnit);
                LogGeneratedCode(simpleCSharpCompiler, compileUnit);
                TypeFactory.ScanAssembly(compiledAssembly, this);
            }
        }