public void PrepareLocalization() { // If we don't have a localization key specified, then return. if (string.IsNullOrWhiteSpace(LocalizationKey)) { return; } // Fetch the service from the factory. IValidationLocalizationService localizationService = ValidationLocalizationFactory.CreateService(); // If we have a service, fetch and assign the localized failure message. if (localizationService != null) { string message = localizationService.GetLocalizedMessage(LocalizationKey); // Only replace the failure message if we receive a valid localized message. // This allows fallback values to be used while localization takes place. if (!string.IsNullOrWhiteSpace(message)) { FailureMessage = message; } } }
/// <summary> /// Creates a singleton instance of T that will be returned when CreateService is invoked. /// </summary> /// <typeparam name="T"></typeparam> public static void Initialize <T>() where T : class, IValidationLocalizationService, new() { _serviceSingleton = new T(); }