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>()));
public static string GetName(this ValidatorDefinition validator, SourceDefinition sourceDefinition, string valueGenericName) => validator.GetValidatorName(sourceDefinition.GetValidatorValueType(valueGenericName, Option.Some(validator)));