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


C# Compilation.AssemblyBuilder类代码示例

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


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

示例1: 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

示例2: AssemblyBuilderWrapper

        public AssemblyBuilderWrapper(AssemblyBuilder builder) {
            if (builder == null) {
                throw new ArgumentNullException("builder");
            }

            InnerBuilder = builder;
        }
开发者ID:radischevo,项目名称:Radischevo.Wahha,代码行数:7,代码来源:AssemblyBuilderWrapper.cs

示例3: GenerateCode

 public override void GenerateCode(AssemblyBuilder assemblyBuilder) {
     var context = new CompileExtensionContext {
         VirtualPath = this.VirtualPath,
         AssemblyBuilder =  new AspNetAssemblyBuilder(assemblyBuilder, this)
     };
     HostContainer.Resolve<IExtensionCompiler>().Compile(context);
 }
开发者ID:sjbisch,项目名称:Orchard,代码行数:7,代码来源:CSharpExtensionBuildProviderShim.cs

示例4: GenerateCode

    public override void GenerateCode(AssemblyBuilder assemblyBuilder) {

        CodeCompileUnit codeCompileUnit = _parser.GetCodeModel();

        // Bail if we have nothing we need to compile
        if (codeCompileUnit == null)
            return;

        assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit);

        // Add all the assemblies
        if (_parser.AssemblyDependencies != null) {
            foreach (Assembly assembly in _parser.AssemblyDependencies) {
                assemblyBuilder.AddAssemblyReference(assembly, codeCompileUnit);
            }
        }

        // NOTE: we can't actually generate the fast factory because it would give
        // a really bad error if the user specifies a classname which doesn't match
        // the actual class they define.  A bit unfortunate, but not that big a deal...

        // tell the host to generate a fast factory for this type (if any)
        //string generatedTypeName = _parser.GeneratedTypeName;
        //if (generatedTypeName != null)
        //    assemblyBuilder.GenerateTypeFactory(generatedTypeName);
    }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:26,代码来源:SimpleHandlerBuildProvider.cs

示例5: GenerateCode

 public override void GenerateCode(AssemblyBuilder assemblyBuilder)
 {
     if (this.Parser.RequiresCompilation)
     {
         BaseCodeDomTreeGenerator generator = this.CreateCodeDomTreeGenerator(this._parser);
         CodeCompileUnit ccu = generator.GetCodeDomTree(assemblyBuilder.CodeDomProvider, assemblyBuilder.StringResourceBuilder, base.VirtualPathObject);
         if (ccu != null)
         {
             if (this._parser.AssemblyDependencies != null)
             {
                 foreach (Assembly assembly in (IEnumerable) this._parser.AssemblyDependencies)
                 {
                     assemblyBuilder.AddAssemblyReference(assembly, ccu);
                 }
             }
             assemblyBuilder.AddCodeCompileUnit(this, ccu);
         }
         this._instantiatableFullTypeName = generator.GetInstantiatableFullTypeName();
         if (this._instantiatableFullTypeName != null)
         {
             assemblyBuilder.GenerateTypeFactory(this._instantiatableFullTypeName);
         }
         this._intermediateFullTypeName = generator.GetIntermediateFullTypeName();
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:BaseTemplateBuildProvider.cs

示例6: GenerateCode

 /// <summary>
 /// Generates source code for the virtual path of the build provider, and adds the source code to a specified assembly builder.
 /// </summary>
 /// <param name="assemblyBuilder">The assembly builder that references the source code generated by the build provider.</param>
 public override void GenerateCode(AssemblyBuilder assemblyBuilder)
 {
     if (!IsCompiledFile)
     {
         base.GenerateCode(assemblyBuilder);
     }
 }
开发者ID:rondoo,项目名称:framework,代码行数:11,代码来源:CompiledRazorBuildProvider.cs

示例7: GenerateCode

 public override void GenerateCode(AssemblyBuilder assemblyBuilder)
 {
     assemblyBuilder.AddAssemblyReference(typeof(SimpleWeb).Assembly);
     assemblyBuilder.AddAssemblyReference(typeof(SimpleTemplateBase).Assembly);
     assemblyBuilder.AddCodeCompileUnit(this, GeneratedCode);
     assemblyBuilder.GenerateTypeFactory(String.Format(CultureInfo.InvariantCulture, "{0}.{1}", Host.DefaultNamespace, "Foot"));
 }
开发者ID:rkevinstout,项目名称:Simple.Web,代码行数:7,代码来源:SimpleRazorBuildProvider.cs

示例8: AddPropertyGroup

 private void AddPropertyGroup(AssemblyBuilder assemblyBuilder, string groupName, string propertyNames, Hashtable properties, CodeTypeDeclaration type, CodeNamespace ns)
 {
     CodeMemberProperty property = new CodeMemberProperty {
         Name = groupName,
         Attributes = MemberAttributes.Public,
         HasGet = true,
         Type = new CodeTypeReference("ProfileGroup" + groupName)
     };
     CodeMethodInvokeExpression expression = new CodeMethodInvokeExpression {
         Method = { TargetObject = new CodeThisReferenceExpression(), MethodName = "GetProfileGroup" }
     };
     expression.Parameters.Add(new CodePrimitiveExpression(property.Name));
     CodeMethodReturnStatement statement = new CodeMethodReturnStatement(new CodeCastExpression(property.Type, expression));
     property.GetStatements.Add(statement);
     type.Members.Add(property);
     CodeTypeDeclaration declaration = new CodeTypeDeclaration {
         Name = "ProfileGroup" + groupName
     };
     declaration.BaseTypes.Add(new CodeTypeReference(typeof(ProfileGroupBase)));
     foreach (string str in propertyNames.Split(new char[] { ';' }))
     {
         this.CreateCodeForProperty(assemblyBuilder, declaration, (ProfileNameTypeStruct) properties[str]);
     }
     ns.Types.Add(declaration);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:ProfileBuildProvider.cs

示例9: GenerateCodeCore

        void GenerateCodeCore(AssemblyBuilder assemblyBuilder)
        {
            if (assemblyBuilder == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("assemblyBuilder");
            }

            CodeCompileUnit codeCompileUnit = parser.GetCodeModel();

            // Bail if we have nothing we need to compile
            //
            if (codeCompileUnit == null)
                return;

            // Add the code unit and then add all the assemblies 
            //
            assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit);
            if (parser.AssemblyDependencies != null)
            {
                foreach (Assembly assembly in parser.AssemblyDependencies)
                {
                    assemblyBuilder.AddAssemblyReference(assembly);
                }
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:25,代码来源:ServiceBuildProvider.cs

示例10: GenerateCode

    public override void GenerateCode(AssemblyBuilder assemblyBuilder)  {
#if !FEATURE_PAL // FEATURE_PAL does not support System.Data.Design
        // Get the namespace that we will use
        string ns = Util.GetNamespaceFromVirtualPath(VirtualPathObject);

        // We need to use XmlDocument to parse the xsd file is order to open it with the
        // correct encoding (VSWhidbey 566286)
        XmlDocument doc = new XmlDocument();
        using (Stream stream = OpenStream()) {
            doc.Load(stream);
        }
        String content = doc.OuterXml;

        // Generate a CodeCompileUnit from the dataset
        CodeCompileUnit codeCompileUnit = new CodeCompileUnit();

        CodeNamespace codeNamespace = new CodeNamespace(ns);
        codeCompileUnit.Namespaces.Add(codeNamespace);

        // Devdiv 18365, Dev10 bug 444516 
        // Call a different Generate method if compiler version is v3.5 or above
        bool isVer35OrAbove = CompilationUtil.IsCompilerVersion35OrAbove(assemblyBuilder.CodeDomProvider.GetType());

        if (isVer35OrAbove) {
            TypedDataSetGenerator.GenerateOption generateOptions = TypedDataSetGenerator.GenerateOption.None;
            generateOptions |= TypedDataSetGenerator.GenerateOption.HierarchicalUpdate;
            generateOptions |= TypedDataSetGenerator.GenerateOption.LinqOverTypedDatasets;
            Hashtable customDBProviders = null;
            TypedDataSetGenerator.Generate(content, codeCompileUnit, codeNamespace, assemblyBuilder.CodeDomProvider, customDBProviders, generateOptions);
        }
        else {
            TypedDataSetGenerator.Generate(content, codeCompileUnit, codeNamespace, assemblyBuilder.CodeDomProvider);
        }

        // Add all the assembly references needed by the generated code
        if (TypedDataSetGenerator.ReferencedAssemblies != null) {
            var isVer35 = CompilationUtil.IsCompilerVersion35(assemblyBuilder.CodeDomProvider.GetType());
            foreach (Assembly a in TypedDataSetGenerator.ReferencedAssemblies) {
                
                if (isVer35) {
                    var aName = a.GetName();
                    if (aName.Name == "System.Data.DataSetExtensions") {
                        // Dev10 Bug 861688 - We need to specify v3.5 version so that the build system knows to use the v3.5 version
                        // because the loaded assembly here is always v4.0
                        aName.Version = new Version(3, 5, 0, 0);
                        CompilationSection.RecordAssembly(aName.FullName, a);
                    }
                }
                assemblyBuilder.AddAssemblyReference(a);
            }
        }
        

        // Add the CodeCompileUnit to the compilation
        assemblyBuilder.AddCodeCompileUnit(this, codeCompileUnit);
#else // !FEATURE_PAL 
        throw new NotImplementedException("System.Data.Design - ROTORTODO");
#endif // !FEATURE_PAL 
    }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:59,代码来源:XsdBuildProvider.cs

示例11: OverrideAssemblyPrefix

		protected override void OverrideAssemblyPrefix (TemplateParser parser, AssemblyBuilder assemblyBuilder)
		{
			if (parser == null || assemblyBuilder == null)
				return;

			string newPrefix = assemblyBuilder.OutputFilesPrefix + parser.ClassName + ".";
			assemblyBuilder.OutputFilesPrefix = newPrefix;
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:ThemeDirectoryBuildProvider.cs

示例12: GenerateCode

        public override void GenerateCode(AssemblyBuilder myAb)
        {
            XmlDocument carXmlDoc = new XmlDocument();

            using (Stream passedFile = OpenStream())
            {
                carXmlDoc.Load(passedFile);
            }
            XmlNode mainNode = carXmlDoc.SelectSingleNode("/car");
            string selectionMainNode = mainNode.Attributes["name"].Value;

            XmlNode colorNode = carXmlDoc.SelectSingleNode("/car/color");
            string selectionColorNode = colorNode.InnerText;

            XmlNode doorNode = carXmlDoc.SelectSingleNode("/car/door");
            string selectionDoorNode = doorNode.InnerText;

            XmlNode speedNode = carXmlDoc.SelectSingleNode("/car/speed");
            string selectionSpeedNode = speedNode.InnerText;

            CodeCompileUnit ccu = new CodeCompileUnit();
            CodeNamespace cn = new CodeNamespace();
            CodeMemberProperty cmp1 = new CodeMemberProperty();
            CodeMemberProperty cmp2 = new CodeMemberProperty();
            CodeMemberMethod cmm1 = new CodeMemberMethod();

            cn.Imports.Add(new CodeNamespaceImport("System"));

            cmp1.Name = "Color";
            cmp1.Type = new CodeTypeReference(typeof(string));
            cmp1.Attributes = MemberAttributes.Public;
            cmp1.GetStatements.Add(new CodeSnippetExpression("return \"" +
               selectionColorNode + "\""));

            cmp2.Name = "Doors";
            cmp2.Type = new CodeTypeReference(typeof(int));
            cmp2.Attributes = MemberAttributes.Public;
            cmp2.GetStatements.Add(new CodeSnippetExpression("return " +
               selectionDoorNode));

            cmm1.Name = "Go";
            cmm1.ReturnType = new CodeTypeReference(typeof(int));
            cmm1.Attributes = MemberAttributes.Public;
            cmm1.Statements.Add(new CodeSnippetExpression("return " +
               selectionSpeedNode));

            CodeTypeDeclaration ctd = new CodeTypeDeclaration(selectionMainNode);
            ctd.Members.Add(cmp1);
            ctd.Members.Add(cmp2);
            ctd.Members.Add(cmm1);

            cn.Types.Add(ctd);
            ccu.Namespaces.Add(cn);

            myAb.AddCodeCompileUnit(this, ccu);
        }
开发者ID:kacecode,项目名称:SchoolWork,代码行数:56,代码来源:Car.cs

示例13: AddReferences

    /// <summary>
    /// 添加依赖项
    /// </summary>
    /// <param name="assemblyBuilder"></param>
    protected virtual void AddReferences( AssemblyBuilder assemblyBuilder )
    {
      var buildTypeAssembly = GetType().Assembly;
      var domProviderTypeAssembly = GetDomProviderType().Assembly;


      assemblyBuilder.AddAssemblyReference( buildTypeAssembly );
      if ( buildTypeAssembly != domProviderTypeAssembly )
        assemblyBuilder.AddAssemblyReference( domProviderTypeAssembly );
    }
开发者ID:ajayumi,项目名称:Jumony,代码行数:14,代码来源:HtmlBuildProvider.cs

示例14: Compile

		public void Compile ()
		{
			string refsPath = Path.Combine (HttpRuntime.AppDomainAppPath, ResourcesDirName);
			if (!Directory.Exists (refsPath))
				return;

			string[] files = Directory.GetFiles (refsPath, "*.wsdl", SearchOption.AllDirectories);
			if (files == null || files.Length == 0)
				return;

			CompilationSection cs = WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
			if (cs == null)
				throw new HttpException ("Unable to determine default compilation language.");

			CompilerType ct = BuildManager.GetDefaultCompilerTypeForLanguage (cs.DefaultLanguage, cs);
			CodeDomProvider codeDomProvider = null;
			Exception codeDomException = null;
			
			try {
				codeDomProvider = Activator.CreateInstance (ct.CodeDomProviderType) as CodeDomProvider;
			} catch (Exception e) {
				codeDomException = e;
			}

			if (codeDomProvider == null)
				throw new HttpException ("Unable to instantiate default compilation language provider.", codeDomException);

			AssemblyBuilder ab = new AssemblyBuilder (codeDomProvider, "App_WebReferences_");
			ab.CompilerOptions = ct.CompilerParameters;
			
			VirtualPath vp;
			WsdlBuildProvider wbp;
			foreach (string file in files) {
				vp = VirtualPath.PhysicalToVirtual (file);
				if (vp == null)
					continue;
				
				wbp = new WsdlBuildProvider ();
				wbp.SetVirtualPath (vp);
				wbp.GenerateCode (ab);
			}

			CompilerResults results;
			try {
				results = ab.BuildAssembly ();
			} catch (CompilationException ex) {
				throw new HttpException ("Failed to compile web references.", ex);
			}

			if (results == null)
				return;
			
			Assembly asm = results.CompiledAssembly;
			BuildManager.TopLevelAssemblies.Add (asm);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:55,代码来源:AppWebReferencesCompiler.cs

示例15: GenerateCode

        public void GenerateCode(AssemblyBuilder assemblyBuilder, Stream xamlStream, BuildProvider buildProvider)
        {
            object serviceObject = WorkflowServiceHostFactory.LoadXaml(xamlStream);

            WorkflowService workflowService = serviceObject as WorkflowService;
            if (workflowService != null && workflowService.Body != null)
            {
                string activityName;
                if (this.TryGenerateSource(assemblyBuilder, buildProvider, workflowService, false, null, out activityName))
                {
                    this.generatedPrimaryTypeName = GeneratedNamespace + "." + activityName + ExpressionRootFactorySuffix;
                }

                // find all supported versions xamlx files, load and compile them
                IList<Tuple<string, Stream>> streams = null;

                string xamlVirtualFile = GetXamlVirtualPath(buildProvider);
                string xamlFileName = Path.GetFileNameWithoutExtension(VirtualPathUtility.GetFileName(xamlVirtualFile));
                WorkflowServiceHostFactory.GetSupportedVersionStreams(xamlFileName, out streams);
                if (streams != null)
                {
                    try
                    {
                        foreach (Tuple<string, Stream> stream in streams)
                        {
                            try
                            {
                                WorkflowService service = WorkflowServiceHostFactory.CreatetWorkflowService(stream.Item2, workflowService.Name);
                                if (service != null && service.Body != null)
                                {
                                    this.TryGenerateSource(assemblyBuilder, buildProvider, service, true, stream.Item1, out activityName);
                                }
                            }
                            catch (Exception e)
                            {
                                Exception newException;
                                if (Fx.IsFatal(e) || !WorkflowServiceHostFactory.TryWrapSupportedVersionException(stream.Item1, e, out newException))
                                {
                                    throw;
                                }

                                throw FxTrace.Exception.AsError(newException);
                            }
                        }
                    }
                    finally
                    {
                        foreach (Tuple<string, Stream> stream in streams)
                        {
                            stream.Item2.Dispose();
                        }
                    }
                }
            }            
        }        
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:55,代码来源:XamlBuildProviderExtension.cs


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