33namespace Microsoft . Graph . ODataTemplateWriter . CodeHelpers . ObjC
44{
55 using System . Collections . Generic ;
6+ using System . Linq ;
67 using Microsoft . Graph . ODataTemplateWriter . Extensions ;
78 using Microsoft . Graph . ODataTemplateWriter . Settings ;
89 using Vipr . Core . CodeModel ;
910
1011 public static class TypeHelperObjC
11- {
12- public static string Prefix = ConfigurationService . Settings . NamespacePrefix ;
12+ {
13+ public static string Prefix = ConfigurationService . Settings . NamespacePrefix ;
1314
1415 private static ICollection < string > reservedNames ;
1516 public static ICollection < string > ReservedNames
1617 {
17- get
18+ get
1819 {
1920 if ( reservedNames == null )
2021 {
21- reservedNames = new HashSet < string >
22+ reservedNames = new HashSet < string >
2223 {
2324 "id" ,
2425 "YES" ,
@@ -84,9 +85,9 @@ public static ICollection<string> ReservedNames
8485 }
8586 }
8687
87- public static string GetTypeString ( this OdcmType type )
88+ public static string GetTypeString ( this OdcmType type )
8889 {
89- if ( type == null )
90+ if ( type == null )
9091 {
9192 return "id" ;
9293 }
@@ -125,19 +126,19 @@ public static string GetTypeString(this OdcmType type)
125126 }
126127 }
127128
128- public static string GetTypeString ( this OdcmProperty property )
129+ public static string GetTypeString ( this OdcmProperty property )
129130 {
130131 return property . Projection . Type . GetTypeString ( ) ;
131132 }
132133
133- public static bool IsComplex ( this OdcmType type )
134+ public static bool IsComplex ( this OdcmType type )
134135 {
135136 string t = GetTypeString ( type ) ;
136137 return
137138 ! ( t == "int32_t" || t == "int64_t" || t == "int16_t" || t == "BOOL" || t == "Byte" || t == "CGFloat" ) ;
138139 }
139140
140- public static bool IsComplex ( this OdcmProperty property )
141+ public static bool IsComplex ( this OdcmProperty property )
141142 {
142143 return property . Projection . Type . IsComplex ( ) ;
143144 }
@@ -152,16 +153,16 @@ public static string ToSetterTypeString(this OdcmProperty property)
152153 return string . Format ( "{0} {1}" , property . GetFullType ( ) , ( property . IsComplex ( ) ? "*" : string . Empty ) ) ;
153154 }
154155
155- public static string SanitizePropertyName ( this OdcmProperty property )
156+ public static string SanitizePropertyName ( this OdcmProperty property )
156157 {
157- if ( ReservedNames . Contains ( property . Name . ToLower ( ) ) )
158+ if ( ReservedNames . Contains ( property . Name . ToLower ( ) ) )
158159 {
159160 return property . Class . Name . ToLowerFirstChar ( ) + property . Name . ToUpperFirstChar ( ) ;
160161 }
161162 return property . Name ;
162163 }
163164
164- public static string GetFullType ( this OdcmProperty property )
165+ public static string GetFullType ( this OdcmProperty property )
165166 {
166167 if ( property . IsCollection )
167168 {
@@ -171,23 +172,23 @@ public static string GetFullType(this OdcmProperty property)
171172 {
172173 return property . Projection . Type . GetTypeString ( ) ;
173174 }
174- }
175+ }
175176
176- public static string GetFullType ( this OdcmType type )
177- {
178- return GetTypeString ( type ) ;
179- }
177+ public static string GetFullType ( this OdcmType type )
178+ {
179+ return GetTypeString ( type ) ;
180+ }
180181
181- public static bool IsSystem ( this OdcmProperty property )
182- {
182+ public static bool IsSystem ( this OdcmProperty property )
183+ {
183184 return property . Projection . Type . IsSystem ( ) ;
184- }
185+ }
185186
186- public static bool IsSystem ( this OdcmType type )
187- {
188- string t = GetTypeString ( type ) ;
189- return ( t . Contains ( "int" ) || t == "BOOL" || t == "Byte" || t == "NSString" || t == "NSDate" || t == "NSStream" || t == "CGFloat" ) ;
190- }
187+ public static bool IsSystem ( this OdcmType type )
188+ {
189+ string t = GetTypeString ( type ) ;
190+ return ( t . Contains ( "int" ) || t == "BOOL" || t == "Byte" || t == "NSString" || t == "NSDate" || t == "NSStream" || t == "CGFloat" ) ;
191+ }
191192
192193 public static bool IsComplexCollectionOpenType ( this OdcmProperty property , OdcmModel model )
193194 {
@@ -206,27 +207,27 @@ public static bool IsDate(this OdcmType type)
206207 return typeString . Equals ( "NSDate" ) ;
207208 }
208209
209- public static string GetToLowerFirstCharName ( this OdcmProperty property )
210- {
211- return property . Name . ToLowerFirstChar ( ) ;
212- }
210+ public static string GetToLowerFirstCharName ( this OdcmProperty property )
211+ {
212+ return property . Name . ToLowerFirstChar ( ) ;
213+ }
213214
214- public static string GetToLowerImport ( this OdcmProperty property )
215- {
215+ public static string GetToLowerImport ( this OdcmProperty property )
216+ {
216217 var type = property . Projection . Type ;
217218 var index = type . Name . LastIndexOf ( '.' ) ;
218- return type . Name . Substring ( 0 , index ) . ToLower ( ) + type . Name . Substring ( index ) ;
219- }
219+ return type . Name . Substring ( 0 , index ) . ToLower ( ) + type . Name . Substring ( index ) ;
220+ }
220221
221222 public static string GetToUpperFirstCharName ( this OdcmProperty property )
222223 {
223224 return property . Name . ToUpperFirstChar ( ) ;
224225 }
225226
226- public static bool IsEnum ( this OdcmProperty property )
227- {
228- return property . Projection . Type is OdcmEnum ;
229- }
227+ public static bool IsEnum ( this OdcmProperty property )
228+ {
229+ return property . Projection . Type is OdcmEnum ;
230+ }
230231 public static string GetNSNumberValueMethod ( this OdcmType type )
231232 {
232233 string objectiveCType = type . GetTypeString ( ) ;
@@ -253,5 +254,5 @@ public static string GetNSNumberValueMethod(this OdcmType type)
253254
254255 return null ;
255256 }
256- }
257+ }
257258}
0 commit comments