Exemple #1
0
        /// <summary>
        /// This method adds an override setting and clears the cache.
        /// </summary>
        /// <typeparam name="P"></typeparam>
        /// <param name="pipeline">The Microservice pipeline.</param>
        /// <param name="settings">The settings key value pair.</param>
        /// <param name="fnInclude">This function can be used to filter specific keys.</param>
        /// <param name="priority">This is the default priority for the arguments, which is 1000.</param>
        /// <returns>Returns the pipeline.</returns>
        public static P ConfigurationSetFromConsoleArgs <P>(this P pipeline, Dictionary <string, string> settings
                                                            , Func <string, string, bool> fnInclude = null, int priority = 1000)
            where P : IPipeline
        {
            if (settings == null)
            {
                throw new ArgumentNullException("settings", "Settings cannot be null.");
            }

            if (settings.Count > 0)
            {
                if (fnInclude == null)
                {
                    fnInclude = (k, v) => true;
                }

                ConfigResolverMemory cfResolver = new ConfigResolverMemory();

                settings
                .Where((k) => fnInclude(k.Key, k.Value))
                .ForEach((k) => cfResolver.Add(k.Key, k.Value));

                pipeline.Configuration.ResolverSet(priority, cfResolver);

                pipeline.Configuration.CacheFlush();
            }

            return(pipeline);
        }
Exemple #2
0
        /// <summary>
        /// This method clears the resolvers from the collection.
        /// </summary>
        public void ResolversClear()
        {
            mConfigResolvers.Clear();
            //Set the default override resolver for manual settings that override the base settings.
            var resolver = new ConfigResolverMemory();

            mConfigResolvers.AddOrUpdate(int.MaxValue, resolver, (k, v) => resolver);
        }