Exemple #1
0
        /// <summary>
        /// This method sets a new resolver in the config hierarchy.
        /// </summary>
        /// <param name="priority">The priorty level, which should be below int max.</param>
        /// <param name="resolver">The resolver.</param>
        public void ResolverSet(int priority, ConfigResolver resolver)
        {
            if (priority == int.MaxValue)
            {
                throw new ArgumentOutOfRangeException("priority", "priority cannot be int max as that is a reserved value");
            }
            if (resolver == null)
            {
                throw new ArgumentNullException("resolver cannot be null");
            }

            mConfigResolvers.AddOrUpdate(priority, resolver, (k, v) => resolver);
        }
Exemple #2
0
        /// <summary>
        /// Sets a configuration resolver for the Microservice.
        /// </summary>
        /// <typeparam name="P">The pipeline type.</typeparam>
        /// <param name="pipeline">The pipeline.</param>
        /// <param name="priority">The resolver priority.</param>
        /// <param name="resolver">The resolver class.</param>
        /// <param name="assign">The pre-assignment method.</param>
        /// <returns>The pipeline.</returns>
        /// <exception cref="ArgumentNullException">The pipeline cannot be null</exception>
        public static P ConfigResolverSet <P>(this P pipeline, int priority, ConfigResolver resolver, Action <ConfigResolver> assign = null)
            where P : IPipeline
        {
            if (pipeline == null)
            {
                throw new ArgumentNullException("pipeline cannot be null");
            }

            assign?.Invoke(resolver);

            pipeline.Configuration.ResolverSet(priority, resolver);

            return(pipeline);
        }