Bumped package version to 1.5.1, added GetNames/GetValues helper functions to Javascript Enum Type class.
This commit is contained in:
parent
fe5fc73d14
commit
bbd38496da
@ -17,7 +17,7 @@
|
||||
<AssemblyName>MontoyaTech.Rest.Net</AssemblyName>
|
||||
<RootNamespace>MontoyaTech.Rest.Net</RootNamespace>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
<Version>1.5.0</Version>
|
||||
<Version>1.5.1</Version>
|
||||
<PackageReleaseNotes></PackageReleaseNotes>
|
||||
<PackageIcon>Logo_Symbol_Black_Outline.png</PackageIcon>
|
||||
</PropertyGroup>
|
||||
|
@ -289,6 +289,41 @@ namespace MontoyaTech.Rest.Net
|
||||
writer.Outdent().WriteLine("}");
|
||||
}
|
||||
|
||||
//If this is an enum, generate a GetNames/GetValues function.
|
||||
if (type.IsEnum)
|
||||
{
|
||||
writer.WriteBreak().WriteLine("/**").Indent();
|
||||
writer.WriteLine("Returns the names of this enums values in an array.");
|
||||
writer.WriteLine("@method");
|
||||
writer.WriteLine("@returns {Array<string>}");
|
||||
writer.Outdent().WriteLine("*/");
|
||||
writer.WriteLine("static GetNames() {").Indent();
|
||||
writer.WriteLine("return [").Indent();
|
||||
|
||||
var names = Enum.GetNames(type);
|
||||
foreach (var name in names)
|
||||
writer.WriteLine($"'{name}',");
|
||||
|
||||
writer.Outdent().WriteLine("];");
|
||||
writer.Outdent().WriteLine("}");
|
||||
|
||||
writer.WriteBreak().WriteLine("/**").Indent();
|
||||
writer.WriteLine("Returns the values of this enum in an arrray.");
|
||||
writer.WriteLine("@method");
|
||||
writer.WriteLine("@returns {Array<number>}");
|
||||
writer.Outdent().WriteLine("*/");
|
||||
writer.WriteLine("static GetValues() {").Indent();
|
||||
writer.WriteLine("return [").Indent();
|
||||
|
||||
var values = Enum.GetValues(type);
|
||||
foreach (var value in values)
|
||||
writer.WriteLine($"{Convert.ToInt32(value)},");
|
||||
|
||||
writer.Outdent().WriteLine("];");
|
||||
writer.Outdent().WriteLine("}");
|
||||
}
|
||||
|
||||
//Close off the class
|
||||
writer.Outdent().WriteLine("}");
|
||||
|
||||
writer.WriteBreak().WriteLine($"{this.ClientName}.{(type.DeclaringType != null ? type.DeclaringType.Name : "")}{(newName != null ? newName.Name : type.Name)} = {(type.DeclaringType != null ? type.DeclaringType.Name : "")}{(newName != null ? newName.Name : type.Name)};");
|
||||
|
Loading…
x
Reference in New Issue
Block a user