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


C# Template.Replace方法代码示例

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


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

示例1: RunTest

 public static void RunTest(string template, string expected, string errMsg)
 {
     string actual = new Template(template).Render(globals);
     actual = actual.Replace("{", "{{").Replace("}", "}}");
     Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
         Environment.NewLine, errMsg, template, actual, expected);
 }
开发者ID:kooboo-jifeng,项目名称:SharpTAL,代码行数:7,代码来源:TalReplaceTests.cs

示例2: RunTest

 public static void RunTest(string template, string expected, string errMsg)
 {
     globals = new Dictionary<string, object>();
     globals.Add("name", "world");
     string actual = new Template(template).Render(globals);
     actual = actual.Replace("{", "{").Replace("}", "}");
     Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
         Environment.NewLine, errMsg, template, actual, expected);
 }
开发者ID:kooboo-jifeng,项目名称:SharpTAL,代码行数:9,代码来源:TextTemplateTests.cs

示例3: RunTest

 public static void RunTest(string template, string expected, string errMsg)
 {
     List<Assembly> referencedAssemblies = new List<Assembly>()
     {
         typeof(TalContentTests).Assembly
     };
     string actual = new Template(template, referencedAssemblies).Render(globals);
     actual = actual.Replace("{", "{{").Replace("}", "}}");
     Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
         Environment.NewLine, errMsg, template, actual, expected);
 }
开发者ID:kooboo-jifeng,项目名称:SharpTAL,代码行数:11,代码来源:TalContentTests.cs

示例4: RunTest

 public static void RunTest(string template, string expected, string errMsg)
 {
     globals = new Dictionary<string, object>();
     globals.Add("top", "Hello from the top");
     globals.Add("helloFunc", new TestFuncDelegate(simpleFunction));
     globals.Add("helloFunction", new TestFuncDelegate2(helloFunction));
     globals.Add("myList", new List<int>() { 1, 2, 3, 4, 5, 6 });
     globals.Add("testing", "testing");
     globals.Add("map", new Dictionary<string, object>() { { "test", "maptest" } });
     globals.Add("data", new Dictionary<string, object>() { { "one", 1 }, { "zero", 0 } });
     string actual = new Template(template).Render(globals);
     actual = actual.Replace("{", "{{").Replace("}", "}}");
     Assert.AreEqual(expected, actual, "{1} - {0}template: {2}{0}actual: {3}{0}expected: {4}",
         Environment.NewLine, errMsg, template, actual, expected);
 }
开发者ID:kooboo-jifeng,项目名称:SharpTAL,代码行数:15,代码来源:TalesCSharpPathTests.cs

示例5: Main

        private static int Main(string[] args)
        {
            var myName = Environment.GetCommandLineArgs()[0];
            myName = Path.GetFileNameWithoutExtension(string.IsNullOrWhiteSpace(myName)
                   ? System.Reflection.Assembly.GetEntryAssembly().Location
                   : myName);

            if (args.Length != 2)
            {
                Console.Write("Usage: " + myName + @" <template> <target>
              <template> Path to the template file with [GITHASH] and [REVNO]
              <target>   Path to the target file (AssemblyInfo.cs)
            ");
                return 1;
            }

            Console.WriteLine("Updating assembly info...");
            var workingFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
            var templateFile = args[0];
            var targetFile = args[1];
            var template = new Template(templateFile);

            var clrHash = new CommandLineRunner();
            var clrTags = new CommandLineRunner();
            var gitPath = GetGitPath();
            string exceptionMessage;
            if (clrHash.RunCommandAndGetOutput(gitPath, "rev-parse --verify HEAD", workingFolder) &&
                clrTags.RunCommandAndGetOutput(gitPath, "describe --tags", workingFolder))
            {
                try
                {
                    template.Replace("[GITHASH]", clrHash.Result);
                    if (clrTags.Result.IndexOf('-') < 0)
                        clrTags.Result += "-0";
                    template.Replace("[REVNO]", clrTags.Result.Split('-')[1]);
                    template.Save(targetFile);
                    return 0;
                }
                catch (Exception ex)
                {
                    exceptionMessage = ex.Message;
                }
            }
            else
            {
                try
                {
                    // allow to compile without git
                    Console.WriteLine("WARNING: Could not run Git - build number will be 9999!");
                    template.Replace("[GITHASH]", string.Empty);
                    template.Replace("[REVNO]", "9999");
                    template.Save(targetFile);
                    return 0;
                }
                catch (Exception ex)
                {
                    exceptionMessage = ex.Message;
                }
            }
            Console.WriteLine(myName + ": Could not update AssemblyInfo: " + exceptionMessage);
            Console.WriteLine(" - Git folder: " + workingFolder);
            Console.WriteLine(" - Template: " + templateFile);
            Console.WriteLine(" - Target: " + targetFile);
            return 1;
        }
开发者ID:aisam97,项目名称:subtitleedit,代码行数:65,代码来源:Program.cs


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