Exemple #1
0
        public IMemcachedClient Create(string name, NameValueCollection config, out bool disposeClient)
        {
            // This client should be disposed of as it is not shared
            disposeClient = true;

            // Get the section name from the configuration file. If not found, create a default Couchbase client which
            // will get the configuration information from the default Couchbase client section in the Web.config file
            var sectionName = ProviderHelper.GetAndRemove(config, "section", false);

            if (String.IsNullOrEmpty(sectionName))
            {
                return(this.CreateClient(null));
            }

            // If a custom section name is passed in, get the section information and use it to construct the Couchbase client
            var section = ConfigurationManager.GetSection(sectionName);

            if (section == null)
            {
                throw new InvalidOperationException("Invalid config section: " + sectionName);
            }
            return(CreateClient(section));
        }