随笔-113  评论-60  文章-0  trackbacks-3
  2006年10月10日
private XmlElement AddFileNode(XmlElement rootNode, string filename)
{
    XmlElement node 
= docOutput.CreateElement("File");
    Trace.WriteLine(
string.Format("\t*File Created: {0}", filename));    
    PerformStep();
    
    XmlAttribute attName 
= docOutput.CreateAttribute("name");
    attName.Value 
= filename;
    node.Attributes.Append(attName);
    XmlAttribute attTime 
= docOutput.CreateAttribute("startTime");
    attTime.Value 
= DateTime.Now.ToFileTime().ToString();
    node.Attributes.Append(attTime);
        
    rootNode.AppendChild(node);
    
return node;
}



    AddFileNode(commonNode, 
"EntityKeyBaseCore.generated.cs");
    
this.GetTemplate("EntityKeyBaseCore.generated.cst").SetProperty("BLLNameSpace", BLLNameSpace);
    
this.RenderToFile("EntityKeyBaseCore.generated.cst", rootPathBLL + "\\EntityKeyBaseCore.generated.cs"true);


    if (!File.Exists(rootPathBLL + "\\EntityKeyBase.cs"))
    
{
        AddFileNode(commonNode, 
"EntityKeyBase.cs");
        
this.GetTemplate("EntityKeyBase.cst").SetProperty("BLLNameSpace", BLLNameSpace);
        
this.RenderToFile("EntityKeyBase.cst", rootPathBLL + "\\EntityKeyBase.cs"true);
    }

                

public void RenderToFile(string templateName, string path, bool overwrite)
{
    
this._CurrentFileName = path;
    
this.GetTemplate(templateName).RenderToFile(path, overwrite);
    
this._counter++;
}



public CodeTemplate GetTemplate(string templateType)
{
    
return (CodeSmith.Engine.CodeTemplate)_CodeTemplates[templateType];
}


public MoM.Templates.CommonSqlCode GetTemplateBase(string templateType)
{
    
return (MoM.Templates.CommonSqlCode) GetTemplate(templateType);
}

posted @ 2006-10-10 15:42 灵风 阅读(76) 评论(0) 编辑

 

private CodesmithVersion GetCodesmithVersion()
{
    
try
    
{
        
string version = typeof(CodeTemplate).Assembly.GetName().Version.ToString();
        
if(version != null)
        
{
            
if (version.IndexOf("3.2">= 0)
                
return CodesmithVersion.Codesmith32;
            
else if (version.IndexOf("3.1">=0)
                
return CodesmithVersion.Codesmith31;
            
else if (version.IndexOf("3.0">=0)
                
return CodesmithVersion.Codesmith30;
            
else if (version.IndexOf("2.6">= 0)
                
return CodesmithVersion.Codesmith26;
        }

    }

    
catch
    
{
        
//could not discover version info.    
    }

    
    
return CodesmithVersion.Unknown;
}
posted @ 2006-10-10 15:39 灵风 阅读(61) 评论(0) 编辑