DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Static Public Attributes | Properties | Private Member Functions | List of all members
Deveel.Data.Mapping.RuledNamingConvention Class Reference
Inheritance diagram for Deveel.Data.Mapping.RuledNamingConvention:
Deveel.Data.Mapping.INamingConvention

Public Member Functions

 RuledNamingConvention (DefaultNamingRules rules)
 
string FormatName (string inputName)
 

Static Public Attributes

static RuledNamingConvention SqlNaming = new RuledNamingConvention(DefaultNamingRules.LowerCase | DefaultNamingRules.UnderscoreSeparator)
 

Properties

DefaultNamingRules Rules [get, private set]
 

Private Member Functions

void ValidateCaseRule (DefaultNamingRules rules)
 

Detailed Description

Definition at line 5 of file RuledNamingConvention.cs.

Constructor & Destructor Documentation

Deveel.Data.Mapping.RuledNamingConvention.RuledNamingConvention ( DefaultNamingRules  rules)
inline

Definition at line 8 of file RuledNamingConvention.cs.

8  {
9  ValidateCaseRule(rules);
10  Rules = rules;
11  }
void ValidateCaseRule(DefaultNamingRules rules)

Member Function Documentation

string Deveel.Data.Mapping.RuledNamingConvention.FormatName ( string  inputName)
inline

Implements Deveel.Data.Mapping.INamingConvention.

Definition at line 24 of file RuledNamingConvention.cs.

24  {
25  var input = inputName.ToCharArray();
26  var sb = new StringBuilder();
27 
28  bool upperSeen = false;
29  for (int i = 0; i < input.Length; i++) {
30  var c = input[i];
31  if (Char.IsUpper(c)) {
32  if ((Rules & DefaultNamingRules.LowerCase) != 0) {
33  c = Char.ToLower(c);
34  } else if ((Rules & DefaultNamingRules.CamelCase) != 0) {
35  if (upperSeen) {
36  c = Char.ToLower(c);
37  }
38  }
39 
40  upperSeen = true;
41  } else if (Char.IsLower(c)) {
42  if ((Rules & DefaultNamingRules.UpperCase) != 0) {
43  c = Char.ToUpper(c);
44  }
45 
46  upperSeen = false;
47  }
48 
49  sb.Append(c);
50 
51  if (upperSeen && i > 0 && ((Rules & DefaultNamingRules.UnderscoreSeparator) != 0))
52  sb.Append('_');
53  }
54 
55  return sb.ToString();
56  }
void Deveel.Data.Mapping.RuledNamingConvention.ValidateCaseRule ( DefaultNamingRules  rules)
inlineprivate

Definition at line 13 of file RuledNamingConvention.cs.

13  {
14  if ((rules & DefaultNamingRules.CamelCase) != 0 &&
15  ((rules & DefaultNamingRules.LowerCase) != 0 ||
16  (rules & DefaultNamingRules.UpperCase) != 0))
17  throw new ArgumentException("Invalid casing rule.", "rules");
18 
19  // TODO: do the same for other casing rules
20  }

Member Data Documentation

RuledNamingConvention Deveel.Data.Mapping.RuledNamingConvention.SqlNaming = new RuledNamingConvention(DefaultNamingRules.LowerCase | DefaultNamingRules.UnderscoreSeparator)
static

Definition at line 6 of file RuledNamingConvention.cs.

Property Documentation

DefaultNamingRules Deveel.Data.Mapping.RuledNamingConvention.Rules
getprivate set

Definition at line 22 of file RuledNamingConvention.cs.


The documentation for this class was generated from the following file: