Exemple #1
0
        public static ParseResult <ApplicationConfiguration> Parse(TextReader yamlStream)
        {
            var yamlSerializer = new Serializer(new SerializerSettings
            {
                NamingConvention = new CamelCaseNamingConvention(),
                EmitTags         = false
            });

            try
            {
                var configuration = yamlSerializer.Deserialize <ApplicationConfiguration>(yamlStream);

                var validator        = new Validator();
                var validationResult = validator.Validate(configuration);
                var parseResult      = new ParseResult <ApplicationConfiguration>(configuration, validationResult);

                foreach (var service in configuration.Services)
                {
                    parseResult.AddWarningsAndErrors(service.ParseTemplateOptions(yamlSerializer));
                }

                return(parseResult);
            }
            catch (YamlException e)
            {
                throw new ConfigParseException(e);
            }
        }