コード例 #1
0
        public static ITransformJsonService MapPropertyService(RuntimeContext ctx, ITransformJsonService service, string propertyName, JToken value)
        {
            (PropertyInfo, Action <object, object>)writer = GetWriter(service.GetType(), propertyName);

            if (writer.Item1 != null)
            {
                var type = writer.Item1.PropertyType;
                if (type == typeof(string))
                {
                    writer.Item2(service, value.ToString());
                }

                else if (type.IsValueType)
                {
                    writer.Item2(service, Convert.ChangeType(value.ToString(), type));
                }

                else if (value is JObject o)
                {
                    writer.Item2(service, o.ToObject(type));
                }

                else
                {
                }
            }

            return(service);
        }
コード例 #2
0
 // ITransformJsonService
 public static JToken GetContentFromService(RuntimeContext ctx, JToken token, ITransformJsonService service)
 {
     return(service.Execute(ctx, token));
 }