当前位置: 首页>>代码示例>>C#>>正文


C# Compiler.CompilerResults类代码示例

本文整理汇总了C#中System.CodeDom.Compiler.CompilerResults的典型用法代码示例。如果您正苦于以下问题:C# CompilerResults类的具体用法?C# CompilerResults怎么用?C# CompilerResults使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CompilerResults类属于System.CodeDom.Compiler命名空间,在下文中一共展示了CompilerResults类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        /// <exception cref="TargetInvocationException">When the supplied assembly's main method throws</exception>
        public void Execute(CompilerResults results, IEnumerable<string> additionalReferences)
        {
            var entryPoint = results.CompiledAssembly.EntryPoint;

            using(serviceMessages.ProgressBlock("Executing script"))
                ExecutePrivate(entryPoint, additionalReferences);
        }
开发者ID:Tdue21,项目名称:teamcitycsharprunner,代码行数:8,代码来源:Executor.cs

示例2: CompileAssemblyFromDomBatch

        public CompilerResults CompileAssemblyFromDomBatch(CompilerParameters options, CodeCompileUnit[] compilationUnits)
        {
            Setup(options, ContainsLocalFunctions(compilationUnits));

            foreach(var Unit in compilationUnits)
            {
                foreach (CodeAttributeDeclaration attribute in Unit.AssemblyCustomAttributes)
                    EmitAttribute(ABuilder, attribute);
                    
                EmitNamespace(ABuilder, Unit.Namespaces[0]);
            }
            
            ABuilder.SetEntryPoint(EntryPoint, PEFileKinds.WindowApplication);
            Save();

            var results = new CompilerResults(new TempFileCollection());
            string output = options.OutputAssembly;

            if (options.GenerateInMemory)
            {
                results.TempFiles.AddFile(output, false);
                byte[] raw = File.ReadAllBytes(output);
                results.CompiledAssembly = Assembly.Load(raw);
                File.Delete(output);
            }
            else
                results.PathToAssembly = Path.GetFullPath(output);

            return results;
        }
开发者ID:BillTheBest,项目名称:IronAHK,代码行数:30,代码来源:Compiler.cs

示例3: Compile

 public List<CheckingResult> Compile(string program, out CompilerResults compilerResults)
 {
     compilerResults = null;
     using (var provider = new CSharpCodeProvider())
     {
         compilerResults = provider.CompileAssemblyFromSource(new CompilerParameters(new string[]
         {
             "System.dll"
         })
         {
             GenerateExecutable = true
         },
         new string[]
         {
             program
         });
     }
     var result = new List<CheckingResult>();
     if (compilerResults.Errors.HasErrors)
     {
         for (int i = 0; i < compilerResults.Errors.Count; i++)
             result.Add(new CheckingResult
             {
                 FirstErrorLine = compilerResults.Errors[i].Line,
                 FirstErrorColumn = compilerResults.Errors[i].Column,
                 Output = null,
                 Description = compilerResults.Errors[i].ErrorText
             });
     }
     return result;
 }
开发者ID:KvanTTT,项目名称:Freaky-Sources,代码行数:31,代码来源:CSharpChecker.cs

示例4: Load

		void Load (CompilerResults results, string fullName)
		{
			var assembly = results.CompiledAssembly;
			Type transformType = assembly.GetType (fullName);
			//MS Templating Engine does not look on the type itself, 
			//it checks only that required methods are exists in the compiled type 
			textTransformation = Activator.CreateInstance (transformType);
			
			//set the host property if it exists
			Type hostType = null;
			var gen = host as TemplateGenerator;
			if (gen != null) {
				hostType = gen.SpecificHostType;
			}
			var hostProp = transformType.GetProperty ("Host", hostType ?? typeof(ITextTemplatingEngineHost));
			if (hostProp != null && hostProp.CanWrite)
				hostProp.SetValue (textTransformation, host, null);
			
			var sessionHost = host as ITextTemplatingSessionHost;
			if (sessionHost != null) {
				//FIXME: should we create a session if it's null?
				var sessionProp = transformType.GetProperty ("Session", typeof (IDictionary<string, object>));
				sessionProp.SetValue (textTransformation, sessionHost.Session, null);
			}
		}
开发者ID:riverans,项目名称:monodevelop,代码行数:25,代码来源:CompiledTemplate.cs

示例5: CompileScript

        /// <summary>
        /// Compile Script -> Return Assembly
        /// </summary>
        public Assembly CompileScript(IRefObject ScriptObject, out CompilerResults Result)
        {
            String ClassName, PrefixName;
            switch (ScriptObject.Type)
            {
                case IRefObject.ScriptType.WEAPON:
                    ClassName = "ScriptWeapon";
                    PrefixName = "WeaponPrefix";
                    break;

                default:
                    ClassName = "ScriptLevelNpc";
                    PrefixName = "LevelNpcPrefix";
                    break;
            }

            // Setup our options
            CompilerParameters options = new CompilerParameters();
            options.GenerateExecutable = false;
            options.GenerateInMemory = true;
            options.ReferencedAssemblies.Add(Assembly.GetExecutingAssembly().Location);
            options.ReferencedAssemblies.Add("System.dll");
            options.ReferencedAssemblies.Add("System.Core.dll");
            options.ReferencedAssemblies.Add("Microsoft.CSharp.dll");

            // Compile our code
            CSharpCodeProvider csProvider = new Microsoft.CSharp.CSharpCodeProvider();
            Result = csProvider.CompileAssemblyFromSource(options, "using CS_NPCServer; public class " + PrefixName + NextId[(int)ScriptObject.Type] + " : " + ClassName + " { public " + PrefixName + NextId[(int)ScriptObject.Type] + "(NPCServer Server, IRefObject Ref) : base(Server, Ref) { } " + ParseJoins(ScriptObject.Script) + " } ");
            NextId[(int)ScriptObject.Type]++;
            return (Result.Errors.HasErrors ? null : Result.CompiledAssembly);
        }
开发者ID:dufresnep,项目名称:gs2emu-googlecode,代码行数:34,代码来源:GameCompiler.cs

示例6: CompilerErrorException

 public CompilerErrorException(CompilerResults results)
 {
     foreach (CompilerError error in results.Errors)
     {
         this.CompilerMessage += error + "\n";
     }
 }
开发者ID:esmaxwill,项目名称:ScriptHost,代码行数:7,代码来源:CompilerErrorException.cs

示例7: GetGeneratedType

 public override Type GetGeneratedType(CompilerResults results)
 {
     Type type;
     try
     {
         using (Stream stream = base.OpenStream())
         {
             XamlXmlReader reader2 = new XamlXmlReader(XmlReader.Create(stream));
             while (reader2.Read())
             {
                 if (reader2.NodeType == XamlNodeType.StartObject)
                 {
                     if (reader2.Type.IsUnknown)
                     {
                         StringBuilder sb = new StringBuilder();
                         this.AppendTypeName(reader2.Type, sb);
                         throw FxTrace.Exception.AsError(new TypeLoadException(System.Xaml.Hosting.SR.CouldNotResolveType(sb)));
                     }
                     return reader2.Type.UnderlyingType;
                 }
             }
             throw FxTrace.Exception.AsError(new HttpCompileException(System.Xaml.Hosting.SR.UnexpectedEof));
         }
     }
     catch (XamlParseException exception)
     {
         throw FxTrace.Exception.AsError(new HttpCompileException(exception.Message, exception));
     }
     return type;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:XamlBuildProvider.cs

示例8: handleErrors

		private void handleErrors(CompilerResults compilerResults)
		{
			if (compilerResults.Errors.Count > 0) 
			{
				StringBuilder sb = new StringBuilder("Error compiling the composition script:\n");

				foreach (CompilerError compilerError in compilerResults.Errors) 
				{
					if (!compilerError.IsWarning) 
					{
						sb.Append("\nError number:\t")
							.Append(compilerError.ErrorNumber)
							.Append("\nMessage:\t ")
							.Append(compilerError.ErrorText)
							.Append("\nLine number:\t")
							.Append(compilerError.Line);
					}
				}
				
				if (!sb.Length.Equals(0)) 
				{
					throw new PicoCompositionException(sb.ToString());
				}
			}
		}
开发者ID:smmckay,项目名称:picocontainer,代码行数:25,代码来源:FrameworkCompiler.cs

示例9: GetGeneratedType

 internal Type GetGeneratedType(CompilerResults results, bool useDelayLoadTypeIfEnabled)
 {
     string str;
     if (!this.Parser.RequiresCompilation)
     {
         return null;
     }
     if (this._instantiatableFullTypeName == null)
     {
         if (this.Parser.CodeFileVirtualPath == null)
         {
             return this.Parser.BaseType;
         }
         str = this._intermediateFullTypeName;
     }
     else
     {
         str = this._instantiatableFullTypeName;
     }
     if (useDelayLoadTypeIfEnabled && DelayLoadType.Enabled)
     {
         return new DelayLoadType(Util.GetAssemblyNameFromFileName(Path.GetFileName(results.PathToAssembly)), str);
     }
     return results.CompiledAssembly.GetType(str);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:BaseTemplateBuildProvider.cs

示例10: CacheCompileErrors

 private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results)
 {
     System.Web.Compilation.BuildProvider provider = null;
     foreach (CompilerError error in results.Errors)
     {
         if (!error.IsWarning)
         {
             System.Web.Compilation.BuildProvider buildProviderFromLinePragma = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName);
             if (((buildProviderFromLinePragma != null) && (buildProviderFromLinePragma is BaseTemplateBuildProvider)) && (buildProviderFromLinePragma != provider))
             {
                 provider = buildProviderFromLinePragma;
                 CompilerResults results2 = new CompilerResults(null);
                 foreach (string str in results.Output)
                 {
                     results2.Output.Add(str);
                 }
                 results2.PathToAssembly = results.PathToAssembly;
                 results2.NativeCompilerReturnValue = results.NativeCompilerReturnValue;
                 results2.Errors.Add(error);
                 HttpCompileException compileException = new HttpCompileException(results2, assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProviderFromLinePragma));
                 BuildResult result = new BuildResultCompileError(buildProviderFromLinePragma.VirtualPathObject, compileException);
                 buildProviderFromLinePragma.SetBuildResultDependencies(result);
                 BuildManager.CacheVPathBuildResult(buildProviderFromLinePragma.VirtualPathObject, result, this._utcStart);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:WebDirectoryBatchCompiler.cs

示例11: ProcessResults

 private static void ProcessResults(CompilerResults results)
 {
     if (results.Errors.Count != 0)
         throw new CompilingErrorsException(results.Errors.OfType<CompilerError>().ToArray());
     if (results.CompiledAssembly == null)
         throw new CompilingException(CouldNotLocateAssemblyErrorMessage);
 }
开发者ID:Eskat0n,项目名称:NArms,代码行数:7,代码来源:CompilingServiceBase.cs

示例12: Check

        private static _Assembly Check(CompilerResults results) {
            if (results.Errors.Count > 0) {
                throw new CompilerException(results);
            }

            return results.CompiledAssembly;
        }
开发者ID:roomaroo,项目名称:coapp.powershell,代码行数:7,代码来源:CompilerImpl.cs

示例13: BuildManagerCacheItem

		public BuildManagerCacheItem (Assembly assembly, BuildProvider bp, CompilerResults results)
		{
			this.BuiltAssembly = assembly;
			this.CompiledCustomString = bp.GetCustomString (results);
			this.VirtualPath = bp.VirtualPath;
			this.Type = bp.GetGeneratedType (results);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:7,代码来源:BuildManagerCacheItem.cs

示例14: GetGeneratedType

 public override Type GetGeneratedType(CompilerResults results)
 {
     if (this.xamlBuildProviderExtension != null)
     {
         Type result = this.xamlBuildProviderExtension.GetGeneratedType(results);
         if (result != null)
         {
             return result;
         }
     }
     
     try
     {
         XamlType rootXamlType = GetRootXamlType();
         if (rootXamlType.IsUnknown)
         {
             StringBuilder typeName = new StringBuilder();
             AppendTypeName(rootXamlType, typeName);
             throw FxTrace.Exception.AsError(new TypeLoadException(SR.CouldNotResolveType(typeName)));
         }
         return rootXamlType.UnderlyingType;
     }
     catch (XamlParseException ex)
     {
         throw FxTrace.Exception.AsError(new HttpCompileException(ex.Message, ex));
     }
 }        
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:27,代码来源:XamlBuildProvider.cs

示例15: CompileAssemblyFromSource

        // Build an assembly from a list of source strings.
        public override CompilerResults CompileAssemblyFromSource(CompilerParameters options, params string[] sources)
        {
            var root = new Root();

            foreach(string code in sources)
                parser.Parse(root, code);

            if(root.CompilerErrors.Count > 0)
            {
                var results = new CompilerResults(null);
                foreach(var e in root.CompilerErrors)
                    results.Errors.Add(e);
                return results;
            }

            validator.Validate(options, root);

            if (root.CompilerErrors.Count > 0)
            {
                var results = new CompilerResults(null);
                foreach (var e in root.CompilerErrors)
                    results.Errors.Add(e);
                return results;
            }

            var codeDomEmitter = new CodeDomEmitter();
            return codeDomEmitter.Emit(options, root);
        }
开发者ID:maleficus1234,项目名称:Pie,代码行数:29,代码来源:PieCodeProvider.cs


注:本文中的System.CodeDom.Compiler.CompilerResults类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。