Exemple #1
0
        //////////////////////////////////////////////////////////////
        /// <summary>
        ///   This factory method returns the appropriate resolver to
        ///   the consumer.  The definition of "appropriate" is left
        ///   to the implementation of the config resolver.
        /// </summary>
        /// <param name="key">the key to be tested</param>
        /// <param name="supplier">the potential new supplier</param>
        /// <param name="current">the current supplier</param>
        //////////////////////////////////////////////////////////////

        public virtual IConfigResolver GetResolver(string key,
                                                   IConfigSupplier supplier,
                                                   IConfigResolver current)
        {
            IConfigResolver cr = null;

            if (_debug.IsActive)
            {
                _debug.WriteLine("template:  getting resolver for key:  " + key);
                _debug.WriteLine("template:  supplier:  " + supplier);
                _debug.WriteLine("template:  current:  " + current);
            }

            // only do something if the supplier can read the key
            if (supplier.CanRead(key))
            {
                cr = new DefaultConfigResolver(key, supplier);
            }
            else
            {
                return(current);
            }

            // if we get here, the supplier can read the key, so
            // it is just a matter of hooking up the relationships
            if (current != null)
            {
                current.Parent = cr;
                cr             = current;
            }

            return(cr);
        }
Exemple #2
0
        //////////////////////////////////////////////////////////////
        /// <summary>
        ///   This factory method returns the appropriate resolver to
        ///   the consumer.  The definition of "appropriate" is left
        ///   to the implementation of the config resolver.
        /// </summary>
        /// <param name="key">the key to be tested</param>
        /// <param name="supplier">the potential new supplier</param>
        /// <param name="current">the current supplier</param>
        //////////////////////////////////////////////////////////////

        public override IConfigResolver GetResolver(string key,
                                                    IConfigSupplier supplier,
                                                    IConfigResolver current)
        {
            // unfortunately, this is pretty much cut-n-paste code
            // reuse from the base class... :(

            IConfigResolver cr = null;

            // only do something if the supplier can read the key
            if (supplier.CanRead(key))
            {
                cr = new WriteCaptureConfigResolver(key,
                                                    supplier, _write);
            }
            else
            {
                return(current);
            }

            // if we get here, the supplier can read the key, so
            // it is just a matter of hooking up the relationships
            if (current != null)
            {
                current.Parent = cr;
                cr             = current;
            }

            return(cr);
        }