@@ -3,15 +3,15 @@ const { AttributeType } = require('../attribute');
33const { LanguageMeta } = require("./language");
44
55class CSharp extends LanguageMeta {
6- getType(attribute, collections) {
6+ getType(attribute, collections, collectionName ) {
77 let type = "";
88 switch (attribute.type) {
99 case AttributeType.STRING:
1010 case AttributeType.EMAIL:
1111 case AttributeType.DATETIME:
1212 type = "string";
1313 if (attribute.format === AttributeType.ENUM) {
14- type = LanguageMeta.toPascalCase(attribute.key);
14+ type = LanguageMeta.toPascalCase(collectionName) + LanguageMeta.toPascalCase( attribute.key);
1515 }
1616 break;
1717 case AttributeType.INTEGER:
@@ -60,7 +60,7 @@ namespace Appwrite.Models
6060<% for (const attribute of collection.attributes) { -%>
6161<% if (attribute.format === ' enum' ) { -%>
6262
63- public enum <% - toPascalCase(attribute.key) %> {
63+ public enum <% - toPascalCase(collection.name) %><% - toPascalCase( attribute.key) %> {
6464<% for (const [index, element] of Object .entries(attribute.elements) ) { -%>
6565 [JsonPropertyName("<% - element %> ")]
6666 <% - toPascalCase(element) %><% if (index < attribute.elements.length - 1 ) { %> ,<% } %>
@@ -72,13 +72,13 @@ public class <%= toPascalCase(collection.name) %>
7272{
7373<% for (const [index, attribute] of Object .entries(collection.attributes)) { -%>
7474 [JsonPropertyName("<% - attribute.key %> ")]
75- public <% - getType(attribute, collections) %> <%= toPascalCase(attribute.key) %> { get; private set; }
75+ public <% - getType(attribute, collections, collection.name ) %> <%= toPascalCase(attribute.key) %> { get; private set; }
7676
7777<% } -%>
7878
7979 public <%= toPascalCase(collection.name) %> (
8080<% for (const [index, attribute] of Object .entries(collection.attributes)) { -%>
81- <% - getType(attribute, collections) %> <%= toCamelCase(attribute.key) %><% if (index < collection.attributes.length - 1 ) { %> ,<% } %>
81+ <% - getType(attribute, collections, collection.name ) %> <%= toCamelCase(attribute.key) %><% if (index < collection.attributes.length - 1 ) { %> ,<% } %>
8282<% } -%>
8383 )
8484 {
@@ -93,9 +93,9 @@ public class <%= toPascalCase(collection.name) %>
9393 // ENUM
9494 if (attribute.format === ' enum' ) {
9595 if (attribute.array) {
96- -%> ((IEnumerable<object >)map["<% - attribute.key %> "]).Select(e => Enum.Parse<Models .<% - toPascalCase(attribute.key) %> >(e.ToString()!, true)).ToList()<%
96+ -%> ((IEnumerable<object >)map["<% - attribute.key %> "]).Select(e => Enum.Parse<Models .<% - toPascalCase(collection.name) %><% - toPascalCase( attribute.key) %> >(e.ToString()!, true)).ToList()<%
9797 } else {
98- -%> Enum.Parse<Models .<% - toPascalCase(attribute.key) %> >(map["<% - attribute.key %> "].ToString()!, true)<%
98+ -%> Enum.Parse<Models .<% - toPascalCase(collection.name) %><% - toPascalCase( attribute.key) %> >(map["<% - attribute.key %> "].ToString()!, true)<%
9999 }
100100 // RELATIONSHIP
101101 } else if (attribute.type === ' relationship' ) {
@@ -122,7 +122,7 @@ public class <%= toPascalCase(collection.name) %>
122122 } else if (attribute.type === ' double' ) {
123123 -%><% - ! attribute.required ? ' map["' + attribute.key + ' "] == null ? null : ' : ' ' %> Convert.ToDouble(map["<% - attribute.key %> "])<%
124124 } else if (attribute.type === ' boolean' ) {
125- -%> (<% - getType(attribute, collections) %> )map["<% - attribute.key %> "]<%
125+ -%> (<% - getType(attribute, collections, collection.name ) %> )map["<% - attribute.key %> "]<%
126126 } else if (attribute.type === ' string' || attribute.type === ' datetime' || attribute.type === ' email' ) {
127127 -%> map["<% - attribute.key %> "]<% - ! attribute.required ? ' ?' : ' ' %> .ToString()<% - attribute.required ? ' !' : ' ' %><%
128128 } else {
0 commit comments