Пример #1
0
        /// <summary>
        /// Activation of components with ISolutionEvents.
        /// </summary>
        /// <param name="data"></param>
        public void updateActivation(ISolutionEvents data)
        {
            if (data == null)
            {
                Log.Debug("Bootloader: Changing of activation has been ignored.");
                return;
            }

            foreach (IComponent c in Registered)
            {
                if (data.Components == null || data.Components.Length < 1)
                {
                    //c.Enabled = true;
                    continue;
                }

                Configuration.Component found = data.Components.Where(p => p.ClassName == c.GetType().Name).FirstOrDefault();
                if (found == null)
                {
                    continue;
                }

#if DEBUG
                if (c.Enabled != found.Enabled)
                {
                    Log.Trace("Bootloader - Component '{0}': Changing of activation status '{1}' -> '{2}'", found.ClassName, c.Enabled, found.Enabled);
                }
#endif
                c.Enabled = found.Enabled;
            }
        }
Пример #2
0
 /// <summary>
 /// Update list of components from configuration set
 /// </summary>
 /// <param name="components"></param>
 public void updateComponents(Configuration.Component[] components)
 {
     Settings.Cfg.Components = components;
     foreach (IComponent c in bootloader.Registered)
     {
         Configuration.Component found = components.Where(p => p.ClassName == c.GetType().Name).FirstOrDefault();
         if (found != null)
         {
             c.Enabled = found.Enabled;
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Refresh list of components
        /// </summary>
        /// <param name="grid"></param>
        public void fillComponents(DataGridView grid)
        {
            grid.Rows.Clear();
            foreach (IComponent c in bootloader.Registered)
            {
                Type type = c.GetType();
                if (!Inspector.isComponent(type))
                {
                    continue;
                }

                bool   enabled   = c.Enabled;
                string className = c.GetType().Name;

                Configuration.Component[] cfg = Settings.Cfg.Components;
                if (cfg != null && cfg.Length > 0)
                {
                    Configuration.Component v = cfg.Where(p => p.ClassName == className).FirstOrDefault();
                    if (v != null)
                    {
                        enabled = v.Enabled;
                    }
                }

                cInfo[className] = new List <INodeInfo>();
                bool withoutAttr = true;

                foreach (Attribute attr in type.GetCustomAttributes(true))
                {
                    if (attr.GetType() == typeof(ComponentAttribute) || attr.GetType() == typeof(DefinitionAttribute))
                    {
                        withoutAttr = false;
                    }

                    if (attr.GetType() == typeof(ComponentAttribute) && ((ComponentAttribute)attr).Parent == null)
                    {
                        fillComponents((ComponentAttribute)attr, enabled, className, grid);
                    }
                    else if (attr.GetType() == typeof(DefinitionAttribute) && ((DefinitionAttribute)attr).Parent == null)
                    {
                        DefinitionAttribute def = (DefinitionAttribute)attr;
                        grid.Rows.Add(DomIcon.definition, enabled, def.Name, className, def.Description);
                    }
                    else if (((DefinitionAttribute)attr).Parent != null)
                    {
                        cInfo[className].Add(new NodeInfo((DefinitionAttribute)attr));
                    }
                    else if (((ComponentAttribute)attr).Parent != null)
                    {
                        cInfo[className].Add(new NodeInfo((ComponentAttribute)attr));
                    }
                }

                if (withoutAttr)
                {
                    grid.Rows.Add(DomIcon.package, enabled, String.Empty, className, String.Empty);
                }
                cInfo[className].AddRange(new List <INodeInfo>(domElemsBy(className)));
            }
            grid.Sort(grid.Columns[2], System.ComponentModel.ListSortDirection.Descending);
        }