private void ValidateSettings(ProtectedSettings settings) { if (settings.Proxy == null) { settings.Proxy = new ProxySetting(); } ProxySetting proxy = settings.Proxy; if (Uri.CheckHostName(proxy.Host) == UriHostNameType.Unknown) { proxy.Host = string.Empty; } if (proxy.Port < 0 || proxy.Port > 65535) { proxy.Port = 8080; } if (settings.Profiles != null) { TwitterNameValidation twitterValidator = new TwitterNameValidation(); GuildNameValidationRule guildNameValidator = new GuildNameValidationRule(); foreach (var profile in settings.Profiles) { if (profile.News == null) { profile.News = new NewsData(); } if (profile.Login == null) { profile.Login = new LoginData(); } if (profile.Rotation == null) { profile.Rotation = new RotationData(); } if (profile.GameModel == null) { profile.GameModel = new GameModel(); } if (!twitterValidator.Validate(profile.News.TwitterUser, null).IsValid) { profile.News.TwitterUser = Utils.GetDefaultTwitter(); } if (profile.Rotation.Guild != null) { if (!guildNameValidator.Validate(profile.Rotation.Guild, null).IsValid) { profile.Rotation.Guild = string.Empty; } } } } }
public bool IsValidName(string name) { if (name == LanguageManager.Model.CommGuildName) { DialogManager.ShowErrorDialog(LanguageManager.Model.CommGuildNameEmpty); return(false); } GuildNameValidationRule validationRule = new GuildNameValidationRule(); ValidationResult result = validationRule.Validate(name, new System.Globalization.CultureInfo(1, false)); if (!result.IsValid) { DialogManager.ShowErrorDialog(result.ErrorContent.ToString()); } return(result.IsValid); }