public void LoadWrongVersion() { TypePrompt prompt = new TypePrompt(); prompt.SubjectTypeName = GetType().AssemblyQualifiedName.Replace("1.0.0.0", "3.0.0.0"); Assert.NotNull(prompt.TypeFullName); }
/// <summary> /// Get all strings. /// </summary> /// <param name="culture">Culture to get prompts for</param> /// <returns>A colleciton of prompts (or an empty collection)</returns> public virtual IEnumerable<TypePrompt> GetPrompts(CultureInfo culture) { if (culture == null) throw new ArgumentNullException("culture"); var prompts = new List<TypePrompt>(); var baseAttribte = typeof (ValidationAttribute); var attributes = typeof (RequiredAttribute).Assembly.GetTypes().Where( p => baseAttribte.IsAssignableFrom(p) && !p.IsAbstract).ToList(); foreach (var type in attributes) { var key = new TypePromptKey(type.FullName, "class"); var typePrompt = new TypePrompt { Key = key, LocaleId = CultureInfo.CurrentUICulture.LCID, TypeFullName = type.FullName, TextName = "class", UpdatedAt = DateTime.Now, UpdatedBy = Thread.CurrentPrincipal.Identity.Name }; var value = GetString(type, culture); if (value != null) { typePrompt.TranslatedText = DefaultUICulture.IsActive ? value : ""; } prompts.Add(typePrompt); } return prompts; }
/// <summary> /// Create or update a prompt /// </summary> /// <param name="culture">Culture that the prompt is for</param> /// <param name="fullTypeName">Type.FullName for the type being localized</param> /// <param name="name">Property name and any additonal names (such as metadata name, use underscore as delimiter)</param> /// <param name="translatedText">Translated text string</param> public void Save(CultureInfo culture, string fullTypeName, string name, string translatedText) { if (culture == null) { throw new ArgumentNullException("culture"); } if (fullTypeName == null) { throw new ArgumentNullException("fullTypeName"); } if (name == null) { throw new ArgumentNullException("name"); } if (translatedText == null) { throw new ArgumentNullException("translatedText"); } if (fullTypeName.IndexOf(".") == -1) { throw new ArgumentException("You must use Type.FullName", "fullTypeName"); } var lang = GetLanguage(culture); var key = new TypePromptKey(fullTypeName, name); var prompt = lang.Get(key); if (prompt == null) { prompt = new TypePrompt { Key = key, LocaleId = culture.LCID, TypeFullName = fullTypeName, TextName = name, TranslatedText = translatedText, UpdatedAt = DateTime.Now, UpdatedBy = Thread.CurrentPrincipal.Identity.Name }; lang.Add(prompt); } prompt.TranslatedText = translatedText; SaveLanguage(culture, lang); }
/// <summary> /// Initializes a new instance of the <see cref="TypePromptDocument"/> class. /// </summary> /// <param name="culture">The culture.</param> /// <param name="prompt">The prompt.</param> public TypePromptDocument(CultureInfo culture, TypePrompt prompt) { if (culture == null) { throw new ArgumentNullException("culture"); } if (prompt == null) { throw new ArgumentNullException("prompt"); } FullTypeName = prompt.TypeFullName; TypeName = prompt.TypeName; TextName = prompt.TextName; TextKey = prompt.Key.ToString(); LocaleId = culture.LCID; UpdatedAt = prompt.UpdatedAt; UpdatedBy = prompt.UpdatedBy; Text = prompt.TranslatedText; }
/// <summary> /// Get all strings. /// </summary> /// <param name="culture">Culture to get prompts for</param> /// <returns>A colleciton of prompts (or an empty collection)</returns> public virtual IEnumerable <TypePrompt> GetPrompts(CultureInfo culture) { if (culture == null) { throw new ArgumentNullException("culture"); } var prompts = new List <TypePrompt>(); var baseAttribte = typeof(ValidationAttribute); var attributes = typeof(RequiredAttribute).Assembly.GetTypes().Where( p => baseAttribte.IsAssignableFrom(p) && !p.IsAbstract).ToList(); foreach (var type in attributes) { var key = new TypePromptKey(type.FullName, "class"); var typePrompt = new TypePrompt { Key = key, LocaleId = CultureInfo.CurrentUICulture.LCID, TypeFullName = type.FullName, TextName = "class", UpdatedAt = DateTime.Now, UpdatedBy = Thread.CurrentPrincipal.Identity.Name }; var value = GetString(type, culture); if (value != null) { typePrompt.TranslatedText = DefaultUICulture.IsActive ? value : ""; } prompts.Add(typePrompt); } return(prompts); }
public void LoadWrongVersion() { TypePrompt prompt = new TypePrompt(); Assert.NotNull(prompt.TypeFullName); }
public static string Show(string message) { var prompt = new TypePrompt(); return(prompt.Show(message)); }
public static (bool, string) ShowQuitable(string message) { var prompt = new TypePrompt(); return(prompt.ShowQuitable(message)); }
public void LoadWrongVersion() { TypePrompt prompt = new TypePrompt(); Assert.IsNull(prompt.TypeFullName); }