示例#1
0
 public T4ClassForm()
 {
     source = Context.ContentDatabase;
     if (!source.Name.Contains("core"))
     {
         _configT4Class = ConfigManager.GetT4ClassConfig();
     }
 }
        public static string RunT4Template(this List <TemplateFieldItem> templateFields, T4ClassConfig configT4Class,
                                           TemplateItem currentTreeviewItem)
        {
            var template = new T4TemplateClass();
            var session  = new TextTemplatingSession();

            session["namespaceName"] = !configT4Class.DefaultNamespace.Any()
                                   ? T4ClassConsts.Texts.DefaultNamespaceText
                                   : configT4Class.DefaultNamespace;
            session["usingNamespaces"] = configT4Class.UsingStatement;
            session["classType"]       = configT4Class.ClassType.GetClassTypeName();
            session["classFields"]     = templateFields;
            session["className"]       = currentTreeviewItem.Name.Replace(" ", string.Empty);
            template.Session           = session;
            template.Initialize();
            string textTemplateOutput = template.TransformText();

            return(textTemplateOutput.Remove(0, 15));
        }