Exemple #1
0
        public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy)
        {
            StringBuilder stringBuilder = new StringBuilder(2000);
            bool          flag          = SimpleJsonTool.SerializeValue(jsonSerializerStrategy, json, stringBuilder);

            return((!flag) ? null : stringBuilder.ToString());
        }
Exemple #2
0
        private static bool SerializeArray(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable anArray, StringBuilder builder)
        {
            bool flag2;

            builder.Append("[");
            bool flag = true;

            using (IEnumerator enumerator = anArray.GetEnumerator())
            {
                while (true)
                {
                    if (enumerator.MoveNext())
                    {
                        object current = enumerator.Current;
                        if (!flag)
                        {
                            builder.Append(",");
                        }
                        if (!SerializeValue(jsonSerializerStrategy, current, builder))
                        {
                            flag2 = false;
                            break;
                        }
                        flag = false;
                        continue;
                    }
                    builder.Append("]");
                    return(true);
                }
            }
            return(flag2);
        }
Exemple #3
0
        private static bool SerializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder)
        {
            builder.Append("{");
            var ke    = keys.GetEnumerator();
            var ve    = values.GetEnumerator();
            var first = true;

            while (ke.MoveNext() && ve.MoveNext())
            {
                var key   = ke.Current;
                var value = ve.Current;
                if (!first)
                {
                    builder.Append(",");
                }

                if (key is string stringKey)
                {
                    SerializeString(stringKey, builder);
                }
                else if (!SerializeValue(jsonSerializerStrategy, value, builder))
                {
                    return(false);
                }
                builder.Append(":");
                if (!SerializeValue(jsonSerializerStrategy, value, builder))
                {
                    return(false);
                }
                first = false;
            }
            builder.Append("}");
            return(true);
        }
Exemple #4
0
        internal static ServerError Create(IDictionary <string, object> dict, IJsonSerializerStrategy strategy)
        {
            var statusCode = -1;

            if (dict.TryGetValue("status", out var status))
            {
                statusCode = Convert.ToInt32(status);
            }

            if (!dict.TryGetValue("error", out var error))
            {
                return(null);
            }
            Error err;

            if (error is string s)
            {
                err = new Error {
                    Reason = s
                };
            }
            else
            {
                err = (Error)strategy.DeserializeObject(error, typeof(Error));
            }

            return(new ServerError(err, statusCode));
        }
Exemple #5
0
        /// <summary>
        /// Converts a IDictionary&lt;string,object> / IList&lt;object> object into a JSON string
        /// </summary>
        /// <param name="json">A IDictionary&lt;string,object> / IList&lt;object></param>
        /// <param name="jsonSerializerStrategy">Serializer strategy to use</param>
        /// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns>
        public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy)
        {
            StringBuilder builder = new StringBuilder(BUILDERCAPACITY);
            bool          success = SerializeValue(jsonSerializerStrategy, json, builder);

            return(success ? builder.ToString() : null);
        }
Exemple #6
0
        /// <summary>
        ///     Converts a IDictionary&lt;string,object> / IList&lt;object> object into a JSON string
        /// </summary>
        /// <param name="json">A IDictionary&lt;string,object> / IList&lt;object></param>
        /// <param name="jsonSerializerStrategy">Serializer strategy to use</param>
        /// <returns>A JSON encoded string, or null if object 'json' is not serializable</returns>
        public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy = null)
        {
            var builder = new StringBuilder(BUILDER_CAPACITY);
            var success = SerializeValue(jsonSerializerStrategy ?? CurrentJsonSerializerStrategy, json, builder);

            return(success ? builder.ToString() : null);
        }
Exemple #7
0
        private static bool SerializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder)
        {
            builder.Append("{");
            IEnumerator enumerator  = keys.GetEnumerator();
            IEnumerator enumerator2 = values.GetEnumerator();

            for (bool flag = true; enumerator.MoveNext() && enumerator2.MoveNext(); flag = false)
            {
                object current = enumerator.Current;
                object obj3    = enumerator2.Current;
                if (!flag)
                {
                    builder.Append(",");
                }
                string aString = current as string;
                if (aString != null)
                {
                    SerializeString(aString, builder);
                }
                else if (!SerializeValue(jsonSerializerStrategy, obj3, builder))
                {
                    return(false);
                }
                builder.Append(":");
                if (!SerializeValue(jsonSerializerStrategy, obj3, builder))
                {
                    return(false);
                }
            }
            builder.Append("}");
            return(true);
        }
        internal static Error Create(IDictionary <string, object> dict, IJsonSerializerStrategy strategy)
        {
            var error = new Error();

            error.FillValues(dict);

            object causedBy;

            if (dict.TryGetValue("caused_by", out causedBy))
            {
                error.CausedBy = (CausedBy)strategy.DeserializeObject(causedBy, typeof(CausedBy));
            }

            object rootCause;

            if (!dict.TryGetValue("root_cause", out rootCause))
            {
                return(error);
            }

            var os = rootCause as object[];

            if (os == null)
            {
                return(error);
            }
            error.RootCause = os.Select(o => (RootCause)strategy.DeserializeObject(o, typeof(RootCause))).ToList();
            return(error);
        }
        internal static RootCause Create(IDictionary <string, object> dict, IJsonSerializerStrategy strategy)
        {
            var rootCause = new RootCause();

            rootCause.FillValues(dict);
            return(rootCause);
        }
Exemple #10
0
        protected static bool serializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder)
        {
            builder.Append("{");
            IEnumerator enumerator  = keys.GetEnumerator();
            IEnumerator enumerator2 = values.GetEnumerator();
            bool        flag        = true;

            while (enumerator.MoveNext() && enumerator2.MoveNext())
            {
                object current  = enumerator.Current;
                object current2 = enumerator2.Current;
                if (!flag)
                {
                    builder.Append(",");
                }
                if (current is string)
                {
                    serializeString((string)current, builder);
                }
                else if (!serializeValue(jsonSerializerStrategy, current2, builder))
                {
                    return(false);
                }
                builder.Append(":");
                if (!serializeValue(jsonSerializerStrategy, current2, builder))
                {
                    return(false);
                }
                flag = false;
            }
            builder.Append("}");
            return(true);
        }
Exemple #11
0
        private static bool SerializeObject(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable keys, IEnumerable values, StringBuilder builder)
        {
            builder.Append("{");
            IEnumerator enumerator  = keys.GetEnumerator();
            IEnumerator enumerator2 = values.GetEnumerator();
            bool        flag        = true;

            while (enumerator.MoveNext() && enumerator2.MoveNext())
            {
                object current  = enumerator.Current;
                object current2 = enumerator2.Current;
                if (!flag)
                {
                    builder.Append(",");
                }
                string text = current as string;
                if (text != null)
                {
                    SerializeString(text, builder);
                }
                else if (!SerializeValue(jsonSerializerStrategy, current2, builder))
                {
                    return(false);
                }
                builder.Append(":");
                if (!SerializeValue(jsonSerializerStrategy, current2, builder))
                {
                    return(false);
                }
                flag = false;
            }
            builder.Append("}");
            return(true);
        }
Exemple #12
0
        internal static ServerError Create(IDictionary <string, object> dict, IJsonSerializerStrategy strategy)
        {
            object status, error;
            int    statusCode = -1;

            if (dict.TryGetValue("status", out status))
            {
                statusCode = Convert.ToInt32(status);
            }

            if (!dict.TryGetValue("error", out error))
            {
                return(null);
            }
            Error err;
            var   s = error as string;

            if (s != null)
            {
                err = new Error {
                    Reason = s
                };
            }
            else
            {
                err = (Error)strategy.DeserializeObject(error, typeof(Error));
            }

            return(new ServerError
            {
                Status = statusCode,
                Error = err
            });
        }
Exemple #13
0
        private static bool SerializeArray(IJsonSerializerStrategy jsonSerializerStrategy, IEnumerable anArray, StringBuilder builder)
        {
            builder.Append("[");
            bool        flag       = true;
            IEnumerator enumerator = anArray.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object current = enumerator.Current;
                    if (!flag)
                    {
                        builder.Append(",");
                    }
                    if (!SerializeValue(jsonSerializerStrategy, current, builder))
                    {
                        return(false);
                    }
                    flag = false;
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            builder.Append("]");
            return(true);
        }
Exemple #14
0
        public static object DeserializeObject(string json, Type type, IJsonSerializerStrategy jsonSerializerStrategy)
        {
            object jsonObject = DeserializeObject(json);

            return(type == null || (jsonObject != null && ReflectionUtils.IsAssignableFrom(jsonObject.GetType(), type))
                       ? jsonObject
                       : (jsonSerializerStrategy ?? CurrentJsonSerializerStrategy).DeserializeObject(jsonObject, type));
        }
Exemple #15
0
        public static object DeserializeObject(string json, Type type, IJsonSerializerStrategy jsonSerializerStrategy)
        {
            object obj2 = DeserializeObject(json);

            if (jsonSerializerStrategy == null)
            {
            }
            return(((type != null) && ((obj2 == null) || !ReflectionUtils.IsAssignableFrom(obj2.GetType(), type))) ? CurrentJsonSerializerStrategy.DeserializeObject(obj2, type) : obj2);
        }
Exemple #16
0
        private static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
        {
            bool   success     = true;
            string stringValue = value as string;

            if (stringValue != null)
            {
                success = SerializeString(stringValue, builder);
            }
            else
            {
                IDictionary <string, object> dict = value as IDictionary <string, object>;
                if (dict != null)
                {
                    success = SerializeObject(jsonSerializerStrategy, dict.Keys, dict.Values, builder);
                }
                else
                {
                    IDictionary <string, string> stringDictionary = value as IDictionary <string, string>;
                    if (stringDictionary != null)
                    {
                        success = SerializeObject(jsonSerializerStrategy, stringDictionary.Keys, stringDictionary.Values, builder);
                    }
                    else
                    {
                        IEnumerable enumerableValue = value as IEnumerable;
                        if (enumerableValue != null)
                        {
                            success = SerializeArray(jsonSerializerStrategy, enumerableValue, builder);
                        }
                        else if (IsNumeric(value))
                        {
                            success = SerializeNumber(value, builder);
                        }
                        else if (value is bool)
                        {
                            builder.Append((bool)value ? "true" : "false");
                        }
                        else if (value == null)
                        {
                            builder.Append("null");
                        }
                        else
                        {
                            object serializedObject;
                            success = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out serializedObject);
                            if (success)
                            {
                                SerializeValue(jsonSerializerStrategy, serializedObject, builder);
                            }
                        }
                    }
                }
            }

            return(success);
        }
Exemple #17
0
        private static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
        {
            bool   flag    = true;
            string aString = value as string;

            if (aString != null)
            {
                flag = SimpleJson.SimpleJson.SerializeString(aString, builder);
            }
            else
            {
                IDictionary <string, object> dictionary1 = value as IDictionary <string, object>;
                if (dictionary1 != null)
                {
                    flag = SimpleJson.SimpleJson.SerializeObject(jsonSerializerStrategy, (IEnumerable)dictionary1.Keys, (IEnumerable)dictionary1.Values, builder);
                }
                else
                {
                    IDictionary <string, string> dictionary2 = value as IDictionary <string, string>;
                    if (dictionary2 != null)
                    {
                        flag = SimpleJson.SimpleJson.SerializeObject(jsonSerializerStrategy, (IEnumerable)dictionary2.Keys, (IEnumerable)dictionary2.Values, builder);
                    }
                    else
                    {
                        IEnumerable anArray = value as IEnumerable;
                        if (anArray != null)
                        {
                            flag = SimpleJson.SimpleJson.SerializeArray(jsonSerializerStrategy, anArray, builder);
                        }
                        else if (SimpleJson.SimpleJson.IsNumeric(value))
                        {
                            flag = SimpleJson.SimpleJson.SerializeNumber(value, builder);
                        }
                        else if (value is bool)
                        {
                            builder.Append(!(bool)value ? "false" : "true");
                        }
                        else if (value == null)
                        {
                            builder.Append("null");
                        }
                        else
                        {
                            object output;
                            flag = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out output);
                            if (flag)
                            {
                                SimpleJson.SimpleJson.SerializeValue(jsonSerializerStrategy, output, builder);
                            }
                        }
                    }
                }
            }
            return(flag);
        }
Exemple #18
0
        private static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
        {
            bool   flag = true;
            string text = value as string;

            if (text != null)
            {
                flag = SimpleJson.SerializeString(text, builder);
            }
            else
            {
                IDictionary <string, object> dictionary = value as IDictionary <string, object>;
                if (dictionary != null)
                {
                    flag = SimpleJson.SerializeObject(jsonSerializerStrategy, dictionary.Keys, dictionary.Values, builder);
                }
                else
                {
                    IDictionary <string, string> dictionary2 = value as IDictionary <string, string>;
                    if (dictionary2 != null)
                    {
                        flag = SimpleJson.SerializeObject(jsonSerializerStrategy, dictionary2.Keys, dictionary2.Values, builder);
                    }
                    else
                    {
                        IEnumerable enumerable = value as IEnumerable;
                        if (enumerable != null)
                        {
                            flag = SimpleJson.SerializeArray(jsonSerializerStrategy, enumerable, builder);
                        }
                        else if (SimpleJson.IsNumeric(value))
                        {
                            flag = SimpleJson.SerializeNumber(value, builder);
                        }
                        else if (value is bool)
                        {
                            builder.Append((!(bool)value) ? "false" : "true");
                        }
                        else if (value == null)
                        {
                            builder.Append("null");
                        }
                        else
                        {
                            object value2;
                            flag = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out value2);
                            if (flag)
                            {
                                SimpleJson.SerializeValue(jsonSerializerStrategy, value2, builder);
                            }
                        }
                    }
                }
            }
            return(flag);
        }
Exemple #19
0
        public static object DeserializeObject(string json, Type type, IJsonSerializerStrategy jsonSerializerStrategy)
        {
            object obj = DeserializeObject(json);

            if (!(type == null) && (obj == null || !ReflectionUtils.IsAssignableFrom(obj.GetType(), type)))
            {
                return((jsonSerializerStrategy ?? CurrentJsonSerializerStrategy).DeserializeObject(obj, type));
            }
            return(obj);
        }
Exemple #20
0
        public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy)
        {
            StringBuilder stringBuilder = new StringBuilder(2000);

            if (!SerializeValue(jsonSerializerStrategy, json, stringBuilder))
            {
                return(null);
            }
            return(stringBuilder.ToString());
        }
Exemple #21
0
        public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy)
        {
            StringBuilder builder = new StringBuilder(2000);

            if (SimpleJson.SimpleJson.SerializeValue(jsonSerializerStrategy, json, builder))
            {
                return(builder.ToString());
            }
            return((string)null);
        }
Exemple #22
0
        public static object DeserializeObject(string json, Type type, IJsonSerializerStrategy jsonSerializerStrategy = null)
        {
            object obj = PlayFabSimpleJson.DeserializeObject(json);

            if (type == null || (obj != null && ReflectionUtils.IsAssignableFrom(obj.GetType(), type)))
            {
                return(obj);
            }
            return((jsonSerializerStrategy ?? PlayFabSimpleJson.CurrentJsonSerializerStrategy).DeserializeObject(obj, type));
        }
        public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy)
        {
            StringBuilder stringBuilder = GetStringBuilder();
            bool          flag          = SimpleJsonTool.SerializeValue(jsonSerializerStrategy, json, stringBuilder);

            string res = (!flag) ? null : stringBuilder.ToString();

            RecycleStringBuilder(stringBuilder);
            return(res);
        }
		internal static Error Create(IDictionary<string, object> dict, IJsonSerializerStrategy strategy)
		{
			var error = new Error();
			error.FillValues(dict);
			object rootCause;
			if (!dict.TryGetValue("root_cause", out rootCause)) return error;

			var os = rootCause as object[];
			if (os == null) return error;
			error.RootCause = os.Select(o => (RootCause)strategy.DeserializeObject(o, typeof(RootCause))).ToList();
			return error;
		}
Exemple #25
0
        private static Error ReadRootCause(IDictionary <string, object> dict, IJsonSerializerStrategy strategy, Error error)
        {
            if (!dict.TryGetValue("root_cause", out var rootCause))
            {
                return(error);
            }

            if (!(rootCause is object[] os))
            {
                return(error);
            }
            error.RootCause = os.Select(o => (ErrorCause)strategy.DeserializeObject(o, typeof(ErrorCause))).ToList().AsReadOnly();
            return(error);
        }
Exemple #26
0
        protected static bool serializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
        {
            bool flag = true;

            if (value is string)
            {
                flag = serializeString((string)value, builder);
            }
            else if (value is IDictionary <string, object> )
            {
                IDictionary <string, object> dictionary = (IDictionary <string, object>)value;
                flag = serializeObject(jsonSerializerStrategy, dictionary.Keys, dictionary.Values, builder);
            }
            else if (value is IDictionary <string, string> )
            {
                IDictionary <string, string> dictionary2 = (IDictionary <string, string>)value;
                flag = serializeObject(jsonSerializerStrategy, dictionary2.Keys, dictionary2.Values, builder);
            }
            else if (value is IDictionary)
            {
                IDictionary dictionary3 = (IDictionary)value;
                flag = serializeObject(jsonSerializerStrategy, dictionary3.Keys, dictionary3.Values, builder);
            }
            else if (value is IEnumerable)
            {
                flag = serializeArray(jsonSerializerStrategy, (IEnumerable)value, builder);
            }
            else if (isNumeric(value))
            {
                flag = serializeNumber(value, builder);
            }
            else if (value is bool)
            {
                builder.Append((!(bool)value) ? "false" : "true");
            }
            else if (value == null)
            {
                builder.Append("null");
            }
            else
            {
                flag = jsonSerializerStrategy.serializeNonPrimitiveObject(value, out var output);
                if (flag)
                {
                    serializeValue(jsonSerializerStrategy, output, builder);
                }
            }
            return(flag);
        }
Exemple #27
0
        private static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
        {
            object obj2;
            bool   flag    = true;
            string aString = value as string;

            if (aString != null)
            {
                return(SerializeString(aString, builder));
            }
            IDictionary <string, object> dictionary = value as IDictionary <string, object>;

            if (dictionary != null)
            {
                return(SerializeObject(jsonSerializerStrategy, dictionary.Keys, dictionary.Values, builder));
            }
            IDictionary <string, string> dictionary2 = value as IDictionary <string, string>;

            if (dictionary2 != null)
            {
                return(SerializeObject(jsonSerializerStrategy, dictionary2.Keys, dictionary2.Values, builder));
            }
            IEnumerable anArray = value as IEnumerable;

            if (anArray != null)
            {
                return(SerializeArray(jsonSerializerStrategy, anArray, builder));
            }
            if (IsNumeric(value))
            {
                return(SerializeNumber(value, builder));
            }
            if (value is bool)
            {
                builder.Append(!((bool)value) ? "false" : "true");
                return(flag);
            }
            if (value == null)
            {
                builder.Append("null");
                return(flag);
            }
            flag = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out obj2);
            if (flag)
            {
                SerializeValue(jsonSerializerStrategy, obj2, builder);
            }
            return(flag);
        }
Exemple #28
0
        public static string SerializeObject(object json, IJsonSerializerStrategy jsonSerializerStrategy = null)
        {
            if (PlayFabSimpleJson._serializeObjectBuilder == null)
            {
                PlayFabSimpleJson._serializeObjectBuilder = new StringBuilder(2000);
            }
            PlayFabSimpleJson._serializeObjectBuilder.Length = 0;
            if (jsonSerializerStrategy == null)
            {
                jsonSerializerStrategy = PlayFabSimpleJson.CurrentJsonSerializerStrategy;
            }
            bool flag = PlayFabSimpleJson.SerializeValue(jsonSerializerStrategy, json, PlayFabSimpleJson._serializeObjectBuilder);

            return((!flag) ? null : PlayFabSimpleJson._serializeObjectBuilder.ToString());
        }
Exemple #29
0
        public RxSpyHttpServer()
        {
            _server = new HttpListener();
            Address = new Uri("http://localhost:" + GetRandomTcpPort() + "/rxspy/");

            _serializerStrategy = new RxSpyJsonSerializerStrategy();

            _server.Prefixes.Add(Address.AbsoluteUri);
            _server.Start();

            var cts = new CancellationTokenSource();

            _serverTask = Task.Factory.StartNew(() => Run(cts.Token));
            _cancellationTokenSource = cts;
        }
		internal static ServerError Create(IDictionary<string, object> dict, IJsonSerializerStrategy strategy)
		{
			object status, error;
			int statusCode = -1;
			if (dict.TryGetValue("status", out status))
				statusCode = Convert.ToInt32(status);

			if (!dict.TryGetValue("error", out error)) return null;

			return new ServerError
			{
				Status = statusCode,
				Error = (Error)strategy.DeserializeObject(error, typeof(Error))
			};
		}
Exemple #31
0
        public RxSpyHttpServer()
        {
            _server = new HttpListener();
            Address = new Uri("http://localhost:" + GetRandomTcpPort() + "/rxspy/");

            _serializerStrategy = new RxSpyJsonSerializerStrategy();

            _server.Prefixes.Add(Address.AbsoluteUri);
            _server.Start();

            var cts = new CancellationTokenSource();

            _serverTask = Task.Factory.StartNew(() => Run(cts.Token));
            _cancellationTokenSource = cts;
        }
Exemple #32
0
        private static bool SerializeValue(IJsonSerializerStrategy jsonSerializerStrategy, object value, StringBuilder builder)
        {
            var success = true;

            if (value is string stringValue)
            {
                return(SerializeString(stringValue, builder));
            }
            if (IsChar(value))
            {
                return(SerializeString(((char)value).ToString(), builder));
            }

            switch (value)
            {
            case IDictionary <string, object> dict:
                return(SerializeObject(jsonSerializerStrategy, dict.Keys, dict.Values, builder));

            case IDictionary <string, string> stringDictionary:
                return(SerializeObject(jsonSerializerStrategy, stringDictionary.Keys, stringDictionary.Values, builder));

            case IEnumerable enumerableValue:
                return(SerializeArray(jsonSerializerStrategy, enumerableValue, builder));
            }

            if (IsNumeric(value))
            {
                return(SerializeNumber(value, builder));
            }

            if (value is bool b)
            {
                builder.Append(b ? "true" : "false");
            }
            else if (value is null)
            {
                builder.Append("null");
            }
            else
            {
                success = jsonSerializerStrategy.TrySerializeNonPrimitiveObject(value, out var serializedObject);
                if (success)
                {
                    SerializeValue(jsonSerializerStrategy, serializedObject, builder);
                }
            }
            return(success);
        }
Exemple #33
0
        internal static CausedBy Create(IDictionary <string, object> dict, IJsonSerializerStrategy strategy)
        {
            var    causedBy = new CausedBy();
            object reason;

            if (dict.TryGetValue("reason", out reason))
            {
                causedBy.Reason = Convert.ToString(reason);
            }
            object type;

            if (dict.TryGetValue("type", out type))
            {
                causedBy.Type = Convert.ToString(type);
            }
            return(causedBy);
        }
		internal static RootCause Create(IDictionary<string, object> dict, IJsonSerializerStrategy strategy)
		{
			var rootCause = new RootCause();
			rootCause.FillValues(dict);
			return rootCause;
		}
		internal static CausedBy Create(IDictionary<string, object> dict, IJsonSerializerStrategy strategy)
		{
			var causedBy = new CausedBy();
			object reason;
			if (dict.TryGetValue("reason", out reason)) causedBy.Reason = Convert.ToString(reason);
			object type;
			if (dict.TryGetValue("type", out type)) causedBy.Type = Convert.ToString(type);
			return causedBy;
		}