25개 이상의 토픽을 선택하실 수 없습니다.
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- using BPA.Helper;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.Business
- {
- public class Plugin : Singleton<Plugin>, IDisposable
- {
- private List<IPlugin> plugins = new List<IPlugin>();
-
- public void Dispose()
- {
- plugins.ForEach(p => p.Dispose());
- }
-
- public void Init()
- {
- this.GetType().Assembly.GetTypes().ToList().ForEach(plugin =>
- {
- if (plugin.GetInterfaces().Contains(typeof(IPlugin)))
- {
- plugins.Add((IPlugin)Activator.CreateInstance(plugin));
- }
- });
-
- plugins.ForEach(p => {
- p.Initialize();
- p.Start();
- });
- }
-
- public T GetPlugin<T>() where T : IPlugin
- {
- return (T)plugins.FirstOrDefault(p => p.GetType().Equals(typeof(T)));
- }
- }
- }
|