动软代码生成器 常用函数
生活随笔
收集整理的這篇文章主要介紹了
动软代码生成器 常用函数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?動軟代碼生成器在自動化生成.Net代碼方面功能非常強大。在實際使用中,我也經常使用它的自定義模板功能,生成Js、html、php、java等代碼。其模板里的函數與.net函數并不完全一致,現把模板常用代碼寫在這里,以方便查詢使用。實際使用中每個項目要按自己框架情況進行定義。
<#@ template language="c#" HostSpecific="True" #> <#@ output extension= ".js" #> <#TableHost host = (TableHost)(Host); string DbParaHead=host.DbParaHead;string DbParaDbType=host.DbParaDbType;string preParameter=host.preParameter;string ModelSpace = host.NameSpace+".Model."+ host.GetModelClass(host.TableName);string TableName = host.GetModelClass(host.TableName);string ModuleName = TableName;string ActionName = TableName;if(TableName.IndexOf('_') > -1){string[] tempArray=TableName.Split('_');ModuleName=tempArray[0];ActionName=tempArray[1];if(tempArray.Length==3)ActionName += "_"+tempArray[2];} ColumnInfo identityKey=host.IdentityKey;string returnValue = "void";if (identityKey!=null){ returnValue = CodeCommon.DbTypeToCS(identityKey.TypeName); }else if(2>1){}else{identityKey=host.Fieldlist[0];} #>- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
字符串函數
String Abc=actionArr[2].Substring(0,1).ToUpper() + actionArr[2].Substring(1,actionArr[2].Length-1); "CABc".ToLower()- 1
- 2
字段遍歷
<# for(int i=0;i< host.Fieldlist.Count;i++){ColumnInfo c = host.Fieldlist[i];//c.ColumnName 字段名稱//CodeCommon.DbTypeToCS(c.TypeName) 字段類型//c.Length 字段長度String type=CodeCommon.DbTypeToCS(c.TypeName);if(type=="DateTime")type="String";else if(type=="int")type="Integer";else if(type=="string")type="String";else if(type=="decimal")type="Float"; #> <#}#>- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
字段類型枚舉:
CodeCommon.DbTypeToCS(c.TypeName)
- DateTime
- int
- Boolean
- string
- decimal
總結
以上是生活随笔為你收集整理的动软代码生成器 常用函数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 移动端禁止视频自动全屏播放
- 下一篇: vuex-persistedstate