public static object ConvertDictionaryToClassDataContract(DataContractJsonSerializer serializer, ClassDataContract dataContract, Dictionary <string, object> deserialzedValue, XmlObjectSerializerReadContextComplexJson context)
{
if (deserialzedValue == null)
{
return(null);
}
if (dataContract.UnderlyingType == Globals.TypeOfDateTimeOffsetAdapter)
{
var tuple = deserialzedValue["DateTime"] as Tuple <DateTime, string>;
DateTimeOffset dto = new DateTimeOffset(tuple != null ? tuple.Item1 : (DateTime)deserialzedValue["DateTime"]);
return(dto.ToOffset(new TimeSpan(0, (int)deserialzedValue["OffsetMinutes"], 0)));
}
if (deserialzedValue.ContainsKey(JsonGlobals.ServerTypeString))
{
dataContract = ResolveDataContractFromTypeInformation(deserialzedValue[JsonGlobals.ServerTypeString].ToString(), dataContract, context);
}
object o = CreateInstance(dataContract);
CheckDuplicateNames(dataContract);
DataContractJsonSerializer.InvokeOnDeserializing(o, dataContract, context);
ReadClassDataContractMembers(serializer, dataContract, deserialzedValue, o, context);
DataContractJsonSerializer.InvokeOnDeserialized(o, dataContract, context);
if (dataContract.IsKeyValuePairAdapter)
{
return(dataContract.GetKeyValuePairMethodInfo.Invoke(o, Globals.EmptyTypeArray));
}
return(o);
}