Skip to content

Commit 527eed3

Browse files
author
FAREAST\vidadhee
committed
Change
#1. Add MSDuration for edm.duration handling. #2. Change setters of Other date and time models
1 parent 8c212b5 commit 527eed3

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

Templates/ObjC/Base/SharedObjC.template.tt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ private string GetJsonToObjCExpressionConversion(string expr,OdcmProperty prop)
118118
expr);
119119
}
120120

121+
if(GetObjCTypeIdentifier(prop,true)=="MSDuration")
122+
{
123+
return String.Format(@"[{0} ms_durationFromString: {1}]",
124+
GetObjCTypeIdentifier(prop,true),
125+
expr);
126+
}
127+
121128
if(prop.IsEnum())
122129
{
123130
return String.Format(
@@ -195,6 +202,27 @@ private string SetDictionaryPropertyInJsonConvertibleForm(OdcmProperty prop, str
195202
// Dictionary entries can either be directly NSJSON-typed, or convertible to
196203
// a NSJSON type via [MSObject getNSJsonSerializationCompatibleValue].
197204
//
205+
206+
if(GetObjCTypeIdentifier(prop,true)=="NSDate" ||
207+
GetObjCTypeIdentifier(prop,true)=="MSDate")
208+
{
209+
return String.Format(@"self.dictionary[@""{0}""] = {1};",
210+
prop.Name,
211+
String.Format(@"[{0} ms_toString]",GetObjCToJsonConvertibleExpressionConversion(prop,val)));
212+
}
213+
214+
if(GetObjCTypeIdentifier(prop,true)=="MSTimeOfDay")
215+
{
216+
return String.Format(@"self.dictionary[@""{0}""] = {1};",
217+
prop.Name,
218+
String.Format(@"[{0} ms_toString]",GetObjCToJsonConvertibleExpressionConversion(prop,val)));
219+
}
220+
221+
if(GetObjCTypeIdentifier(prop,true)=="MSDuration")
222+
{
223+
return String.Format(@"self.dictionary[@""{0}""] = {1};",prop.Name,String.Format(@"{0}.durationString",GetObjCToJsonConvertibleExpressionConversion(prop,val)));
224+
}
225+
198226
return String.Format(@"self.dictionary[@""{0}""] = {1};",prop.Name,GetObjCToJsonConvertibleExpressionConversion(prop,val));
199227
}
200228

Templates/ObjC/Models/Models.h.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#import "MSDate.h"
66
#import "MSTimeOfDay.h"
7+
#import "MSDuration.h"
78
<#
89
var enums = model.GetEnumTypes();
910
foreach(var e in enums)

src/GraphODataTemplateWriter/CodeHelpers/ObjC/TypeHelperObjC.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public static string GetTypeString(this OdcmType type)
125125
case "Stream":
126126
return "NSStream";
127127
case "Duration":
128-
return "MSDate";
128+
return "MSDuration";
129129
case "NSDictionary":
130130
return "NSDictionary";
131131
case "JSON":

0 commit comments

Comments
 (0)