Exemplo n.º 1
0
        public static void LoadRazerChromaPlugins(this MainWindow mainWindow)
        {
            var effects  = new List <IChromaEffect>();
            var type     = typeof(IChromaEffect);
            var assembly = type.Assembly;

            effects.AddRange(AssemblyHelpers.LoadInstances <IChromaEffect>(assembly));

            var pluginDir = Path.Combine(Directory.GetCurrentDirectory(), "plugins");
            var files     = Directory.EnumerateFiles(pluginDir, "*.dll", SearchOption.TopDirectoryOnly);

            foreach (var file in files)
            {
                var plugin = AssemblyHelpers.LoadInstance <IChromaEffect>(file);
                if (plugin == null)
                {
                    continue;
                }

                Console.WriteLine($" [Plugin][{DateTime.Now}] {Path.GetFileName(file)} loaded.");
                effects.Add(plugin);
            }

            Effects = effects;
        }
Exemplo n.º 2
0
        public static IStreamablePlayerHost LoadPlayerHost <T>() where T : IStreamablePlayerHost
        {
            var type     = typeof(T);
            var assembly = type.Assembly;

            Metadata = AssemblyHelpers.LoadInstance <IPlayerMetadata>(assembly);
            var instance = Activator.CreateInstance(type) as IStreamablePlayerHost;

            return(instance);
        }
Exemplo n.º 3
0
        public static IEnumerable <IListenerPlugin> LoadPlugins()
        {
            var pluginDir = Path.Combine(Directory.GetCurrentDirectory(), "plugins");

            Directory.CreateDirectory(pluginDir);
            var files = Directory.EnumerateFiles(pluginDir, "*.dll", SearchOption.TopDirectoryOnly);

            foreach (var file in files)
            {
                var plugin = AssemblyHelpers.LoadInstance <IListenerPlugin>(file);
                if (plugin == null)
                {
                    continue;
                }

                Console.WriteLine($" [Plugin][{DateTime.Now}] {Path.GetFileName(file)} loaded.");
                yield return(plugin);
            }
        }