@@ -27,11 +27,17 @@ private string GetObjCTypeIdentifier(OdcmObject o, bool getUnderlyingType=false)
2727 if(o is OdcmProperty)
2828 {
2929 OdcmProperty prop=(OdcmProperty)o;
30+
3031 if(prop.IsCollection && !getUnderlyingType)
3132 {
3233 return @"NSArray";
3334 }
3435
36+ if (prop.IsComplexCollectionOpenType(model) && !getUnderlyingType)
37+ {
38+ return @"NSDictionary";
39+ }
40+
3541 return GetObjCTypeIdentifier(prop.Projection.Type,getUnderlyingType);
3642 }
3743 else if(o is OdcmType)
@@ -136,6 +142,17 @@ private string GetJsonToObjCExpressionConversion(string expr,OdcmProperty prop)
136142 type.GetNSNumberValueMethod());
137143}
138144
145+ private string GetObjCTypeIdentifierCollection(OdcmProperty prop)
146+ {
147+ var propName = GetObjCTypeIdentifier(prop,true);
148+ if (prop.IsComplexCollectionOpenType(model))
149+ {
150+ propName = propName.RemoveFromEnd("Collection");
151+ }
152+
153+ return propName;
154+ }
155+
139156private string GetHydratedPropertyFromDictionary(OdcmProperty prop)
140157{
141158 return GetJsonToObjCExpressionConversion(String.Format(@"self.dictionary[@""{0}""]",prop.Name),prop);
@@ -198,8 +215,39 @@ private string GetHydratedIVarFromDictionary(OdcmProperty prop)
198215 GetJsonToObjCExpressionConversion(prop.Projection.Type.Name.ToLowerFirstChar(), prop));
199216 }
200217
218+ if(prop.IsComplexCollectionOpenType(model))
219+ {
220+ return String.Format(@"
221+ NSMutableDictionary *{0}Result = [[NSMutableDictionary alloc] init];
222+ NSDictionary *{0} = self.dictionary[@""{1}""];
223+
224+ if ([{0} isKindOfClass:[NSDictionary class]]){{
225+ [{0} enumerateKeysAndObjectsUsingBlock:^(NSString* key, id value, BOOL* stop){{
226+ [{0}Result setValue:{3} forKey:key];
227+ }}];
228+ }}
229+
230+ _{0} = {0}Result;
231+ ",
232+ GetObjCProperty(prop),
233+ prop.Name,
234+ prop.Projection.Type.Name.ToLowerFirstChar().RemoveFromEnd("Collection"),
235+ GetJsonToObjCExpressionConversionOpenType(prop));
236+ }
237+
201238 return String.Format(@"_{0} = {1};",GetObjCProperty(prop),GetHydratedPropertyFromDictionary(prop));
239+ }
240+
241+ private string GetJsonToObjCExpressionConversionOpenType(OdcmProperty prop)
242+ {
243+ string objCIdentifierType = GetObjCTypeIdentifierCollection(prop);
244+
245+ if(model.GetComplexTypes().Any(complexType => objCIdentifierType.Equals(writer.GetPrefix() + complexType.Name.ToUpperFirstChar())))
246+ {
247+ return String.Format("[[{0} alloc] initWithDictionary:value]", objCIdentifierType);
248+ }
202249
250+ return "value";
203251}
204252
205253public string GetFunctionParameterDictionary(List<OdcmParameter> parameters)
0 commit comments