Describes a single entry in a JSON property bag (a JSON object whose keys have arbitrary names and whose values may be any JSON values).
        public bool Equals(SerializedPropertyInfo other)
        {
            if (other == null)
            {
                return(false);
            }

            if (IsString != other.IsString)
            {
                return(false);
            }

            if (!ReferenceEquals(SerializedValue, other.SerializedValue))
            {
                if (SerializedValue == null || other.SerializedValue == null)
                {
                    return(false);
                }

                if (!SerializedValue.Equals(other.SerializedValue))
                {
                    return(false);
                }
            }

            return(true);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            var objectDictionary = new Dictionary <string, object>();

            serializer.Populate(reader, objectDictionary);

            var propertyDictionary = new Dictionary <string, SerializedPropertyInfo>();

            foreach (string key in objectDictionary.Keys)
            {
                object value        = objectDictionary[key];
                Type   propertyType = value?.GetType();

                string serializedValue = value?.ToString();
                bool   isString        = false;

                if (propertyType == typeof(bool))
                {
                    serializedValue = serializedValue.ToLowerInvariant();
                }
                else if (propertyType == typeof(string))
                {
                    serializedValue = JsonConvert.ToString(serializedValue);
                    isString        = true;
                }
                else if (propertyType == typeof(DateTime))
                {
                    // There's no need to worry about value being null here, because we know that
                    // Newtonsoft.Json recognized the value as a string that looks like a DateTime.
                    serializedValue = JsonConvert.SerializeObject(value);
                }

                SerializedPropertyInfo propInfo = value == null ? null : new SerializedPropertyInfo(serializedValue, isString);

                propertyDictionary.Add(key, propInfo);
            }

            return(propertyDictionary);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            IDictionary <string, SerializedPropertyInfo> dictionary = (existingValue as IDictionary <string, SerializedPropertyInfo> ?? new Dictionary <string, SerializedPropertyInfo>());

            reader.Read();

            while (reader.TokenType == JsonToken.PropertyName)
            {
                string name = (string)reader.Value;
                reader.Read();

                SerializedPropertyInfo value = SerializedPropertyInfoConverter.Read(reader);
                reader.Read();

                dictionary[name] = value;
            }

            return(dictionary);
        }
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            if (serializer == null)
            {
                throw new ArgumentNullException(nameof(serializer));
            }

            var objectDictionary = new Dictionary <string, object>();

            serializer.Populate(reader, objectDictionary);

            var propertyDictionary = new Dictionary <string, SerializedPropertyInfo>();

            foreach (string key in objectDictionary.Keys)
            {
                object value        = objectDictionary[key];
                Type   propertyType = value?.GetType();

                string serializedValue = value?.ToString();
                bool   isString        = false;

                if (propertyType == typeof(bool))
                {
                    serializedValue = serializedValue.ToLowerInvariant();
                }
                else if (propertyType == typeof(string))
                {
                    serializedValue = JsonConvert.ToString(serializedValue);
                    isString        = true;
                }

                SerializedPropertyInfo propInfo = value == null ? null : new SerializedPropertyInfo(serializedValue, isString);

                propertyDictionary.Add(key, propInfo);
            }

            return(propertyDictionary);
        }
        public bool Equals(SerializedPropertyInfo other)
        {
            if (other == null)
            {
                return false;
            }

            if (IsString != other.IsString)
            {
                return false;
            }

            if (!ReferenceEquals(SerializedValue, other.SerializedValue))
            {
                if (SerializedValue == null || other.SerializedValue == null)
                {
                    return false;
                }

                if (!SerializedValue.Equals(other.SerializedValue))
                {
                    return false;
                }
            }

            return true;
        }