Exemplo n.º 1
0
        public IProperties TryParse(String @string)
        {
            if (String.IsNullOrEmpty(@string))
            {
                return(null);
            }

            var properties = new MemoryProperties();

            foreach (var line in lineSplitter.SplitLines(@string))
            {
                if (line.TrimStart().StartsWith("#"))
                {
                    continue;
                }

                if (!line.Contains("="))
                {
                    continue;
                }

                var parts         = line.Split(new[] { '=' }, 2);
                var propertyName  = parts[0].Trim();
                var propertyValue = parts[1].Trim();

                properties.Set(propertyName, propertyValue);
            }

            return(properties);
        }
Exemplo n.º 2
0
 private static void Patch(MemoryProperties baseProperties, IProperties deltaProperties)
 {
     foreach (var property in deltaProperties.ToDictionary())
     {
         baseProperties.Set(property.Key, property.Value);
     }
 }
Exemplo n.º 3
0
        public IDictionary <String, String> ToDictionary()
        {
            var cascadedProperties = new MemoryProperties();

            for (var i = properties.Length - 1; i >= 0; i--)
            {
                Patch(cascadedProperties, properties[i]);
            }

            return(cascadedProperties.ToDictionary());
        }
Exemplo n.º 4
0
        public IDictionary <String, String> ToDictionary()
        {
            var properties = cache.TryRead();

            if (properties != null)
            {
                return(properties.ToDictionary());
            }

            properties = new MemoryProperties(source.ToDictionary());

            cache.Write(properties);

            return(properties.ToDictionary());
        }