Example #1
0
        public static List <PluginBase> GetEnabledPluginMetadatas <T>() where T : PluginBase
        {
            var dict = PluginManagerCache.GetPluginSortedList();

            return(dict.Values.Where(
                       pluginInfo =>
                       pluginInfo.Plugin != null && !pluginInfo.IsDisabled &&
                       pluginInfo.Plugin is T
                       ).Select(pluginInfo => pluginInfo.Plugin).ToList());
        }
Example #2
0
        public static IMetadata GetMetadata(string pluginId)
        {
            var dict = PluginManagerCache.GetPluginSortedList();

            if (dict.TryGetValue(pluginId, out PluginInstance pluginInfo))
            {
                return(pluginInfo.Plugin);
            }
            return(null);
        }
Example #3
0
        public static List <PluginInfo> GetEnabledPluginInfoList <T1, T2>()
        {
            var dict = PluginManagerCache.GetPluginSortedList();

            return(dict.Values.Where(
                       pluginInfo =>
                       pluginInfo.Plugin != null && !pluginInfo.IsDisabled &&
                       (pluginInfo.Plugin is T1 || pluginInfo.Plugin is T2)
                       )
                   .ToList());
        }
Example #4
0
        public static bool IsExists(string pluginId)
        {
            if (string.IsNullOrEmpty(pluginId))
            {
                return(false);
            }

            var dict = PluginManagerCache.GetPluginSortedList();

            return(dict.ContainsKey(pluginId));
        }
Example #5
0
        public static PluginInstance GetPluginInfo(string pluginId)
        {
            if (string.IsNullOrEmpty(pluginId))
            {
                return(null);
            }

            var dict = PluginManagerCache.GetPluginSortedList();

            return(dict.TryGetValue(pluginId, out var pluginInfo) ? pluginInfo : null);
        }
Example #6
0
        public static List <T> GetEnabledFeatures <T>() where T : PluginBase
        {
            var dict = PluginManagerCache.GetPluginSortedList();

            var pluginInfos = dict.Values.Where(
                pluginInfo =>
                pluginInfo.Plugin != null && !pluginInfo.IsDisabled &&
                pluginInfo.Plugin is T
                )
                              .ToList();

            return(pluginInfos.Select(pluginInfo => (T)pluginInfo.Plugin).ToList());
        }
Example #7
0
        public static PluginBase GetPlugin(string pluginId)
        {
            if (string.IsNullOrEmpty(pluginId))
            {
                return(null);
            }

            var dict = PluginManagerCache.GetPluginSortedList();

            if (dict.TryGetValue(pluginId, out PluginInstance pluginInfo))
            {
                return(pluginInfo.Plugin);
            }
            return(null);
        }
Example #8
0
        public static PluginInfo GetPluginInfo(string pluginId)
        {
            if (string.IsNullOrEmpty(pluginId))
            {
                return(null);
            }

            var dict = PluginManagerCache.GetPluginSortedList();

            PluginInfo pluginInfo;

            if (dict.TryGetValue(pluginId, out pluginInfo))
            {
                return(pluginInfo);
            }
            return(null);
        }
Example #9
0
        public static IMetadata GetEnabledPluginMetadata <T>(string pluginId) where T : PluginBase
        {
            if (string.IsNullOrEmpty(pluginId))
            {
                return(null);
            }

            var dict = PluginManagerCache.GetPluginSortedList();

            var isGet = dict.TryGetValue(pluginId, out PluginInstance pluginInfo);

            if (isGet && pluginInfo.Plugin != null && !pluginInfo.IsDisabled &&
                pluginInfo.Plugin is T)
            {
                return(pluginInfo.Plugin);
            }
            return(null);
        }
Example #10
0
        public static T GetEnabledFeature <T>(string pluginId) where T : PluginBase
        {
            if (string.IsNullOrEmpty(pluginId))
            {
                return(default(T));
            }

            var dict = PluginManagerCache.GetPluginSortedList();

            PluginInfo pluginInfo;
            var        isGet = dict.TryGetValue(pluginId, out pluginInfo);

            if (isGet && pluginInfo.Plugin != null && !pluginInfo.IsDisabled &&
                pluginInfo.Plugin is T)
            {
                return((T)pluginInfo.Plugin);
            }
            return(default(T));
        }
Example #11
0
        public static Dictionary <string, string> GetPluginIdAndVersionDict()
        {
            var dict = PluginManagerCache.GetPluginSortedList();

            var retval = new Dictionary <string, string>();

            foreach (var pluginId in dict.Keys)
            {
                var pluginInfo = dict[pluginId];
                if (pluginInfo.Plugin != null)
                {
                    retval[pluginId] = pluginInfo.Plugin.Version;
                }
                else
                {
                    retval[pluginId] = string.Empty;
                }
            }

            return(retval);
        }
Example #12
0
        public static PluginInstance GetPluginInfo <T>() where T : PluginBase
        {
            var dict = PluginManagerCache.GetPluginSortedList();

            return(dict.Values.Where(instance => instance.Plugin is T).FirstOrDefault(instance => instance.IsRunnable && !instance.IsDisabled));
        }