예제 #1
0
 /// <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,
     });
 }
예제 #2
0
        /// <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);
        }
예제 #3
0
        /// <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;
            }
        }