Skip to content

Commit

Permalink
added more C# and TS types
Browse files Browse the repository at this point in the history
added more content SEO++
  • Loading branch information
IPdotSetAF committed Oct 25, 2024
1 parent 779fe86 commit 9b249c0
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 12 deletions.
65 changes: 65 additions & 0 deletions src/app/cs2ts/cs2ts.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,69 @@ <h2>C# to TS Converter</h2>
<button class="btn btn-success" (click)="convert()">Convert <i class="bi bi-caret-right"></i></button>
</div>
</div>

<br />

<div class="row">
<div class="col-12">
<h3 class="row">Supports:</h3>
<ul class="row">
<li>Primary data types:
<ul>
<li>boolean</li>
<li>number:
<ul>
<li>byte</li>
<li>sbyte</li>
<li>short</li>
<li>ushort</li>
<li>int</li>
<li>uint</li>
<li>float</li>
<li>double</li>
<li>decimal</li>
</ul>
</li>
<li>bigint:
<ul>
<li>long</li>
<li>ulong</li>
</ul>
</li>
<li>string:
<ul>
<li>string</li>
<li>char</li>
</ul>
</li>
<li>Date:
<ul>
<li>DateTime</li>
<li>DateOnly</li>
<li>TimeOnly</li>
</ul>
</li>
<li>any:
<ul>
<li>object</li>
<li>dynamic</li>
</ul>
</li>
<li>void</li>
</ul>
</li>
<li>Custom data types</li>
<li>Arrays
<ul>
<li>[]</li>
<li>List&lt;&gt;</li>
<li>IEnumerable&lt;&gt;</li>
<li>ICollection&lt;&gt;</li>
</ul>
</li>
<li>Generics</li>
<li>Nullables</li>
</ul>
</div>
</div>
</div>
45 changes: 33 additions & 12 deletions src/app/cs2ts/cs2ts.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ export class Cs2tsComponent implements AfterContentInit {
protected status: boolean = false;

protected inputDebouncer = new Subject<string>();
constructor(meta:Meta){

constructor(meta: Meta) {
meta.addTags([
{name: "description", content:"Converts C# model to TS model, converts fields, types, arrays and generics."},
{name: "keywords", content:"C#, TS, CSharp, TypeScript, script, type, generic, array, converter, model, fields, string, number, int, class, code, language, long, float, boolean, bool"},
{ name: "description", content: "Converts C# model to TS model, converts fields, types, arrays and generics." },
{ name: "keywords", content: "C#, TS, CSharp, TypeScript, script, type, generic, array, converter, model, DTO, DataTransferObject, POCO, fields, string, number, int, class, code, language, long, float, boolean, bool" },
]);

this.placeholder2 = Cs2tsComponent.convert(this.placeholder1);
Expand Down Expand Up @@ -102,19 +102,40 @@ export class Cs2tsComponent implements AfterContentInit {
return code;
}

private static convertTypes(a: string | undefined): string | undefined {
if (a === "bool")
return "boolean";

switch (a) {
private static convertTypes(t: string | undefined): string | undefined {
if (!t)
return t;

switch (t!.toLowerCase()) {
case "bool":
return "boolean";
case "byte":
case "sbyte":
case "short":
case "ushort":
case "int":
case "uint":
case "float":
case "double":
case "decimal":
case "long":
return "number";
case "long":
case "ulong":
return "bigint";
case "char":
case "string":
return "string";
case "datetime":
case "dateonly":
case "timeonly":
return "Date";
case "object":
case "dynamic":
return "any";
case "void":
return "void";
default:
return t;
}

return a;
}
}

0 comments on commit 9b249c0

Please sign in to comment.