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


C# CompilationContext类代码示例

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


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

示例1: EmitCall

        public static void EmitCall(
            CompilationContext context,
            IAstRefOrAddr invocationObject,
            MethodInfo methodInfo,
            List<IAstStackItem> arguments)
        {
            if (arguments == null)
            {
                arguments = new List<IAstStackItem>();
            }
            if (invocationObject != null)
            {
                invocationObject.Compile(context);
            }

            ParameterInfo[] args = methodInfo.GetParameters();
            if (args.Length != arguments.Count)
            {
                throw new Exception("Invalid method parameters count");
            }

            for (int i = 0; i < args.Length; ++i)
            {
                arguments[i].Compile(context);
                PrepareValueOnStack(context, args[i].ParameterType, arguments[i].itemType);
            }
            if (methodInfo.IsVirtual)
            {
                context.EmitCall(OpCodes.Callvirt, methodInfo);
            }
            else
            {
                context.EmitCall(OpCodes.Call, methodInfo);
            }
        }
开发者ID:ZixiangBoy,项目名称:FAS,代码行数:35,代码来源:CompilationHelper.cs

示例2: Main

		static int Main(string[] args)
		{
			if (args != null && args.Length == 1)
			{
				if (args[0].Equals("-w", StringComparison.InvariantCultureIgnoreCase) ||
				    args[0].Equals("-wait", StringComparison.InvariantCultureIgnoreCase))
					Console.ReadLine();
				else
					siteRoot = args[0];
			}
			if (siteRoot == null)
			{
				string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
				siteRoot = baseDirectory.Substring(0, baseDirectory.LastIndexOf("\\bin", StringComparison.InvariantCultureIgnoreCase));
			}
			Console.WriteLine("Compiling [" + siteRoot + "] ...");

			InitializeConfig();

			if (!Directory.Exists(siteRoot))
			{
				PrintHelpMessage(string.Format("The path '{0}' does not exist", siteRoot));
				Console.ReadLine();
				return -1;
			}

			OfflineCompiler compiler;
			try
			{
				ICompilationContext compilationContext = new CompilationContext(
					new DirectoryInfo(Path.Combine(siteRoot, "bin")),
					new DirectoryInfo(siteRoot),
					new DirectoryInfo(Path.Combine(siteRoot, "views")),
					new DirectoryInfo(options.CompilerOptions.TemporarySourceFilesDirectory));

				compiler = new OfflineCompiler(
					new CSharpCodeProviderAdapterFactory(),
					new PreProcessor(), 
					compilationContext, options.CompilerOptions, new DefaultFileSystemAdapter());
			}
			catch
			{
				PrintHelpMessage("Could not start the compiler.");
				return -2;
			}

			try
			{
				string path = compiler.Execute();

				Console.WriteLine("[{0}] compiled into [{1}].", siteRoot, path);
				return 0;
			}
			catch (Exception ex)
			{
				PrintHelpMessage("Could not compile." + Environment.NewLine + ex);
				return -3;
			}

		}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:60,代码来源:Program.cs

示例3: CompileDirectory

        private void CompileDirectory(CompilationContext context, string viewDirectory)
        {
            // Prevent processing of the same directories multiple times (sligh performance optimization,
            // as the build manager second call to compile a view is essentially a "no-op".
            if (context.ProcessedDirectories.Contains(viewDirectory))
                return;
            context.ProcessedDirectories.Add(viewDirectory);

            var stopwatch = new Stopwatch();
            stopwatch.Start();
            try {
                var firstFile = _virtualPathProvider
                    .ListFiles(viewDirectory)
                    .Where(f => context.FileExtensionsToCompile.Any(e => f.EndsWith(e, StringComparison.OrdinalIgnoreCase)))
                    .FirstOrDefault();

                if (firstFile != null)
                    BuildManager.GetCompiledAssembly(firstFile);
            }
            catch(Exception e) {
                // Some views might not compile, this is ok and harmless in this
                // context of pre-compiling views.
                Logger.Information(e, "Compilation of directory '{0}' skipped", viewDirectory);
            }
            stopwatch.Stop();
            Logger.Information("Directory '{0}' compiled in {1} msec", viewDirectory, stopwatch.ElapsedMilliseconds);
        }
开发者ID:gokhandisikara,项目名称:Coevery-Framework,代码行数:27,代码来源:ViewsBackgroundCompilation.cs

示例4: Compile

 public void Compile(CompilationContext context)
 {
     targetObject.Compile(context);
     value.Compile(context);
     CompilationHelper.PrepareValueOnStack(context, fieldInfo.FieldType, value.itemType);
     context.Emit(OpCodes.Stfld, fieldInfo);
 }
开发者ID:antonovicha,项目名称:EmitMapperRedux,代码行数:7,代码来源:AstWriteField.cs

示例5: BuildAst

        internal override IEnumerable<AssociativeNode> BuildAst(List<AssociativeNode> inputAstNodes, CompilationContext context)
        {
            var rhs = AstFactory.BuildStringNode(Value);
            var assignment = AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), rhs);

            return new[] { assignment };
        }
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:7,代码来源:BaseTypes.cs

示例6: Compile

 public override void Compile(CompilationContext context)
 {
     CompilationHelper.CheckIsValue(itemType);
     array.Compile(context);
     context.Emit(OpCodes.Ldc_I4, index);
     context.Emit(OpCodes.Ldelema, itemType);
 }
开发者ID:ZixiangBoy,项目名称:FAS,代码行数:7,代码来源:AstReadArrayItem.cs

示例7: Execute

        /// <summary>
        /// Executes the translation process.
        /// </summary>
        /// <param name="context">The compilation context.</param>
        public void Execute(CompilationContext context)
        {
            if (context == null || context.Model == null)
                return;

            if (context.OutputStream == null || !context.OutputStream.CanWrite)
                throw new CompilationException("The translation output stream is null or not writable.");

            var translationCtx = new TranslationContext();
            translationCtx.OutputStream = context.OutputStream;

            // write enum declarations
            var enumTranslator = new EnumTranslator();
            foreach (var item in context.Model.Enums)
                enumTranslator.Translate(item, translationCtx);

            // write class declarations
            var classTranslator = new ClassTranslator();
            foreach (var item in ClassSorter.Sort(context.Model.Classes))
                classTranslator.Translate(item, translationCtx);

            // write global statements
            if (context.Model.GlobalStatements.Any())
            {
                translationCtx.WriteLine();
                foreach (var item in context.Model.GlobalStatements)
                    translationCtx.WriteModel(item);
            }
        }
开发者ID:JimmyJune,项目名称:blade,代码行数:33,代码来源:TranslationProcess.cs

示例8: Compile

        public void Compile(CompilationContext context)
        {
            AstBuildHelper.CallMethod(
				_setMethod, 
				_targetObject,
                new List<IAstStackItem>() { _value }
			).Compile(context);
        }
开发者ID:antonovicha,项目名称:EmitMapperRedux,代码行数:8,代码来源:AstWriteProperty.cs

示例9: Compile

 public void Compile(CompilationContext context)
 {
     if(localType.IsValueType)
     {
         context.Emit(OpCodes.Ldloca, localIndex);
         context.Emit(OpCodes.Initobj, localType);
     }
 }
开发者ID:ZixiangBoy,项目名称:FAS,代码行数:8,代码来源:AstInitializeLocalVariable.cs

示例10: Execute

        /// <summary>
        /// Executes the model validation process.
        /// </summary>
        /// <param name="context">The compilation context.</param>
        public void Execute(CompilationContext context)
        {
            var provider = new ImportProvider<IModelValidator>();

            foreach (var validator in provider.GetImports())
            {
                validator.Validate(context.Model, context.Result);
            }
        }
开发者ID:JimmyJune,项目名称:blade,代码行数:13,代码来源:ModelValidationProcess.cs

示例11: Compile

 public void Compile(CompilationContext context)
 {
     var endBlock = context.ilGenerator.BeginExceptionBlock();
     protectedBlock.Compile(context);
     context.ilGenerator.BeginCatchBlock(exceptionType);
     context.ilGenerator.Emit(OpCodes.Stloc, eceptionVariable);
     handlerBlock.Compile(context);
     context.ilGenerator.EndExceptionBlock();
 }
开发者ID:ZixiangBoy,项目名称:FAS,代码行数:9,代码来源:AstExceptionHandlingBlock.cs

示例12: Compile

        public void Compile(CompilationContext context)
        {
			new AstCallMethod(methodInfo, invocationObject, arguments).Compile(context);

            if (methodInfo.ReturnType != typeof(void))
            {
                context.Emit(OpCodes.Pop);
            }
        }
开发者ID:NetUtil,项目名称:Util,代码行数:9,代码来源:AstCallMethodVoid.cs

示例13: Compile

 public virtual void Compile(CompilationContext context)
 {
     AstReadArgument arg = new AstReadArgument()
                               {
                                   argumentIndex = 0,
                                   argumentType = thisType
                               };
     arg.Compile(context);
 }
开发者ID:antonovicha,项目名称:EmitMapperRedux,代码行数:9,代码来源:AstReadThis.cs

示例14: Compile

        public void Compile(CompilationContext context)
        {
            value.Compile(context);

            if (value.itemType.IsValueType)
            {
                context.Emit(OpCodes.Box, itemType);
            }
        }
开发者ID:ZixiangBoy,项目名称:FAS,代码行数:9,代码来源:AstBox.cs

示例15: IncrementalHighlighter

 public IncrementalHighlighter(Highlighter highlighter)
 {
     highlightingParser = new HighlightingParser(highlighter);
     var context = new CompilationContext();
     tokenizer = context.CreateTokenizer(
         token => highlightingParser.OnToken(token),
         () => highlightingParser.OnDone(),
         () => {}
     );
 }
开发者ID:lunchtimemama,项目名称:Stinky,代码行数:10,代码来源:IncrementalHighlighter.cs


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