public object Deserialize(string value, JsonConverter converter) { //Integration.Implementation.LogAudit("TinCanActor Deserialize called", null); IDictionary objMap = converter.DeserializeJSONToMap(value); string typeField = null; if (objMap.Contains("type")) { typeField = (string)objMap["type"]; } //Avoid infinite loop here, if type is this base class Type targetType = typeof(ActivityDefinition_JsonTarget); if (typeField != null) { Uri activityType = new Uri((string)objMap["type"]); if (activityType.Equals("http://adlnet.gov/expapi/activities/cmi.interaction")) { targetType = typeof(InteractionDefinition); } } return converter.DeserializeJSON(value, targetType); }
public object Deserialize(string value, JsonConverter converter) { LanguageMap langDict = new LanguageMap(); IDictionary objMap = converter.DeserializeJSONToMap(value); foreach (object key in objMap.Keys) { langDict.Add((string)key, (string)objMap[key]); } return langDict; }
public object Deserialize(string value, JsonConverter converter) { //Integration.Implementation.LogAudit("TinCanStatementTarget Deserialize called", null); IDictionary objMap = converter.DeserializeJSONToMap(value); String typeField = null; if (objMap.Contains("objectType")) { typeField = (String)objMap["objectType"]; } TypeFieldJsonHelper typeFieldHelper = new TypeFieldJsonHelper(); Type targetType = typeFieldHelper.GetTypeFromString(typeField, typeof(TinCanActivity)); return converter.DeserializeJSON(value, targetType); }
public object Reduce(object value, JsonConverter converter) { //This should never be called, since TinCanStatementTarget is just an interface, and true should be known for serialization throw new Exception("Reduce called on TinCanStatement converter"); /*Integration.Implementation.LogAudit("TinCanStatementTarget Reduce called", null); Type targetType = value.GetType(); if (targetType.IsAssignableFrom(typeof(Activity))){ return (Activity)value; } else if (targetType.IsAssignableFrom(typeof(TinCanActor))){ return (TinCanActor)value; } throw new Exception("Statement target type " + value.GetType().ToString() + " was unrecognized during serialization");*/ }
public object Deserialize(string value, JsonConverter converter) { //Integration.Implementation.LogAudit("TinCanActor Deserialize called", null); IDictionary objMap = converter.DeserializeJSONToMap(value); String typeField = null; if (objMap.Contains("objectType")) { typeField = (String)objMap["objectType"]; } TypeFieldJsonHelper typeFieldHelper = new TypeFieldJsonHelper(); Type targetType = typeFieldHelper.GetTypeFromString(typeField, typeof(Actor)); //Avoid infinite loop here, if type is this base class if (targetType.Equals(typeof(Actor))) { targetType = typeof(TinCanActor_JsonTarget); } return converter.DeserializeJSON(value, targetType); }
public object Deserialize(string value, JsonConverter converter) { //Integration.Implementation.LogAudit("TinCanActor Deserialize called", null); IDictionary objMap = converter.DeserializeJSONToMap(value); String typeField = null; if (objMap.Contains("type")) { typeField = (String)objMap["type"]; } TinCanActivityType activityType = TinCanActivityTypeHelper.Parse(typeField); //Avoid infinite loop here, if type is this base class Type targetType = typeof(ActivityDefinition_JsonTarget); if (activityType == TinCanActivityType.CMI_Interaction){ targetType = typeof(InteractionDefinition); } return converter.DeserializeJSON(value, targetType); }
public object Reduce(object value, JsonConverter converter) { return ((NullableInteger)value).Value; }
public object Deserialize(string value, JsonConverter converter) { return string.IsNullOrEmpty(value) ? null : new NullableInteger(Int32.Parse(value)); }
public object Reduce(object value, JsonConverter converter) { //Avoid infinite loop here, so we don't ever return just a Uri type return new ActivityDefinition_JsonTarget((ActivityDefinition)value); }
public object Reduce(object value, JsonConverter converter) { //Avoid infinite loop here, so we don't ever return just a TinCanActor type return new TinCanActor_JsonTarget((Actor)value); }
public object Deserialize(string value, JsonConverter converter) { return String.IsNullOrEmpty(value) ? null : new NullableDouble(Double.Parse(value)); }
public object Reduce(object value, JsonConverter converter) { return ((NullableBoolean)value).Value; }
public object Deserialize(string value, JsonConverter converter) { return string.IsNullOrEmpty(value) ? null : new NullableBoolean(bool.Parse(value)); }
public object Reduce(object value, JsonConverter converter) { return ((NullableScormTimeSpan)value).Value.ToIso8601String(); }
public object Deserialize(string value, JsonConverter converter) { return string.IsNullOrEmpty(value) ? null : new NullableScormTimeSpan(value); }
public object Deserialize(string value, JsonConverter converter) { return string.IsNullOrEmpty(value) ? null : new NullableDateTime(ParserUtil.GetDateTimeFromIsoTimeString(value)); }
public object Reduce(object value, JsonConverter converter) { return ((NullableDateTime)value).Value.ToString(Constants.ISO8601_DATE_FORMAT); }
public object Reduce(object value, JsonConverter converter) { return (new Dictionary<string, string>((IDictionary<string, string>)value)); }