public static object FromString(ContractValue contract, string value) { if (stringtovalue.TryGetValue(contract.GetTypeFromTask(), out ConvertFromString function)) { return(function(value)); } throw new InvokeException($"no value-converter for {contract.Name}"); }
private static string ToString(ContractValue contract, object value) { if (valuetostring.TryGetValue(contract.GetTypeFromTask(), out ConvertToString function)) { return(function(value)); } throw new InvokeException($"no value-converter for {contract.Name}"); }
internal static object FromJson(ContractValue contract, JObject data) { var datacontract = ServicesFactory.GetDataContract(contract.Type); if (datacontract != null) { // var obj = data[contract.Name].Value<object>(); var result = Activator.CreateInstance(datacontract.Type); foreach (var p in datacontract.Properties) { p.Property.SetValue(result, data[p.Name].ToObject(p.Type)); } return(result); } else { var obj = data["result"].Value <JValue>(); return(obj.ToObject(contract.GetTypeFromTask())); } }