示例#1
0
        private static void SetValueBinder(IocContainer container, ValueServiceBinder item)
        {
            var type = item.ExpectType ?? EmptyType;

            container.CacheTypeName.AddOrUpdate(type, t =>
            {
                var dict        = new ConcurrentDictionary <string, ICallSite>(StringComparer.CurrentCultureIgnoreCase);
                dict[item.Name] = item.CallSite;
                return(dict);
            }, (t, dict) =>
            {
                dict[item.Name] = item.CallSite;
                return(dict);
            });
        }
示例#2
0
        private IIocContainer InnerAddValue(Type expectType, string name, Func <ValueServiceBinder, IServiceBuilder> callback, bool promote)
        {
            if (expectType == null)
            {
                throw new ArgumentNullException(nameof(expectType));
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            var binder = new ValueServiceBinder(this, null, expectType, name);

            callback(binder);
            var container = this;

            do
            {
                SetValueBinder(container, binder);
            } while(promote && container._hasParent && (container = container.Parent) != null);

            return(this);
        }