Patch looks good, but I would suggest changing GetCase() to switch on
parameters.Case.ToLowerInvariant() (so that fat-fingered "Leave" options
are accepted).
Also, the default should probably be NetCase. This is .NET, after
all. :-)
Please commit.
- Jon
On Fri, 2009-10-16 at 18:17 +0200, Federico Di Gregorio wrote:
> Very simple patch that adds the /case option and let the user select the
> text transformation applied to table/column/type names. I mapped all the
> enum values to short names:
>
> Case.Leave leave
> Case.PascalCase pascal
> Case.NetCase net
> Case.camelCase camel
>
> and yes, someone drunk too much and really defined an enum value using
> the casing of the value itself (camelCase). Bleurgh.
>
> This is not enough because not all code uses the passed value: my plan
> is to hunt for the bad parts and fixing them in a later patch.
>
> Patch follows, zipped version attached. Hope everything is fine.
>
> diff --git a/src/DbMetal/Generator/Implementation/Processor.cs
> b/src/DbMetal/Generator/Implementation/Processor.cs
> index a143fc2..4365bf5 100644
> --- a/src/DbMetal/Generator/Implementation/Processor.cs
> +++ b/src/DbMetal/Generator/Implementation/Processor.cs
> @@ -1,4 +1,4 @@
> -#region MIT license
> +#region MIT license
> //
> // MIT license
> //
> @@ -216,7 +216,7 @@ namespace DbMetal.Generator.Implementation
>
> parameters.Write(">>> Reading schema from {0} database",
> schemaLoader.Vendor.VendorName);
> dbSchema = schemaLoader.Load(parameters.Database,
> nameAliases,
> - new NameFormat(parameters.Pluralize, Case.PascalCase,
> new CultureInfo(parameters.Culture)),
> + new NameFormat(parameters.Pluralize,
> GetCase(parameters), new CultureInfo(parameters.Culture)),
> parameters.Sprocs, parameters.Namespace,
> parameters.Namespace);
> dbSchema.Provider = parameters.Provider;
> dbSchema.Tables.Sort(new LambdaComparer<Table>((x, y) =>
> (x.Type.Name.CompareTo(y.Type.Name))));
> @@ -250,5 +250,22 @@ namespace DbMetal.Generator.Implementation
> {
> parameters.WriteHelp();
> }
> +
> + private Case GetCase(Parameters parameters)
> + {
> + if (String.IsNullOrEmpty(parameters.Case))
> + return Case.PascalCase;
> + switch (parameters.Case)
> + {
> + case "leave":
> + return Case.Leave;
> + case "camel":
> + return Case.camelCase;
> + case "net":
> + return Case.NetCase;
> + default:
> + return Case.PascalCase;
> + }
> + }
> }
> }
> diff --git a/src/DbMetal/Parameters.cs b/src/DbMetal/Parameters.cs
> index c2232fa..af82048 100644
> --- a/src/DbMetal/Parameters.cs
> +++ b/src/DbMetal/Parameters.cs
> @@ -1,4 +1,4 @@
> -#region MIT license
> +#region MIT license
> //
> // MIT license
> //
> @@ -179,6 +179,13 @@ namespace DbMetal
> public bool Sprocs { get; set; }
>
> /// <summary>
> + /// preserve case of database names
> + /// DbLinq specific
> + /// </summary>
> + [Option("Transform names as indicated (default: pascal; may be:
> leave, pascal, camel, net).", Group = 4)]
> + public string Case { get; set; }
> +
> + /// <summary>
> /// ??
> /// DbLinq specific
> /// </summary>
>
>
> federico
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---