public static string Generate(SourceDefinition source)
        {
            IEnumerable <ValidatorGroups[]> paths;

            switch (source.ValueType)
            {
            case ValueType.Value:
                paths = Data.ValueValidationPaths;
                break;

            case ValueType.Array:
                paths = Data.ArrayValidationPaths;
                break;

            default:
                return(String.Empty);
            }

            var root = new ExtensionPathNode(null, null);

            foreach (var path in paths)
            {
                AddValidators(root, path);
            }

            var extensions = ExtensionGenerator.GenerateInvertExtensionOne(source)
                             .Concat(GenerateExtensions(source, root));

            var header = _header.Replace("__StateValidator__", source.GetSourceName(Option.None <string>()));

            return($"{header}{String.Join($"{Environment.NewLine}{Environment.NewLine}", extensions)}{_footer}");
        }
 private static string PopulateTemplate(string template, SourceDefinition sourceDefinition, string valueGenericName, string[] genericParameters, ValidatorDefinition validatorOne, ValidatorDefinition validatorTwo, ExtensionDefinition extension, bool invertOne, bool invertTwo)
 => template
 .Replace("__Nullable__", $"{(sourceDefinition.IsNullable ? "Nullable" : String.Empty)}")
 .Replace("__InvertOne__", $"{(invertOne ? "Inverted" : "Standard")}")
 .Replace("__InvertTwo__", $"{(invertTwo ? "Inverted" : "Standard")}")
 .Replace("__StateValidator__", sourceDefinition.GetSourceName(Option.Some(valueGenericName)))
 .Replace("__ValueValidatorOne__", validatorOne?.GetValidatorName(GetValueForValidator(sourceDefinition, validatorOne, valueGenericName)) ?? String.Empty)
 .Replace("__ValueValidatorTwo__", validatorTwo?.GetValidatorName(GetValueForValidator(sourceDefinition, validatorTwo, valueGenericName)) ?? String.Empty)
 .Replace("__NewValueValidator__", extension?.Validator.GetValidatorName(GetValueForValidator(sourceDefinition, extension?.Validator, valueGenericName)) ?? String.Empty)
 .Replace("__TValueType__", sourceDefinition.ValueType == ValueType.Array ? $"{valueGenericName}[]" : valueGenericName)
 .Replace("__ExtensionName__", extension?.ExtensionName ?? String.Empty)
 .Replace("__GenericParameters__", genericParameters.Any() ? $"<{String.Join(", ", genericParameters)}>" : String.Empty)
 .Replace("__ExtensionParameters__", String.Join(String.Empty, extension?.Parameters.Where(p => !p.Value.HasValue()).Select(p => $", {p.GetTypeName(GetValueForValidator(sourceDefinition, extension?.Validator, valueGenericName))} {p.Name}{p.DefaultValue.Match(v => $" = {v}", () => String.Empty)}") ?? Enumerable.Empty <string>()))
 .Replace("__Parameters__", String.Join(", ", extension?.Parameters.Select(p => p.Value.Match(v => v, () => p.Name)) ?? Enumerable.Empty <string>()));
 private static string PopulateTemplate(string template, SourceDefinition sourceDefinition, string valueGenericName, string[] genericParameters, ValidatorDefinition validatorOne, ValidatorDefinition validatorTwo, ExtensionDefinition extension, bool invertOne, bool invertTwo, bool joinSourceAndValue = false)
 => template
 .Replace("__InvertOne__", $"{(invertOne ? "Inverted" : "Standard")}")
 .Replace("__InvertTwo__", $"{(invertTwo ? "Inverted" : "Standard")}")
 .Replace("__Inverted__", $"{((extension?.Invert ?? false) ? "Inverted" : "Standard")}")
 .Replace("__DataContainerFactory__", sourceDefinition.GetDataContainerFactoryType())
 .Replace("__StateValidator__", sourceDefinition.GetSourceName(valueGenericName))
 .Replace("__TSourceType__", joinSourceAndValue ? valueGenericName : SourceGeneric)
 .Replace("__TValueType__", valueGenericName)
 .Replace("__TDataValueType__", sourceDefinition.GetDataValueType(valueGenericName))
 .Replace("__TValidatorValueType__", sourceDefinition.GetValidatorValueType(valueGenericName, Option.None <ValidatorDefinition>()))
 .Replace("__ValueValidatorOne__", validatorOne?.GetName(sourceDefinition, valueGenericName) ?? String.Empty)
 .Replace("__ValueValidatorTwo__", validatorTwo?.GetName(sourceDefinition, valueGenericName) ?? String.Empty)
 .Replace("__NewValueValidator__", extension?.Validator.GetName(sourceDefinition, valueGenericName) ?? String.Empty)
 .Replace("__ExtensionName__", extension?.ExtensionName ?? String.Empty)
 .Replace("__GenericParameters__", HelperExtensions.ConstructorGenericParameters(genericParameters, Option.Create(!joinSourceAndValue, SourceGeneric)))
 .Replace("__ExtensionParameters__", extension?.GetParameters(sourceDefinition, valueGenericName) ?? String.Empty)
 .Replace("__Arguments__", extension?.GetArguments() ?? String.Empty)
 .Replace("__NotOpen__", $"{((extension?.Invert ?? false) ? @".Not(s => s" : String.Empty)}")
 .Replace("__NotClose__", $"{((extension?.Invert ?? false) ? ")" : String.Empty)}");