Exemple #1
0
 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}");
 }
Exemple #2
0
 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}");
 }
Exemple #3
0
        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()));
            }
        }