mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Fix GetInstances method to use calling assembly
This commit is contained in:
parent
d3fb5ac7bd
commit
f0e0b7e463
4 changed files with 5 additions and 31 deletions
|
@ -1059,10 +1059,11 @@ public static string ParseJSON(string text, string jsonPath)
|
||||||
|
|
||||||
public static T[] GetInstances<T>() where T : class
|
public static T[] GetInstances<T>() where T : class
|
||||||
{
|
{
|
||||||
return (from t in Assembly.GetExecutingAssembly().GetTypes()
|
var instances = from t in Assembly.GetCallingAssembly().GetTypes()
|
||||||
where t.GetInterfaces().Contains(typeof(T))
|
where t.IsClass && t.IsSubclassOf(typeof(T)) && t.GetConstructor(Type.EmptyTypes) != null
|
||||||
&& t.GetConstructor(Type.EmptyTypes) != null
|
select Activator.CreateInstance(t) as T;
|
||||||
select Activator.CreateInstance(t) as T).ToArray();
|
|
||||||
|
return instances.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,10 +24,7 @@ You should have received a copy of the GNU General Public License
|
||||||
#endregion License Information (GPL v3)
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
using ShareX.HelpersLib;
|
using ShareX.HelpersLib;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ShareX.UploadersLib
|
namespace ShareX.UploadersLib
|
||||||
{
|
{
|
||||||
|
|
|
@ -396,8 +396,6 @@ public bool IsValid(ImageDestination destination)
|
||||||
|
|
||||||
switch (destination)
|
switch (destination)
|
||||||
{
|
{
|
||||||
case ImageDestination.Imgur:
|
|
||||||
return ImgurAccountType == AccountType.Anonymous || OAuth2Info.CheckOAuth(ImgurOAuth2Info);
|
|
||||||
case ImageDestination.ImageShack:
|
case ImageDestination.ImageShack:
|
||||||
return ImageShackSettings != null && !string.IsNullOrEmpty(ImageShackSettings.Auth_token);
|
return ImageShackSettings != null && !string.IsNullOrEmpty(ImageShackSettings.Auth_token);
|
||||||
case ImageDestination.TinyPic:
|
case ImageDestination.TinyPic:
|
||||||
|
|
|
@ -818,28 +818,6 @@ public UploadResult UploadImage(Stream stream, string fileName)
|
||||||
{
|
{
|
||||||
switch (Info.TaskSettings.ImageDestination)
|
switch (Info.TaskSettings.ImageDestination)
|
||||||
{
|
{
|
||||||
case ImageDestination.Imgur:
|
|
||||||
if (Program.UploadersConfig.ImgurOAuth2Info == null)
|
|
||||||
{
|
|
||||||
Program.UploadersConfig.ImgurOAuth2Info = new OAuth2Info(APIKeys.ImgurClientID, APIKeys.ImgurClientSecret);
|
|
||||||
}
|
|
||||||
|
|
||||||
string albumID = null;
|
|
||||||
|
|
||||||
if (Program.UploadersConfig.ImgurUploadSelectedAlbum && Program.UploadersConfig.ImgurSelectedAlbum != null)
|
|
||||||
{
|
|
||||||
albumID = Program.UploadersConfig.ImgurSelectedAlbum.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
imageUploader = new Imgur(Program.UploadersConfig.ImgurOAuth2Info)
|
|
||||||
{
|
|
||||||
UploadMethod = Program.UploadersConfig.ImgurAccountType,
|
|
||||||
DirectLink = Program.UploadersConfig.ImgurDirectLink,
|
|
||||||
ThumbnailType = Program.UploadersConfig.ImgurThumbnailType,
|
|
||||||
UseGIFV = Program.UploadersConfig.ImgurUseGIFV,
|
|
||||||
UploadAlbumID = albumID
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
case ImageDestination.ImageShack:
|
case ImageDestination.ImageShack:
|
||||||
Program.UploadersConfig.ImageShackSettings.ThumbnailWidth = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredWidth;
|
Program.UploadersConfig.ImageShackSettings.ThumbnailWidth = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredWidth;
|
||||||
Program.UploadersConfig.ImageShackSettings.ThumbnailHeight = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredHeight;
|
Program.UploadersConfig.ImageShackSettings.ThumbnailHeight = Info.TaskSettings.AdvancedSettings.ThumbnailPreferredHeight;
|
||||||
|
|
Loading…
Reference in a new issue