public StateManager(IndexValidationVisitor visitor, object newModel)
            {
                _visitor  = visitor;
                _newModel = newModel;

                _container = _visitor._container;
                _key       = _visitor._key;
                _metadata  = _visitor._metadata;
                _model     = _visitor._model;
                _strategy  = _visitor._strategy;
            }
        public void Validate(
            ModelStateDictionary modelState,
            ValidationStateDictionary validationState,
            string prefix,
            object model)
        {
            var visitor = new IndexValidationVisitor(
                modelState,
                _validatorProvider,
                _validatorCache,
                _modelMetadataProvider,
                validationState);

            var metadata = model == null ? null : _modelMetadataProvider.GetMetadataForType(model.GetType());

            visitor.Validate(metadata, prefix, model);
        }
            public static StateManager Recurse(
                IndexValidationVisitor visitor,
                string key,
                ModelMetadata metadata,
                object model,
                IValidationStrategy strategy)
            {
                var recursifier = new StateManager(visitor, model);

                visitor._container = visitor._model;
                visitor._key       = key;
                visitor._metadata  = metadata;
                visitor._model     = model;
                visitor._strategy  = strategy;

                return(recursifier);
            }