Inheritance: NVelocity.VelocityContext
        public void CanReplaceSimpleValueUsingExpressions()
        {
            var t = new SimpleTemplate("asd${asd}asd$qwe");

            t.SetMany(asd => 123, qwe => 456);

            t.ToString().Should().Be("asd123asd456");
        }
        public void CanReplaceSimpleValueUsingAnonymousObject()
        {
            var t = new SimpleTemplate("asd${asd}asd$qwe");

            t.SetMany(new { asd = 123, qwe = 456 });

            t.ToString().Should().Be("asd123asd456");
        }
示例#3
0
 protected SimpleTemplate GetTemplate(string content, string className)
 {
     var conventions = Options.Do.Conventions;
     var template = new SimpleTemplate(content);
     template["opt"] = Options.Do;
     template["classname"] = className;
     template["classname_2"] = conventions.Pluralize(className);
     return template;
 }
        public void Run()
        {
            var types = GetTypes();

            using (var project = Options.Do.Model.Project)
            {
                foreach (var type in types)
                {
                    var template = new SimpleTemplate(Templates.AutoService);
                    template["interface"] = "I" + type.Type.GetRealClassName();
                    template["service"] = type;
                    template["opt"] = Options.Do;

                    project.AddNewCompile(FilePath(type.Type.GetRealClassName()), template.ToString());
                }
            }
        }
示例#5
0
        public void Execute()
        {
            var timestamp = DateTime.Now.ToString("yyyyMMddHHmmss");
            var filename = string.Format("{0}_{1}.cs", timestamp, Name ?? "Untitled");

            var template = new SimpleTemplate(Templates.NewMigration);
            template["timestamp"] = timestamp;
            template["opt"] = Options.Do;

            using (var project = Options.Do.Database.Project)
            {
                project.AddNewCompile(filename, template.ToString());

                if (OpenIt)
                    Process.Start(project.GetFullPath(filename));
            }
        }
示例#6
0
        public void Run()
        {
            var types = GetTypes();

            using (var project = Options.Do.Model.Project)
            {
                foreach (var type in types)
                {
                    var entity = type.Type.GetTypeArgumentsFor(typeof(IEntityService<>)).FirstOrDefault();
                    var template = new SimpleTemplate(Templates.AutoDomain);
                    template["entity"] = entity;
                    template["service"] = type;
                    template["opt"] = Options.Do;

                    project.AddNewCompile(FilePath(entity.Name), template.ToString());
                }
            }
        }
 public void CanReplaceSimpleValueUsingToString()
 {
     var t = new SimpleTemplate("asd${asd}asd");
     t["asd"] = 123;
     t.ToString().Should().Be("asd123asd");
 }
 public void CanReplaceSimpleValue()
 {
     var t = new SimpleTemplate("asd${asd}asd");
     t["asd"] = 123;
     t.Render().Should().Be("asd123asd");
 }