GetAndRemove() 공개 정적인 메소드

Gets and removes an value from the configuration section
public static GetAndRemove ( NameValueCollection config, string name, bool required ) : string
config System.Collections.Specialized.NameValueCollection Name value collection to examine
name string Name of the value to retrieve
required bool True if the value is required, false if optional
리턴 string
예제 #1
0
        public static IMemcachedClient GetClient(string name, NameValueCollection config, Func <ICouchbaseClientFactory> createDefault)
        {
            var factory = GetFactoryInstance(ProviderHelper.GetAndRemove(config, "factory", false), createDefault);

            System.Diagnostics.Debug.Assert(factory != null, "factory == null");

            return(factory.Create(name, config));
        }
        /// <summary>
        /// Returns a Couchbase bucket or create one if it does not exist
        /// </summary>
        /// <param name="name">Name of the section from the configuration file</param>
        /// <param name="config">Configuration section information from the config file</param>
        /// <returns>Instance of the couchbase bucket to use</returns>
        public IBucket GetBucket(
            string name,
            NameValueCollection config)
        {
            // Get the bucket name to use from the configuration file and use a specific bucket if specified
            var bucketName = ProviderHelper.GetAndRemove(config, "bucket", false);

            if (!string.IsNullOrEmpty(bucketName))
            {
                return(ClusterHelper.GetBucket(bucketName));
            }

            // If no bucket is specified, simply use the default bucket (which will be the first in the list)
            return(ClusterHelper.Get().OpenBucket());
        }
        public IMemcachedClient Create(string name, NameValueCollection config)
        {
            var sectionName = ProviderHelper.GetAndRemove(config, "section", false);

            if (String.IsNullOrEmpty(sectionName))
            {
                return(new CouchbaseClient());
            }

            var section = ConfigurationManager.GetSection(sectionName) as ICouchbaseClientConfiguration;

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

            return(new CouchbaseClient(section));
        }
예제 #4
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));
        }