public static void WriteExitLogging(ClassBuilder classBuilder, string methodSignature) { var methodName = RegexMethodName.Match(methodSignature).Groups["methodName"].Value; classBuilder.EndNest(); classBuilder.BeginNest("finally"); classBuilder.AppendLine("stopwatch.Stop();"); classBuilder.AppendLine($"this._logger.LogTrace($\"Exiting {methodName}\\t\\t{{stopwatch.ElapsedMilliseconds}}\");"); classBuilder.EndNest(); }
private string Write(EnumeratedDataType type) { CodeWriterUtils.WriteFileHeader(classBuilder); WriteUsings(); classBuilder.BeginNest($"namespace {codeWriterSettings.Namespace}"); classBuilder.BeginNest($"public enum {type.NetDataType}"); WriteEnumerationValues(type); classBuilder.EndNest(); classBuilder.EndNest(); return(classBuilder.ToString()); }
protected virtual void Dispose(bool disposing) { if (disposing) { //this isn't actually a managed disposal resource _classBuilder.EndNest(); } }
/// <summary> /// Writes the C# code of the table /// </summary> /// <returns></returns> public string Write() { var codeTarget = _codeWriterSettings.CodeTarget; _dataAnnotationWriter = new DataAnnotationWriter(IsEntityFramework(), _codeWriterSettings); var className = _table.NetName; if (string.IsNullOrEmpty(className) && _table.DatabaseSchema != null) { PrepareSchemaNames.Prepare(_table.DatabaseSchema, _codeWriterSettings.Namer); className = _table.NetName; } _dataTypeWriter.CodeTarget = codeTarget; _inheritanceTable = _table.FindInheritanceTable(); WriteNamespaces(); _codeWriterSettings.CodeInserter.WriteNamespaces(_table, _cb); if (!string.IsNullOrEmpty(_codeWriterSettings.Namespace)) { _cb.BeginNest("namespace " + _codeWriterSettings.Namespace); } if (codeTarget == CodeTarget.PocoRiaServices) { WriteRiaClass(className); } else { var tableOrView = _table is DatabaseView ? "view" : "table"; var comment = "Class representing " + _table.Name + " " + tableOrView; var classDefinition = "public class " + className; if (_inheritanceTable != null) { classDefinition += " : " + _inheritanceTable.NetName; } _codeWriterSettings.CodeInserter.WriteTableAnnotations(_table, _cb); using (_cb.BeginNest(classDefinition, comment)) { WriteClassMembers(className); } } if (_table.HasCompositeKey && _inheritanceTable == null) { WriteCompositeKeyClass(className); } if (!string.IsNullOrEmpty(_codeWriterSettings.Namespace)) { _cb.EndNest(); } return(_cb.ToString()); }
private string Write() { if (string.IsNullOrEmpty(table.NetName) && table.DatabaseSchema != null) { PrepareSchemaNames.Prepare(table.DatabaseSchema, codeWriterSettings.Namer); } CodeWriterUtils.WriteFileHeader(classBuilder); WriteUsings(); CodeWriterUtils.BeginNestNamespace(classBuilder, codeWriterSettings); var tableOrView = table is DatabaseView ? "view" : "table"; var comment = $"Interface providing repository CRUD operations for the {table.Name} {tableOrView}"; var interfaceDefinition = $"public partial interface {CodeWriterUtils.GetRepositoryInterfaceName(table)}"; classBuilder.AppendXmlSummary(comment); classBuilder.BeginNest(interfaceDefinition); WriteInterfaceMembers(); classBuilder.EndNest(); // interface classBuilder.EndNest(); // namespace return(classBuilder.ToString()); }
public string Write() { if (string.IsNullOrEmpty(table.NetName) && table.DatabaseSchema != null) { PrepareSchemaNames.Prepare(table.DatabaseSchema, codeWriterSettings.Namer); } CodeWriterUtils.WriteFileHeader(classBuilder); WriteUsings(); CodeWriterUtils.BeginNestNamespace(classBuilder, codeWriterSettings); classBuilder.AppendXmlSummary($"Class representing the {table.Name} table."); classBuilder.AppendLine($"[Table(\"\\\"{table.Name}\\\"\")]"); using (classBuilder.BeginNest($"public partial class {table.NetName}")) { WriteAllMembers(); } classBuilder.EndNest(); return(classBuilder.ToString()); }
/// <summary> /// Writes the C# code of the table /// </summary> /// <returns></returns> public string Write() { var codeTarget = _codeWriterSettings.CodeTarget; _dataAnnotationWriter = new DataAnnotationWriter(IsEntityFramework(), _codeWriterSettings); var className = _table.NetName; if (string.IsNullOrEmpty(className) && _table.DatabaseSchema != null) { PrepareSchemaNames.Prepare(_table.DatabaseSchema); className = _table.NetName; } _dataTypeWriter.CodeTarget = codeTarget; WriteNamespaces(); if (!string.IsNullOrEmpty(_codeWriterSettings.Namespace)) { _cb.BeginNest("namespace " + _codeWriterSettings.Namespace); } if (codeTarget == CodeTarget.PocoRiaServices) { WriteRiaClass(className); } else { var tableOrView = _table is DatabaseView ? "view" : "table"; using (_cb.BeginNest("public class " + className, "Class representing " + _table.Name + " " + tableOrView)) { WriteClassMembers(className); } } if (_table.HasCompositeKey) { WriteCompositeKeyClass(className); } if (!string.IsNullOrEmpty(_codeWriterSettings.Namespace)) { _cb.EndNest(); } return(_cb.ToString()); }