public override void Load()
        {
            if (string.IsNullOrEmpty(this.contents))
            {
                return;
            }

            var data = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
            var parser = new PropertiesFileParser(this.contents, this.root);

            try
            {
                foreach (var pair in parser.GetItems())
                {
                    if (data.ContainsKey(pair.Key))
                    {
                        throw new FormatException($"The key '{pair.Key}' is duplicated.");
                    }

                    data[pair.Key] = pair.Value;
                }

                Data = data;
            }
            catch (Exception ex)
            {
                logger?.Log(new LogEntry(LogLevel.Error, string.Empty, "YamlProvider.Load", ex));
            }
        }
Ejemplo n.º 2
0
        public override void Load()
        {
            if (string.IsNullOrEmpty(this.contents))
            {
                return;
            }

            var data   = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase);
            var parser = new PropertiesFileParser(this.contents, this.root);

            try
            {
                foreach (var pair in parser.GetItems())
                {
                    if (data.ContainsKey(pair.Key))
                    {
                        throw new FormatException($"The key '{pair.Key}' is duplicated.");
                    }

                    data[pair.Key] = pair.Value;
                }

                Data = data;
            }
            catch (Exception ex)
            {
                logger?.Log(new LogEntry(LogLevel.Error, string.Empty, "YamlProvider.Load", ex));
            }
        }