コード例 #1
0
        /// <summary>
        /// Loads the provider which is configured in applicaiton config file (app.config / web.config)
        /// <example>
        /// <![CDATA[<?xml version="1.0" encoding="utf-8" ?>]]>
        ///	<configSections>
        ///	<section name="indexusNetSharedCache" type="SharedCache.WinServiceCommon.Configuration.Client.IndexusProviderSection, SharedCache.WinServiceCommon" />
        ///	</configSections>
        ///
        /// <indexusNetSharedCache defaultProvider="IndexusSharedCacheProvider">
        ///		<servers>
        ///		   <add key="Server1"	ipaddress="10.0.0.3" port="48888" />
        ///		   <add key="Server2"	ipaddress="10.0.0.4" port="48888" />
        ///		</servers>
        ///		<providers>
        ///		   <add
        ///		     name="IndexusSharedCacheProvider"
        ///		     type="SharedCache.WinServiceCommon.Provider.Cache.IndexusSharedCacheProvider, SharedCache.WinServiceCommon" />
        ///		 </providers>
        ///	</indexusNetSharedCache>
        /// </example>
        /// </summary>
        private static void LoadProvider()
        {
            #region Access Log
                        #if TRACE
            {
                Handler.LogHandler.Tracking("Access Method: " + typeof(IndexusDistributionCache).FullName + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;");
            }
                        #endif
            #endregion Access Log

            if (_providerBase == null)
            {
                lock (BulkObject)
                {
                    if (_providerBase == null)
                    {
                        // get a reference to the <cacheProvider> section
                        _providerSection = (IndexusProviderSection)WebConfigurationManager.GetSection("indexusNetSharedCache");

                        // load registered provider and point provider base to the default provider
                        _providerCollection = new IndexusProviderCollection();
                        ProvidersHelper.InstantiateProviders(
                            _providerSection.Providers,
                            _providerCollection,
                            typeof(IndexusProviderBase)
                            );

                        _providerBase = _providerCollection[_providerSection.DefaultProvider];

                        if (_providerBase == null)
                        {
                            throw new ProviderException(@"Unable to load default Shared Cache Provider!");
                        }
                    }
                }
            }
        }
コード例 #2
0
		/// <summary>
		/// Loads the provider which is configured in applicaiton config file (app.config / web.config)
		/// <example>
		/// <![CDATA[<?xml version="1.0" encoding="utf-8" ?>]]>
		///	<configSections>
		///	<section name="indexusNetSharedCache" type="SharedCache.WinServiceCommon.Configuration.Client.IndexusProviderSection, SharedCache.WinServiceCommon" />
		///	</configSections>
		/// 
		/// <indexusNetSharedCache defaultProvider="IndexusSharedCacheProvider">
		///		<servers>
		///		   <add key="Server1"	ipaddress="10.0.0.3" port="48888" />
		///		   <add key="Server2"	ipaddress="10.0.0.4" port="48888" />
		///		</servers>
		///		<providers>
		///		   <add
		///		     name="IndexusSharedCacheProvider"
		///		     type="SharedCache.WinServiceCommon.Provider.Cache.IndexusSharedCacheProvider, SharedCache.WinServiceCommon" />
		///		 </providers>
		///	</indexusNetSharedCache>
		/// </example>
		/// </summary>
		private static void LoadProvider()
		{
			#region Access Log
			#if TRACE
			
			{
				Handler.LogHandler.Tracking("Access Method: " + typeof(IndexusDistributionCache).FullName + "->" + ((object)MethodBase.GetCurrentMethod()).ToString() + " ;");
			}
			#endif
			#endregion Access Log

			if (providerBase == null)
			{
				lock (bulkObject)
				{
					if (providerBase == null)
					{
						// get a reference to the <cacheProvider> section
						providerSection = (IndexusProviderSection)WebConfigurationManager.GetSection("indexusNetSharedCache");

						// load registered provider and point provider base to the default provider
						providerCollection = new IndexusProviderCollection();
						ProvidersHelper.InstantiateProviders(
																providerSection.Providers,
								providerCollection,
								typeof(IndexusProviderBase)
							);

						providerBase = providerCollection[providerSection.DefaultProvider];

						if (providerBase == null)
						{
							throw new ProviderException(@"Unable to load default Shared Cache Provider!");
						}
					}
				}
			}
		}