mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Adding missing DeliciousSharingService
Moving validation outside of UploadersConfig, into separate class
This commit is contained in:
parent
e0ce2f68a7
commit
851ebecad0
7 changed files with 79 additions and 66 deletions
|
@ -209,6 +209,7 @@
|
||||||
<Compile Include="HelperClasses\OAuth\IOAuthBase.cs" />
|
<Compile Include="HelperClasses\OAuth\IOAuthBase.cs" />
|
||||||
<Compile Include="HelperClasses\SSLBypassHelper.cs" />
|
<Compile Include="HelperClasses\SSLBypassHelper.cs" />
|
||||||
<Compile Include="SharingService.cs" />
|
<Compile Include="SharingService.cs" />
|
||||||
|
<Compile Include="SharingServices\DeliciousSharingService.cs" />
|
||||||
<Compile Include="SharingServices\EmailSharingService.cs" />
|
<Compile Include="SharingServices\EmailSharingService.cs" />
|
||||||
<Compile Include="SharingServices\FacebookSharingService.cs" />
|
<Compile Include="SharingServices\FacebookSharingService.cs" />
|
||||||
<Compile Include="SharingServices\GooglePlusSharingService.cs" />
|
<Compile Include="SharingServices\GooglePlusSharingService.cs" />
|
||||||
|
@ -282,6 +283,7 @@
|
||||||
<Compile Include="TextUploaders\CustomTextUploader.cs" />
|
<Compile Include="TextUploaders\CustomTextUploader.cs" />
|
||||||
<Compile Include="TextUploaders\GitHubGist.cs" />
|
<Compile Include="TextUploaders\GitHubGist.cs" />
|
||||||
<Compile Include="TextUploaders\Paste_ee.cs" />
|
<Compile Include="TextUploaders\Paste_ee.cs" />
|
||||||
|
<Compile Include="UploadersConfigValidator.cs" />
|
||||||
<Compile Include="UploaderService.cs" />
|
<Compile Include="UploaderService.cs" />
|
||||||
<Compile Include="UploadResult.cs" />
|
<Compile Include="UploadResult.cs" />
|
||||||
<Compile Include="Forms\TwitterTweetForm.cs">
|
<Compile Include="Forms\TwitterTweetForm.cs">
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace ShareX.UploadersLib.SharingServices
|
||||||
|
{
|
||||||
|
public class DeliciousSharingService : SimpleSharingService
|
||||||
|
{
|
||||||
|
public override URLSharingServices EnumValue { get; } = URLSharingServices.Delicious;
|
||||||
|
protected override string UrlFormatString { get; } = "https://delicious.com/save?v=5&url={0}";
|
||||||
|
}
|
||||||
|
}
|
|
@ -350,68 +350,5 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
|
||||||
public int CustomURLShortenerSelected = 0;
|
public int CustomURLShortenerSelected = 0;
|
||||||
|
|
||||||
#endregion Custom Uploaders
|
#endregion Custom Uploaders
|
||||||
|
|
||||||
#region Helper Methods
|
|
||||||
|
|
||||||
public bool IsValid<T>(int index)
|
|
||||||
{
|
|
||||||
Enum destination = (Enum)Enum.ToObject(typeof(T), index);
|
|
||||||
|
|
||||||
if (destination is ImageDestination)
|
|
||||||
{
|
|
||||||
return IsValid((ImageDestination)destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (destination is TextDestination)
|
|
||||||
{
|
|
||||||
return IsValid((TextDestination)destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (destination is FileDestination)
|
|
||||||
{
|
|
||||||
return IsValid((FileDestination)destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (destination is UrlShortenerType)
|
|
||||||
{
|
|
||||||
return IsValid((UrlShortenerType)destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (destination is URLSharingServices)
|
|
||||||
{
|
|
||||||
return IsValid((URLSharingServices)destination);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValid(ImageDestination destination)
|
|
||||||
{
|
|
||||||
if (destination == ImageDestination.FileUploader) return true;
|
|
||||||
return UploaderFactory.GetImageUploaderServiceByEnum(destination).CheckConfig(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValid(TextDestination destination)
|
|
||||||
{
|
|
||||||
if (destination == TextDestination.FileUploader) return true;
|
|
||||||
return UploaderFactory.GetTextUploaderServiceByEnum(destination).CheckConfig(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValid(FileDestination destination)
|
|
||||||
{
|
|
||||||
return UploaderFactory.GetFileUploaderServiceByEnum(destination).CheckConfig(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValid(UrlShortenerType destination)
|
|
||||||
{
|
|
||||||
return UploaderFactory.GetURLShortenerServiceByEnum(destination).CheckConfig(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsValid(URLSharingServices destination)
|
|
||||||
{
|
|
||||||
return UploaderFactory.GetSharingServiceByEnum(destination).CheckConfig(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion Helper Methods
|
|
||||||
}
|
}
|
||||||
}
|
}
|
66
ShareX.UploadersLib/UploadersConfigValidator.cs
Normal file
66
ShareX.UploadersLib/UploadersConfigValidator.cs
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ShareX.UploadersLib
|
||||||
|
{
|
||||||
|
public static class UploadersConfigValidator
|
||||||
|
{
|
||||||
|
public static bool Validate<T>(int index, UploadersConfig config)
|
||||||
|
{
|
||||||
|
Enum destination = (Enum)Enum.ToObject(typeof(T), index);
|
||||||
|
|
||||||
|
if (destination is ImageDestination)
|
||||||
|
{
|
||||||
|
return Validate((ImageDestination)destination, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destination is TextDestination)
|
||||||
|
{
|
||||||
|
return Validate((TextDestination)destination, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destination is FileDestination)
|
||||||
|
{
|
||||||
|
return Validate((FileDestination)destination, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destination is UrlShortenerType)
|
||||||
|
{
|
||||||
|
return Validate((UrlShortenerType)destination, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (destination is URLSharingServices)
|
||||||
|
{
|
||||||
|
return Validate((URLSharingServices)destination, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Validate(ImageDestination destination, UploadersConfig config)
|
||||||
|
{
|
||||||
|
if (destination == ImageDestination.FileUploader) return true;
|
||||||
|
return UploaderFactory.GetImageUploaderServiceByEnum(destination).CheckConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Validate(TextDestination destination, UploadersConfig config)
|
||||||
|
{
|
||||||
|
if (destination == TextDestination.FileUploader) return true;
|
||||||
|
return UploaderFactory.GetTextUploaderServiceByEnum(destination).CheckConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Validate(FileDestination destination, UploadersConfig config)
|
||||||
|
{
|
||||||
|
return UploaderFactory.GetFileUploaderServiceByEnum(destination).CheckConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Validate(UrlShortenerType destination, UploadersConfig config)
|
||||||
|
{
|
||||||
|
return UploaderFactory.GetURLShortenerServiceByEnum(destination).CheckConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Validate(URLSharingServices destination, UploadersConfig config)
|
||||||
|
{
|
||||||
|
return UploaderFactory.GetSharingServiceByEnum(destination).CheckConfig(config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -191,7 +191,7 @@ private void AddDestination<T>(int index, EDataType dataType, TaskSettings taskS
|
||||||
{
|
{
|
||||||
Enum destination = (Enum)Enum.ToObject(typeof(T), index);
|
Enum destination = (Enum)Enum.ToObject(typeof(T), index);
|
||||||
|
|
||||||
if (Program.UploadersConfig.IsValid<T>(index))
|
if (UploadersConfigValidator.Validate<T>(index, Program.UploadersConfig))
|
||||||
{
|
{
|
||||||
RadioButton rb = new RadioButton() { AutoSize = true };
|
RadioButton rb = new RadioButton() { AutoSize = true };
|
||||||
|
|
||||||
|
|
|
@ -456,7 +456,7 @@ private void EnableDisableToolStripMenuItems<T>(params ToolStripDropDownItem[] p
|
||||||
{
|
{
|
||||||
for (int i = 0; i < parent.DropDownItems.Count; i++)
|
for (int i = 0; i < parent.DropDownItems.Count; i++)
|
||||||
{
|
{
|
||||||
parent.DropDownItems[i].Enabled = Program.UploadersConfig.IsValid<T>(i);
|
parent.DropDownItems[i].Enabled = UploadersConfigValidator.Validate<T>(i, Program.UploadersConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -550,7 +550,7 @@ private void EnableDisableToolStripMenuItems<T>(params ToolStripDropDownItem[] p
|
||||||
{
|
{
|
||||||
for (int i = 0; i < parent.DropDownItems.Count; i++)
|
for (int i = 0; i < parent.DropDownItems.Count; i++)
|
||||||
{
|
{
|
||||||
parent.DropDownItems[i].Enabled = Program.UploadersConfig.IsValid<T>(i);
|
parent.DropDownItems[i].Enabled = UploadersConfigValidator.Validate<T>(i, Program.UploadersConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue