コード例 #1
0
            /// <summary>
            /// 从当前程序集加载
            /// </summary>
            /// <returns></returns>
            private static MusicSources Load()
            {
                Assembly    assembly  = Assembly.GetExecutingAssembly();
                List <Type> hostTypes = new List <Type>();

                foreach (var type in assembly.GetExportedTypes())
                {
                    if (type.Name == "MusicSources")
                    {
                        continue;
                    }

                    if (type.IsClass && typeof(IMusicSource).IsAssignableFrom(type) && !type.IsAbstract) //确定type为类并且继承实现接口实例
                    {
                        hostTypes.Add(type);
                    }
                }

                MusicSources musicSources = new MusicSources();

                foreach (var type in hostTypes)
                {
                    IMusicSource instance = (IMusicSource)Activator.CreateInstance(type);
                    musicSources.AddMusicSource(instance);
                }

                return(musicSources);
            }
コード例 #2
0
 private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     CurrentSource = _loadedPlugins[plListSelection.SelectedIndex];
     QualityDropDown.Items.Clear();
     QualityDropDown.Items.AddRange(CurrentSource.MusicQualityList);
     CurrentQuality    = QualityDropDown.SelectedItem?.ToString() ?? "";
     plAuthor.Text     = CurrentSource.Author;
     plVer.Text        = CurrentSource.MusicSourceVersion;
     interfaceVer.Text = CurrentSource.InterfaceVersion;
     formats.Text      = string.Join("/", CurrentSource.MusicQualityList);
 }
コード例 #3
0
 public void AddMusicSource(IMusicSource Source)
 {
     Sources.Add(Source);
     type2Source.Add(Source.Name, Source);
 }
コード例 #4
0
ファイル: Room.cs プロジェクト: jpmarr/kookbox
 private async Task<Option<IPlayer>> GetPlayerForSourceAsync(IMusicSource source)
 {
     // todo: may have specific player preference here
     IPlayer player;
     if (!players.TryGetValue(source, out player))
     {
         var sourcePlayer = await source.RequestAvailablePlayerAsync(this);
         sourcePlayer.IfHasValue(p =>
         {
             players.Add(source, p);
             SubscribePlayerEvents(p);
         });
         return sourcePlayer;
     }
     return Option.Create(player);
 }