/// <summary> /// Creates an object from an instance of a provider. /// </summary> /// <param name="provider"></param> /// <returns></returns> public static ReceiverFormatName Create(IReceiverFormatProvider provider) { return(new ReceiverFormatName() { UniqueId = provider.UniqueId, ShortName = provider.ShortName, }); }
/// <summary> /// See interface docs. /// </summary> /// <param name="providerId"></param> /// <returns></returns> public IReceiverFormatProvider GetProvider(string providerId) { Initialise(); IReceiverFormatProvider result = null; if (!String.IsNullOrEmpty(providerId)) { var map = _Providers; map.TryGetValue(providerId, out result); } return(result); }
/// <summary> /// See interface docs. /// </summary> /// <param name="provider"></param> public void RegisterProvider(IReceiverFormatProvider provider) { Initialise(); if (provider == null || String.IsNullOrEmpty(provider.UniqueId)) { throw new InvalidOperationException("You must supply a provider and the UniqueId property must return a non-null non-empty string"); } lock (_SyncLock) { var newMap = CollectionHelper.ShallowCopy(_Providers); if (newMap.ContainsKey(provider.UniqueId)) { newMap[provider.UniqueId] = provider; } else { newMap.Add(provider.UniqueId, provider); } _Providers = newMap; } }