Ejemplo n.º 1
0
        //run validation on a top level object, recurse sections, following in a Datafield to pull fqn
        public IValidationResponse Validate(IConfigurationRoot configuration, DataField rootDataField, bool root = false)
        {
            IValidationResponse response = new ValidationResponse();

            response.Passed = true;
            response.FQN    = rootDataField.Datatype.FQN;

            foreach (IConfigurationSection sect in configuration.GetChildren())
            {
                //match root datafields against config root children
                foreach (KeyValuePair <string, DataField> df in rootDataField.Members)
                {
                    if (df.Key == sect.Key)
                    {
                        var childresponse = Validate(sect, df.Value, root);
                        response.Passed = childresponse.Passed == false ? false : response.Passed;
                        response.ChildResponses.Add(childresponse);
                        break;
                    }
                }
            }
            return(response);
        }