public async Task <bool> IsValid() { if (!(DataContext is GfycatPreset preset)) { return(false); } if (string.IsNullOrWhiteSpace(preset.Title)) { StatusBand.Warning(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.Title")); return(false); } if (UserSettings.All.UploadPresets.OfType <UploadPreset>().Any(a => a.Title != _originalTitle && a.Title == preset.Title.Trim())) { StatusBand.Warning(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.Repeated")); return(false); } if (!preset.IsAnonymous && !await Gfycat.IsAuthorized(preset)) { StatusBand.Warning(LocalizationHelper.Get("S.Options.Upload.Preset.Warning.Authenticate")); return(false); } return(true); }
public static async Task <ValidatedEventArgs> IsValid(GfycatPreset preset) { if (!preset.IsAnonymous && !await Gfycat.IsAuthorized(preset)) { return(new ValidatedEventArgs("S.SaveAs.Warning.Upload.NotAuthorized", StatusReasons.UploadServiceUnauthorized, () => App.MainViewModel.OpenOptions.Execute(Options.UploadIndex))); } return(await preset.IsValid()); }
public static async Task <ValidatedEventArgs> IsValid(UploadPreset preset) { if (!preset.IsAnonymous && !await Gfycat.IsAuthorized(preset)) { return(new ValidatedEventArgs("S.SaveAs.Warning.Upload.NotAuthorized", StatusReasons.UploadServiceUnauthorized, () => App.MainViewModel.OpenOptions.Execute(Options.UploadIndex))); } switch (preset) { case GfycatPreset gfycat: return(await IsValid(gfycat)); case ImgurPreset imgur: return(await IsValid(imgur)); case YandexPreset yandex: return(await IsValid(yandex)); } return(await preset.IsValid()); }