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


C# Processor.ExecuteProcessors方法代码示例

本文整理汇总了C#中Processor.ExecuteProcessors方法的典型用法代码示例。如果您正苦于以下问题:C# Processor.ExecuteProcessors方法的具体用法?C# Processor.ExecuteProcessors怎么用?C# Processor.ExecuteProcessors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Processor的用法示例。


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

示例1: TestFormatterWithConvertersAndOptions

        public void TestFormatterWithConvertersAndOptions()
        {
            var processor = new Processor();
            processor.AddDomain("TestDomain");
            processor.GetDomain("TestDomain").Add("TestKey", "This is a test.");

            var formatStr = @"<@
            <% Import dll=""NasuTek.Preprocessor.ProcessingLibrary.Tests.dll"" %>
            <% Import namespace=""NasuTek.Preprocessor.ProcessingLibrary.Tests"" %>
            @>
            ##TestDomain.TestKey(TestConverter[Demo=""Demo Testing "",Demo2=""Is Awesome.""])##";

            processor.ExecuteProcessors(formatStr);

            var formatOut = processor.FormatString(formatStr);

            Assert.AreEqual("Demo Testing Is Awesome.", formatOut);
        }
开发者ID:NasuTek,项目名称:NasuTek-Preprocessor,代码行数:18,代码来源:ProcessorTests.cs

示例2: TestProcessors

        public void TestProcessors()
        {
            var processor = new Processor();

            var processorStr = @"<% Import dll=""NasuTek.Preprocessor.ProcessingLibrary.Tests.dll"" %>
            <% Import namespace=""NasuTek.Preprocessor.ProcessingLibrary.Tests"" %>
            <% TestProcessor %>";

            processor.ExecuteProcessors(processorStr);

            Assert.AreEqual("DEMO", processor.Storage["TestObject"]);
        }
开发者ID:NasuTek,项目名称:NasuTek-Preprocessor,代码行数:12,代码来源:ProcessorTests.cs

示例3: Main

        static void Main(string[] args)
        {
            Console.Error.WriteLine("NasuTek Preprocessor Version 1.0");
            Console.Error.WriteLine("\tCopyright (C) 2013 NasuTek Enterprises");
            Console.Error.WriteLine();

            var inFiles = new List<string>();
            var outFiles = new List<string>();
            var processorDefinitionFile = new List<string>();
            var parameters = new List<string>();

            string showHelp = null;

            if (args.Length < 1)
                showHelp = "";

            var optionSet = new OptionSet {
                { "i|InFile=", "The filename to preprocess. Use STDIN to use standard input.", inFiles.Add },
                { "o|OutFile=", "The filename to write the processed file to. Use STDOUT to use standard output.", outFiles.Add },
                { "P|ProcessorDefinitionFile=", "The filename to preprocess. Use STDIN to use standard input.", processorDefinitionFile.Add },
                { "p|Parameter=", "Set a parameter for a processor.", parameters.Add },
                { "?|h|Help", "Shows Help", v=> showHelp = v },
            };

            try
            {
                optionSet.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Error.Write("NasuTek.Preprocessor: ");
                Console.Error.WriteLine(e.Message);
                Console.Error.WriteLine("Try `NasuTek.Preprocessor /Help' for more information.");
                return;
            }

            if (showHelp != null)
            {
                Show_Help(optionSet);
                return;
            }

            #if !DEBUG
            try
            {
            #endif
            foreach (var inFileName in inFiles)
            {
                var processor = new Processor();
                foreach (var v in parameters)
                {
                    var splValComma = v.Split(',');
                    var splValEqual = splValComma[1].Split('=');

                    processor.SetParameter(splValComma[0], splValEqual[0], splValEqual[1]);
                }

                var input = "";

                if (inFileName != "STDIN")
                    input = File.ReadAllText(inFileName);
                else
                {
                    try
                    {
            #pragma warning disable 168
                        var tmp = Console.KeyAvailable;
            #pragma warning restore 168
                        var readLine = "";
                        while (readLine != "__EOF__")
                        {
                            readLine = Console.ReadLine();
                            if (readLine != "__EOF__")
                                input += readLine + Environment.NewLine;
                        }
                    }
                    catch (InvalidOperationException)
                    {
                        input = Console.In.ReadToEnd();
                    }
                }

                foreach (var processorDef in processorDefinitionFile)
                {
                    processor.ExecuteProcessors(File.ReadAllText(processorDef));
                }

                processor.ExecuteProcessors(input);
                input = processor.FormatString(input);

                if (outFiles[inFiles.IndexOf(inFileName)] != "STDOUT")
                    File.WriteAllText(outFiles[inFiles.IndexOf(inFileName)], input);
                else
                    Console.Write(input);
            }
            #if !DEBUG
            }
            catch (Exception e)
            {
                if (Debugger.IsAttached)
//.........这里部分代码省略.........
开发者ID:NasuTek,项目名称:NasuTek-Preprocessor,代码行数:101,代码来源:Program.cs


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