Beispiel #1
0
        /// <summary>
        /// Sets the theme used to render the switchboard panels.
        /// </summary>
        public DigitalSystem GetSystem()
        {
            XmlSettingsItem item   = null;
            DigitalSystem   system = null;

            Logger.LogDebug(this, "[CLASS].GetSystem()");

            try
            {
                item = this.Settings.GetItem(SystemManager.SETTINGS_SYSTEMS_KEY);
                if (item != null)
                {
                    Assembly assembly = Assembly.LoadFrom(item.GetString(SystemManager.SETTINGS_SYSTEM_PATH));
                    if (assembly == null)
                    {
                        return(null);
                    }

                    Type type = assembly.GetType(item.GetString(SystemManager.SETTINGS_SYSTEM_CLASS));
                    if (type == null)
                    {
                        return(null);
                    }

                    system = (DigitalSystem)Activator.CreateInstance(type);
                }

                return(system);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);
                throw ex;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Get all theme instances included in the application directory.
        /// </summary>
        /// <returns>A list of all systems found.</returns>
        public List <DigitalSystem> GetAll()
        {
            Assembly             assembly;
            DigitalSystem        system  = null;
            List <DigitalSystem> systems = new List <DigitalSystem>();

            Logger.LogDebug(this, "[CLASS].GetAll()");

            try
            {
                foreach (string path in System.IO.Directory.GetFiles(ReflectionUtils.GetCurrentAssemblyPath(), "*.dll"))
                {
                    try
                    {
                        assembly = Assembly.LoadFile(path);
                        Type[] types = assembly.GetTypes();
                        foreach (Type type in types)
                        {
                            if (typeof(DigitalSystem).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract)
                            {
                                system = (DigitalSystem)Activator.CreateInstance(type);
                                if (system != null)
                                {
                                    systems.Add(system);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError(this, ex);
                    }
                }

                return(systems);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);
                throw ex;
            }
        }
Beispiel #3
0
 /// <summary>
 /// Sets the theme used to render the switchboard panels.
 /// </summary>
 public void SetSystem(DigitalSystem system)
 {
     this.SetSystem(system.GetType());
 }