public void Add(HbmCache cache, bool body = false) { if (cache == null) { return; } string region = ""; if (cache.region != null) { region = string.Format(".Region(\"{0}\")", cache.region); } string cacheStr = string.Format("Cache.{0}(){1}", cache.usage == HbmCacheUsage.NonstrictReadWrite? "NonStrictReadWrite" : cache.usage.ToString(), region); if (body) { cacheStr = cacheStr + ";"; } else { cacheStr = "." + cacheStr; } _builder.AddLine(cacheStr); }
public static string Convert(string classMapName, MappedClassInfo classInfo, string nameSpace) { CodeFileBuilder builder = new CodeFileBuilder(); ClassMapBody bodyBuilder = new ClassMapBody(builder); builder.AddUsing("System"); builder.AddUsing("FluentNHibernate.Mapping"); builder.StartNamespace(nameSpace); { builder.StartClass(classMapName + ": ClassMap<" + classInfo.ClassName + ">", false, false); { builder.StartMethod("public " + classMapName + "()"); { if (!String.IsNullOrEmpty(classInfo.TableName)) { builder.AddLine(FluentNHibernateNames.Table + "(\"" + classInfo.TableName + "\");"); } foreach (var info in classInfo.Properties) { bodyBuilder.Add("", info); } } builder.EndBlock(); } builder.EndBlock(); } builder.EndBlock(); return builder.ToString(); }
public static string Convert(string classMapName, MappedClassInfo classInfo, string nameSpace) { CodeFileBuilder builder = new CodeFileBuilder(); builder.AddUsing("System"); builder.AddUsing("FluentNHibernate.Mapping"); builder.StartNamespace(nameSpace); { builder.StartClass(classMapName + ": ClassMap<" + classInfo.ClassName + ">", false, false); { builder.StartMethod("public " + classMapName + "()"); { if (!String.IsNullOrEmpty(classInfo.TableName)) { builder.AddLine(FluentNHibernateNames.Table + "(\"" + classInfo.TableName + "\");"); } new CacheBuilder(builder).Add(classInfo.Cache, true); if (!classInfo.Mutable) { builder.AddLine("ReadOnly();"); } ClassMapBody bodyBuilder = new ClassMapBody(builder); foreach (var info in classInfo.Properties) { bodyBuilder.Add("", info); } } builder.EndBlock(); } builder.EndBlock(); } builder.EndBlock(); return(builder.ToString()); }
private static void EndMap(CodeFileBuilder builder) { builder.AddLine(";"); builder.Unindent(); }
private static void EndMap(CodeFileBuilder builder) { builder.AddLine(";"); builder.Unindent(); }