Beispiel #1
0
        public void TestLineFeedVariableSubstitution()
        {
            var variable = new LineFeedVariable();
            var template = variable.ToString(null);

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            var str = engine.ToString();

            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            Assert.AreEqual("\n", str);
        }
Beispiel #2
0
        public void TestDateTimeVariableSubstitution()
        {
            var variable = new DateTimeVariable();
            var template = variable.ToString(null);

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            var str = engine.ToString();

            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            DateTime.Parse(str);
        }
Beispiel #3
0
        public void TestSeparatorVariableArgVolumeSubstitution()
        {
            var variable = new SeparatorVariable();
            var template = variable.ToString(SeparatorVariable.ArgVolume);

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            var str = engine.ToString();

            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            Assert.AreEqual(Path.VolumeSeparatorChar.ToString(), str);
        }
Beispiel #4
0
        public void TestSpaceVariableWithArgSubstitution()
        {
            var variable = new SpaceVariable();
            int count    = 3;
            var template = variable.ToString(count.ToString());

            var engine = new TemplateEngine(template);

            engine.AddVariable(variable);

            var str = engine.ToString();

            Console.WriteLine(string.Format("SUBSTITUTED STRING: '{0}'", str));

            Assert.AreEqual(new string(' ', count), str);
        }
        public override string EvaluateValueFor(TemplateEngine ctx, string arg)
        {
            switch (arg.ToLower())
            {
            case ArgDirectory:
                return(Path.DirectorySeparatorChar.ToString());

            case ArgPath:
                return(Path.PathSeparator.ToString());

            case ArgVolume:
                return(Path.VolumeSeparatorChar.ToString());

            default:
                throw new ArgumentOutOfRangeException(Id, arg, "Unknown argument");
            }
        }
Beispiel #6
0
        public override string EvaluateValueFor(TemplateEngine ctx, string arg)
        {
            var datetime = DateTime.Now.ToUniversalTime();

            return(string.IsNullOrEmpty(arg) ? datetime.ToString() : datetime.ToString(arg));
        }
 public override string EvaluateValueFor(TemplateEngine ctx, string arg)
 {
     return(Guid.NewGuid().ToString());
 }
 abstract public string EvaluateValueFor(TemplateEngine ctx, string arg);