private static CaseInsensitiveDictionary <string> ConvertToDictionary(string[] propertyNamesAndValues)
        {
            var dictionary = new CaseInsensitiveDictionary <string>();

            for (var i = 0; i < propertyNamesAndValues.Length; i += 2)
            {
                dictionary.Add(propertyNamesAndValues[i], propertyNamesAndValues[i + 1]);
            }
            return(dictionary);
        }
        private bool SetPropertyValue(string value, Queue <string> path)
        {
            var key = path.Dequeue();

            if (path.Count == 0)
            {
                CheckSum = null;
                if (Properties == null)
                {
                    Properties = new CaseInsensitiveDictionary <string>();
                }
                Properties[key] = value;
                if (value != null)
                {
                    return(false);
                }
                // Remove the value
                Properties.Remove(key);
                if (Properties.Count != 0)
                {
                    return(false);
                }
                Properties = null;
                return(true);
            }

            var data = GetNestedProperty(key, true);

            if (data == null)
            {
                CheckSum = null;
                data     = new Data();
                NestedProperties[key] = data;
            }

            var remove = SetPropertyValue(value, path);

            if (!remove)
            {
                return(false);
            }
            NestedProperties.Remove(key);
            if (NestedProperties.Count != 0)
            {
                return(false);
            }
            NestedProperties = null;
            return(true);
        }
        public void Update(Data source)
        {
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            Properties = source.Properties == null ? null : new CaseInsensitiveDictionary <string>(source.Properties);

            if (source.NestedProperties == null)
            {
                NestedProperties = null;
            }
            else
            {
                NestedProperties = new CaseInsensitiveDictionary <Data>(source.NestedProperties.Count);
                foreach (var nestedProperty in source.NestedProperties)
                {
                    var data = new Data();
                    data.Update(nestedProperty.Value);
                    NestedProperties.Add(nestedProperty.Key, data);
                }
            }
        }
 public Data()
 {
     Properties = new CaseInsensitiveDictionary <string>();
 }