public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            JToken       token  = JToken.Load(reader);
            SchemaSource result = (existingValue as SchemaSource ?? new SchemaSource());

            if (token is Newtonsoft.Json.Linq.JObject obj)
            {
                SchemaSource temp = token.ToObject <SchemaSource>();

                result.Location     = temp.Location;
                result.MutationType = temp.MutationType;
                result.QueryType    = temp.QueryType;
                result.Headers      = temp.Headers;
            }
            else if (token is Newtonsoft.Json.Linq.JValue value)
            {
                result.Location = value.Value.ToString();
            }

            return(result);
        }
Esempio n. 2
0
        internal string SettingsHash()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(ClassName);
            sb.Append("~#~");
            sb.Append(OutputPath);
            sb.Append("~#~");
            sb.Append(RootPath);
            sb.Append("~#~");
            sb.Append(Format);
            sb.Append("~#~");
            sb.Append(TypeNameDirective);
            sb.Append("~#~");
            if (Templates != null)
            {
                foreach (var t in Templates)
                {
                    sb.Append(t);
                    sb.Append("~#~");
                }
            }
            if (TemplateSettings != null)
            {
                foreach (var t in TemplateSettings)
                {
                    sb.Append(t.Key);
                    sb.Append("~#~");
                    sb.Append(t.Value);
                    sb.Append("~#~");
                }
            }

            if (SchemaSource != null)
            {
                sb.Append(SchemaSource.SettingsHash());
            }

            return(sb.ToString());
        }