Exemple #1
0
        /// <summary>
        /// Initializes this class.
        /// </summary>
        private void Initialize()
        {
            var plugInApplicationAttribute = SpsHelper.GetAttribute <PlugInApplicationAttribute>(GetType());

            Name = plugInApplicationAttribute == null?GetType().Name : plugInApplicationAttribute.Name;

            PlugIns = new List <IApplicationPlugIn <TPlugIn> >();
        }
Exemple #2
0
        /// <summary>
        /// Loads all PlugIns in PlugInFolder directory.
        /// </summary>
        public void LoadPlugIns()
        {
            if (string.IsNullOrEmpty(PlugInFolder) || !Directory.Exists(PlugInFolder))
            {
                throw new ApplicationException("PlugInFoler must be a valid folder path");
            }

            var assemblyFiles = SpsHelper.FindAssemblyFiles(PlugInFolder);
            var plugInType    = typeof(TPlugIn);

            foreach (var assemblyFile in assemblyFiles)
            {
                var allTypes = Assembly.LoadFrom(assemblyFile).GetTypes();
                foreach (var type in allTypes)
                {
                    if (plugInType.IsAssignableFrom(type) && type.IsClass && !type.IsAbstract)
                    {
                        PlugIns.Add(new ApplicationPlugIn <TPlugIn>(this, type));
                    }
                }
            }

            PlugInsLoaded = true;
        }
Exemple #3
0
 /// <summary>
 /// Default Constructor.
 /// </summary>
 public PlugInBasedApplication()
 {
     Initialize();
     PlugInFolder = SpsHelper.GetCurrentDirectory();
 }