mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
No need to null check uploader service anymore
This commit is contained in:
parent
134fc241c2
commit
47cda1eb29
4 changed files with 27 additions and 59 deletions
1
ShareX.UploadersLib/Forms/EmailForm.Designer.cs
generated
1
ShareX.UploadersLib/Forms/EmailForm.Designer.cs
generated
|
@ -86,6 +86,7 @@ private void InitializeComponent()
|
|||
//
|
||||
// EmailForm
|
||||
//
|
||||
this.AcceptButton = this.btnSend;
|
||||
resources.ApplyResources(this, "$this");
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.btnCancel;
|
||||
|
|
|
@ -280,7 +280,7 @@
|
|||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="btnSend.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>216, 232</value>
|
||||
<value>136, 232</value>
|
||||
</data>
|
||||
<data name="btnSend.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>72, 24</value>
|
||||
|
@ -307,7 +307,7 @@
|
|||
<value>Bottom, Right</value>
|
||||
</data>
|
||||
<data name="btnCancel.Location" type="System.Drawing.Point, System.Drawing">
|
||||
<value>136, 232</value>
|
||||
<value>216, 232</value>
|
||||
</data>
|
||||
<data name="btnCancel.Size" type="System.Drawing.Size, System.Drawing">
|
||||
<value>72, 24</value>
|
||||
|
@ -339,6 +339,9 @@
|
|||
<data name="$this.ClientSize" type="System.Drawing.Size, System.Drawing">
|
||||
<value>298, 265</value>
|
||||
</data>
|
||||
<data name="$this.StartPosition" type="System.Windows.Forms.FormStartPosition, System.Windows.Forms">
|
||||
<value>CenterScreen</value>
|
||||
</data>
|
||||
<data name="$this.Text" xml:space="preserve">
|
||||
<value>ShareX - Send Email</value>
|
||||
</data>
|
||||
|
|
|
@ -389,40 +389,24 @@ public bool IsValid<T>(int index)
|
|||
|
||||
public bool IsValid(ImageDestination destination)
|
||||
{
|
||||
if (destination != ImageDestination.FileUploader)
|
||||
{
|
||||
ImageUploaderService service = UploaderFactory.GetImageUploaderServiceByEnum(destination);
|
||||
if (service != null) return service.CheckConfig(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
if (destination == ImageDestination.FileUploader) return true;
|
||||
return UploaderFactory.GetImageUploaderServiceByEnum(destination).CheckConfig(this);
|
||||
}
|
||||
|
||||
public bool IsValid(TextDestination destination)
|
||||
{
|
||||
if (destination != TextDestination.FileUploader)
|
||||
{
|
||||
TextUploaderService service = UploaderFactory.GetTextUploaderServiceByEnum(destination);
|
||||
if (service != null) return service.CheckConfig(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
if (destination == TextDestination.FileUploader) return true;
|
||||
return UploaderFactory.GetTextUploaderServiceByEnum(destination).CheckConfig(this);
|
||||
}
|
||||
|
||||
public bool IsValid(FileDestination destination)
|
||||
{
|
||||
FileUploaderService service = UploaderFactory.GetFileUploaderServiceByEnum(destination);
|
||||
if (service != null) return service.CheckConfig(this);
|
||||
|
||||
return true;
|
||||
return UploaderFactory.GetFileUploaderServiceByEnum(destination).CheckConfig(this);
|
||||
}
|
||||
|
||||
public bool IsValid(UrlShortenerType destination)
|
||||
{
|
||||
URLShortenerService service = UploaderFactory.GetURLShortenerServiceByEnum(destination);
|
||||
if (service != null) return service.CheckConfig(this);
|
||||
|
||||
return true;
|
||||
return UploaderFactory.GetURLShortenerServiceByEnum(destination).CheckConfig(this);
|
||||
}
|
||||
|
||||
public bool IsValid(URLSharingServices destination)
|
||||
|
|
|
@ -806,11 +806,7 @@ private void DoAfterUploadJobs()
|
|||
|
||||
public UploadResult UploadImage(Stream stream, string fileName)
|
||||
{
|
||||
ImageUploaderService service = UploaderFactory.GetImageUploaderServiceByEnum(Info.TaskSettings.ImageDestination);
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
ImageUploader imageUploader = service.CreateUploader(Program.UploadersConfig);
|
||||
ImageUploader imageUploader = UploaderFactory.GetImageUploaderServiceByEnum(Info.TaskSettings.ImageDestination).CreateUploader(Program.UploadersConfig);
|
||||
|
||||
if (imageUploader != null)
|
||||
{
|
||||
|
@ -818,7 +814,6 @@ public UploadResult UploadImage(Stream stream, string fileName)
|
|||
|
||||
return imageUploader.Upload(stream, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -827,11 +822,7 @@ public UploadResult UploadText(Stream stream, string fileName)
|
|||
{
|
||||
Program.UploadersConfig.TextFormat = Info.TaskSettings.AdvancedSettings.TextFormat;
|
||||
|
||||
TextUploaderService service = UploaderFactory.GetTextUploaderServiceByEnum(Info.TaskSettings.TextDestination);
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
TextUploader textUploader = service.CreateUploader(Program.UploadersConfig);
|
||||
TextUploader textUploader = UploaderFactory.GetTextUploaderServiceByEnum(Info.TaskSettings.TextDestination).CreateUploader(Program.UploadersConfig);
|
||||
|
||||
if (textUploader != null)
|
||||
{
|
||||
|
@ -839,7 +830,6 @@ public UploadResult UploadText(Stream stream, string fileName)
|
|||
|
||||
return textUploader.UploadText(stream, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -862,11 +852,7 @@ public UploadResult UploadFile(Stream stream, string fileName)
|
|||
break;
|
||||
}
|
||||
|
||||
FileUploaderService service = UploaderFactory.GetFileUploaderServiceByEnum(fileDestination);
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
FileUploader fileUploader = service.CreateUploader(Program.UploadersConfig);
|
||||
FileUploader fileUploader = UploaderFactory.GetFileUploaderServiceByEnum(fileDestination).CreateUploader(Program.UploadersConfig);
|
||||
|
||||
if (fileUploader != null)
|
||||
{
|
||||
|
@ -874,24 +860,18 @@ public UploadResult UploadFile(Stream stream, string fileName)
|
|||
|
||||
return fileUploader.Upload(stream, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public UploadResult ShortenURL(string url)
|
||||
{
|
||||
URLShortenerService service = UploaderFactory.GetURLShortenerServiceByEnum(Info.TaskSettings.URLShortenerDestination);
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
URLShortener urlShortener = service.CreateShortener(Program.UploadersConfig);
|
||||
URLShortener urlShortener = UploaderFactory.GetURLShortenerServiceByEnum(Info.TaskSettings.URLShortenerDestination).CreateShortener(Program.UploadersConfig);
|
||||
|
||||
if (urlShortener != null)
|
||||
{
|
||||
return urlShortener.ShortenURL(url);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue