Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Src/TypeScripter/Scripter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,15 @@ public Scripter UsingTypeFilter(Func<Type, bool> filter)
this.TypeFilter = filter;
return this;
}

/// <summary>
/// Use lower camel case for properties
/// </summary>
public Scripter LowerCamelCaseProperties()
{
this.Formatter.LowerCamelCaseProperties = true;
return this;
}
#endregion

#region Type Generation
Expand Down
20 changes: 17 additions & 3 deletions Src/TypeScripter/TypeScript/TsFormatter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -105,6 +106,14 @@ public bool EnumsAsString
{
get; set;
}

/// <summary>
/// Use lower camel case for properties
/// </summary>
public bool LowerCamelCaseProperties
{
get; set;
}
#endregion

#region Creation
Expand Down Expand Up @@ -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));
}
}

/// <summary>
/// Formats an indexer property
/// </summary>
Expand Down