diff --git a/Src/TypeScripter/Scripter.cs b/Src/TypeScripter/Scripter.cs index adb8b71..707a26e 100644 --- a/Src/TypeScripter/Scripter.cs +++ b/Src/TypeScripter/Scripter.cs @@ -265,6 +265,15 @@ public Scripter UsingTypeFilter(Func filter) this.TypeFilter = filter; return this; } + + /// + /// Use lower camel case for properties + /// + public Scripter LowerCamelCaseProperties() + { + this.Formatter.LowerCamelCaseProperties = true; + return this; + } #endregion #region Type Generation diff --git a/Src/TypeScripter/TypeScript/TsFormatter.cs b/Src/TypeScripter/TypeScript/TsFormatter.cs index 5c5c5c6..dd96353 100644 --- a/Src/TypeScripter/TypeScript/TsFormatter.cs +++ b/Src/TypeScripter/TypeScript/TsFormatter.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -105,6 +106,14 @@ public bool EnumsAsString { get; set; } + + /// + /// Use lower camel case for properties + /// + public bool LowerCamelCaseProperties + { + get; set; + } #endregion #region Creation @@ -221,11 +230,16 @@ public virtual string Format(TsProperty property) { using (var sbc = new StringBuilderContext(this)) { - this.Write("{0}{1}: {2};", Format(property.Name), property.Optional?"?":"", Format(property.Type)); - return sbc.ToString(); + this.Write("{0}{1}: {2};", Format(property.Name), property.Optional ? "?" : "", Format(property.Type)); + var result = sbc.ToString(); + if (!LowerCamelCaseProperties) + { + return result; + } + return char.ToLower(result[0]) + (result.Length == 1 ? String.Empty : result.Substring(1)); } } - + /// /// Formats an indexer property ///