A quite big cleanup of DbMetal command-line interface: * renamed -dbLinqSchemaLoaderProvider to -schema-loader * renamed -databaseConnectionProvider to -dbconnection * renamed -sqlDialectType to -vendor * removed -renamesFile alias for -aliases * renamed -entityBase to -entitybase * changed the comma separated -entityAttributes to a repeatable single-item -entity-attribute * ditto for -memberAttributes and -member-attribute * renamed -generateEqualsAndHash to -generate-equals-hash * renamed -readlineAtExit to -readline * retouched a bit some parameter descriptions
Gzipped patch attached.
---
.../CodeTextGenerator/CodeGenerator.Class.cs | 8 ++--
.../CodeTextGenerator/CodeGenerator.cs | 8 ++--
src/DbMetal/Generator/Implementation/Processor.cs | 2 +-
src/DbMetal/Parameters.cs | 58 ++++++++++----------
4 files changed, 39 insertions(+), 37 deletions(-)
diff --git
a/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs
b/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs
index f09a35c..a0b41ee 100644
---
a/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs
+++
b/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.Class.cs
@@ -77,7 +77,7 @@ namespace DbMetal.Generator.Implementation.CodeTextGenerator
var tableAttribute = NewAttributeDefinition<TableAttribute>();
tableAttribute["Name"] = table.Name;
//using (WriteAttributes(writer,
context.Parameters.EntityExposedAttributes))
- using (WriteAttributes(writer, GetAttributeNames(context,
context.Parameters.EntityExposedAttributes)))
+ using (WriteAttributes(writer, GetAttributeNames(context,
context.Parameters.EntityAttributes)))
using (writer.WriteAttribute(tableAttribute))
using (writer.WriteClass(specifications,
table.Type.Name, entityBase,
context.Parameters.EntityInterfaces))
@@ -86,7 +86,7 @@ namespace DbMetal.Generator.Implementation.CodeTextGenerator
WriteCustomTypes(writer, table, schema, context);
WriteClassExtensibilityDeclarations(writer, table, context);
WriteClassProperties(writer, table, context);
- if (context.Parameters.GenerateEqualsAndHash)
+ if (context.Parameters.GenerateEqualsHash)
WriteClassEqualsAndHash(writer, table, context);
WriteClassChildren(writer, table, schema, context);
WriteClassParents(writer, table, schema, context);
@@ -269,7 +269,7 @@ namespace DbMetal.Generator.Implementation.CodeTextGenerator
/// <param name="context"></param>
/// <param name="attributes"></param>
/// <returns></returns>
- protected virtual string[] GetAttributeNames(GenerationContext
context, string[] attributes)
+ protected virtual string[] GetAttributeNames(GenerationContext
context, IEnumerable<string> attributes)
{
return (from a in attributes select GetName(a)).ToArray();
}
@@ -325,7 +325,7 @@ namespace DbMetal.Generator.Implementation.CodeTextGenerator
specifications |=
GetSpecificationDefinition(property.Modifier);
//using (WriteAttributes(writer,
context.Parameters.MemberExposedAttributes))
- using (WriteAttributes(writer, GetAttributeNames(context,
context.Parameters.MemberExposedAttributes)))
+ using (WriteAttributes(writer, GetAttributeNames(context,
context.Parameters.MemberAttributes)))
using
(writer.WriteAttribute(NewAttributeDefinition<DebuggerNonUserCodeAttribute>()))
using (writer.WriteAttribute(column))
using (writer.WriteProperty(specifications, property.Member,
GetTypeOrExtendedType(writer, property)))
diff --git
a/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
b/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
index bc3a7e2..206c6fd 100644
--- a/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
+++ b/src/DbMetal/Generator/Implementation/CodeTextGenerator/CodeGenerator.cs
@@ -177,12 +177,12 @@ namespace
DbMetal.Generator.Implementation.CodeTextGenerator
implementation.WriteHeader(writer, context);
// write namespaces for members attributes
- foreach (var memberExposedAttribute in
context.Parameters.MemberExposedAttributes)
- WriteUsingNamespace(writer,
GetNamespace(memberExposedAttribute));
+ foreach (var memberAttribute in
context.Parameters.MemberAttributes)
+ WriteUsingNamespace(writer, GetNamespace(memberAttribute));
// write namespaces for clases attributes
- foreach (var entityExposedAttribute in
context.Parameters.EntityExposedAttributes)
- WriteUsingNamespace(writer,
GetNamespace(entityExposedAttribute));
+ foreach (var entityAttribute in
context.Parameters.EntityAttributes)
+ WriteUsingNamespace(writer, GetNamespace(entityAttribute));
writer.WriteLine();
}
diff --git a/src/DbMetal/Generator/Implementation/Processor.cs
b/src/DbMetal/Generator/Implementation/Processor.cs
index 5a93e50..2c1ad96 100644
--- a/src/DbMetal/Generator/Implementation/Processor.cs
+++ b/src/DbMetal/Generator/Implementation/Processor.cs
@@ -98,7 +98,7 @@ namespace DbMetal.Generator.Implementation
ProcessSchema(parameters);
- if (parameters.ReadLineAtExit)
+ if (parameters.Readline)
{
// '-readLineAtExit' flag: useful when running from Visual
Studio
Console.ReadKey();
diff --git a/src/DbMetal/Parameters.cs b/src/DbMetal/Parameters.cs
index 1b4845e..458d6ac 100644
--- a/src/DbMetal/Parameters.cs
+++ b/src/DbMetal/Parameters.cs
@@ -135,20 +135,18 @@ namespace DbMetal
/// <summary>
/// Extra attributes to be implemented by class
/// </summary>
- public string EntityAttributes { get; set; }
- public string[] EntityExposedAttributes { get { return
GetArray(EntityAttributes); } }
+ public IList<string> EntityAttributes { get; set; }
/// <summary>
/// Extra attributes to be implemented by class
/// </summary>
- public string MemberAttributes { get; set; }
- public string[] MemberExposedAttributes { get { return
GetArray(MemberAttributes); } }
+ public IList<string> MemberAttributes { get; set; }
/// <summary>
/// base class from which all generated entities will inherit
/// SQLMetal compatible
/// </summary>
- public bool GenerateEqualsAndHash { get; set; }
+ public bool GenerateEqualsHash { get; set; }
/// <summary>
/// export stored procedures
@@ -182,7 +180,7 @@ namespace DbMetal
/// picrap comment: you may use the tool to write output to Visual
Studio output window instead of a console window
/// DbLinq specific
/// </summary>
- public bool ReadLineAtExit { get; set; }
+ public bool Readline { get; set; }
/// <summary>
/// specifies a provider (which here is a pair or ISchemaLoader and
IDbConnection implementors)
@@ -227,6 +225,8 @@ namespace DbMetal
Schema = true;
Culture = "en";
GenerateTypes = new List<string>();
+ EntityAttributes = new List<string>();
+ MemberAttributes = new List<string>();
GenerateTimestamps = true;
EntityInterfaces = new []{ "INotifyPropertyChanging",
"INotifyPropertyChanged" };
}
@@ -266,52 +266,54 @@ namespace DbMetal
{ "provider=",
"Specify {PROVIDER}. May be Ingres, MySql, Oracle,
OracleODP, PostgreSql or Sqlite.",
provider => Provider = provider },
- { "dbLinqSchemaLoaderProvider=",
- "Specify a custom ISchemaLoader implementation {TYPE}.",
+ { "schema-loader=",
+ "ISchemaLoader implementation {TYPE}.",
type => DbLinqSchemaLoaderProvider = type },
- { "databaseConnectionProvider=",
- "Specify a custom IDbConnection implementation {TYPE}.",
+ { "dbconnection=",
+ "IDbConnection implementation {TYPE}.",
type => DatabaseConnectionProvider = type },
- { "sqlDialectType=",
- "The IVendor implementation {TYPE}.",
+ { "vendor=",
+ "IVendor implementation {TYPE}.",
type => SqlDialectType = type },
{ "code=",
"Output as source code to {FILE}. Cannot be used with /dbml
option.",
file => Code = file },
{ "dbml=",
- "Output as dbml to {FILE}. Cannot be used with /map option.",
+ "Output as dbml to {FILE}.",
file => Dbml = file },
{ "language=",
"Language {NAME} for source code: C#, C#2 or VB "
+"(default: derived from extension on code file name).",
name => Language = name },
- { "aliases|renamesFile=",
+ { "aliases=",
"Use mapping {FILE}.",
file => Aliases = file },
{ "schema",
- "Generate schema in code files (default='true').",
+ "Generate schema in code files (default: enabled).",
(bool v) => Schema = v },
{ "namespace=",
"Namespace {NAME} of generated code (default: no
namespace).",
name => Namespace = name },
- { "entityBase=",
+ { "entitybase=",
"Base {TYPE} of entity classes in the generated code "
+"(default: entities have no base class).",
type => EntityBase = type },
- { "entityAttributes=",
- "Comma separated {ATTRIBUTE(S)} of entity classes in the
generated code.",
- attributes => EntityAttributes = attributes },
- { "memberAttributes=",
- "Comma separated {ATTRIBUTE(S)} of entity members in the
generated code.",
- attributes => MemberAttributes = attributes },
+ { "entity-attribute=",
+ "{ATTRIBUTE} for entity classes in the generated code, "
+ +"can be specified multiple times.",
+ attribute => EntityAttributes.Add(attribute) },
+ { "member-attribute=",
+ "{ATTRIBUTE} for entity members in the generated code, "
+ +"can be specified multiple times.",
+ attribute => MemberAttributes.Add(attribute) },
{ "generate-type=",
"Generate only the {TYPE} selected, can be specified
multiple times "
+"and does not prevent references from being generated
(default: "
+"generate a DataContex subclass and all the entities in the
schema).",
type => GenerateTypes.Add(type) },
- { "generateEqualsAndHash",
+ { "generate-equals-hash",
"Generates overrides for Equals() and GetHashCode()
methods.",
- (bool v) => GenerateEqualsAndHash = v },
+ (bool v) => GenerateEqualsHash = v },
{ "sprocs",
"Extract stored procedures.",
(bool v) => Sprocs = v },
@@ -320,18 +322,18 @@ namespace DbMetal
+"using specified culture rules.",
(bool v) => Pluralize = v },
{ "culture=",
- "Specify {CULTURE} for word recognition and pluralization
(default=\"en\").",
+ "Specify {CULTURE} for word recognition and pluralization
(default: \"en\").",
culture => Culture = culture },
{ "case=",
"Transform names with the indicated {STYLE} "
+"(default: net; may be: leave, pascal, camel, net).",
style => Case = style },
{ "generate-timestamps",
- "Generate timestampes in the generated code. True by
default.",
+ "Generate timestampes in the generated code (default:
enabled).",
(bool v) => GenerateTimestamps = v },
- { "readlineAtExit",
+ { "readline",
"Wait for a key to be pressed after processing.",
- (bool v) => ReadLineAtExit = v },
+ (bool v) => Readline = v },
{ "h|?|help",
"Show this help",
(bool v) => Help = v }
--
Emanuele Aina
Studio Associato Di Nunzio e Di Gregorio
http://dndg.it/
Via Maria Vittoria, 2
10123 Torino - Italy
--
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/dblinq?hl=.
0002-Cleanup-of-the-DbMetal-command-line.patch.gz
Description: GNU Zip compressed data
