Mercurial > pub > bltoolkit
view Source/Templates/Renamer.ttinclude @ 6:11b6da379593
Исправлена странная ошибка при использовании OfType<...>().Where(...)
author | cin |
---|---|
date | Mon, 05 Dec 2016 05:50:52 +0300 |
parents | f990fcb411a9 |
children |
line wrap: on
line source
<# //Rename tables and fields according to the .NET style, i.e. "booking_number" to "BookingNumber" { var fieldsPrevBeforeGenerateModel = BeforeGenerateModel; Func<string, string> getNetStyleName = (string name) => { if(!string.IsNullOrEmpty(name)) { var chars = new System.Text.StringBuilder(name); for(int i=1; i<chars.Length; i++) if(chars[i-1]=='_') chars[i]=char.ToUpper(chars[i]); chars.Replace("_", null); chars[0]=char.ToUpper(chars[0]); name = chars.ToString(); } return name; }; BeforeGenerateModel = tt => { fieldsPrevBeforeGenerateModel(tt); Dictionary<string, string> remapper = new Dictionary<string, string>() { { "Exception", "Exceptions" } }; foreach (var t in Tables.Values) { t.ClassName = getNetStyleName(t.ClassName); string className; if(remapper.TryGetValue(t.ClassName, out className)) t.ClassName = className; foreach (var c in t.Columns.Values) c.MemberName = getNetStyleName(c.MemberName); } }; } #>