コード例 #1
0
        /// <summary>
        /// Gets all Notification Types from the configuration file.
        /// </summary>
        /// <returns></returns>
        public List <NotificationTypes> GetNotificationTypes()
        {
            List <NotificationTypes> list = new List <NotificationTypes>();

            AlarmModuleConfigurationSection configSection = AlarmModuleConfiguration.Instance.Configuration;

            /* getting name, value and dynamic type flag from configuration file.  */
            foreach (NotificationTypeElement element in configSection.NotificationType)
            {
                list.Add(new NotificationTypes
                {
                    Name          = element.Name,
                    Value         = element.Value.ToInt(),
                    IsDynamicType = element.IsDynamicType.ToBoolean()
                });
            }

            return(list);
        }
コード例 #2
0
        public void Import()
        {
            //An aggregate catalog that combines multiple catalogs
            var catalog = new AggregateCatalog();

            //Adds all the parts found in all assemblies in current directory
            catalog.Catalogs.Add(
                new SafeDirectoryCatalog(
                    Path.GetDirectoryName(
                        Assembly.GetExecutingAssembly().Location)));

            //Create the CompositionContainer with the parts in the catalog
            CompositionContainer container = new CompositionContainer(catalog);


            //Fill the imports of this object
            container.ComposeParts(this);

            AlarmModuleConfigurationSection configSection = AlarmModuleConfiguration.Instance.Configuration;

            List <IModule> orderingModules = new List <IModule>();

            foreach (ModuleElement element in configSection.Modules)
            {
                foreach (IModule module in _processModules)
                {
                    if (module.GetType().FullName == element.ModuleType)
                    {
                        orderingModules.Add(module);
                        break;
                    }
                }
            }

            _processModules = orderingModules;
            LogBook.Write("Found and added modules from Config File");
        }