private static void ExamineAssembly(Assembly assembly) { // Loop through each type in the assembly foreach (Type thisType in assembly.GetTypes()) { // Only look at public types if (thisType.IsPublic) { // Ignore abstract classes if (!((thisType.Attributes & TypeAttributes.Abstract) == TypeAttributes.Abstract)) { // See if this type implements our interface Type implInterface = thisType.GetInterface(typeof(IRadioProvider).Name); if (implInterface != null) { Provider provider = new Provider(); provider.assembly = assembly; provider.fullClass = thisType.FullName; provider.Class = thisType.Name; try { IRadioProvider instance = (IRadioProvider)assembly.CreateInstance(thisType.FullName); provider.Id = instance.ProviderId; provider.Name = instance.ProviderName; provider.Description = instance.ProviderDescription; provider.Icon = instance.ProviderIcon; provider.ShowOptionsHandler = instance.GetShowOptionsHandler(); provider.ShowMoreProgInfoHandler = instance.GetShowMoreProgInfoHandler(); availableProviders.Add(instance.ProviderId, provider); } catch { continue; } } } } } }
private ListViewItem ProviderListItem(Provider provider) { ListViewItem addItem = new ListViewItem(); addItem.Name = provider.Id.ToString(); addItem.Text = provider.Name; if (provider.Icon != null) { this.ImagesProviders.Images.Add(provider.Id.ToString(), provider.Icon); addItem.ImageKey = provider.Id.ToString(); } else { addItem.ImageKey = "default"; } // Hide the 'No providers' provider options menu item if (this.MenuOptionsProviderOptsNoProvs.Visible) { this.MenuOptionsProviderOptsNoProvs.Visible = false; } MenuItem addMenuItem = new MenuItem(provider.Name + " Provider"); if (provider.ShowOptionsHandler != null) { addMenuItem.Click += provider.ShowOptionsHandler; } else { addMenuItem.Enabled = false; } this.MenuOptionsProviderOpts.MenuItems.Add(addMenuItem); return addItem; }
public static Provider[] GetAll() { Provider[] providers = new Provider[availableProviders.Values.Count]; availableProviders.Values.CopyTo(providers, 0); return providers; }
/// <summary> /// Initializes a new instance of the <see cref="ProviderException" /> class with a specified error message, /// a reference to the inner provider exception that is the cause of this exception, and the /// ID of the provider that is the cause of this exception. /// </summary> /// <param name="message">The message that describes the error.</param> /// <param name="innerException">The provider exception that is the cause of this exception.</param> /// <param name="pluginId">The ID of the provider that is the cause of this exception.</param> public ProviderException(string message, Exception innerException, Guid pluginId) : base(message, innerException) { this.ProviderId = pluginId; this.ProviderName = Provider.GetFromId(pluginId).Name; }