Esempio n. 1
0
        public void Remove(Type expectType, string name, bool promote = false)
        {
            if (expectType == null)
            {
                throw new ArgumentNullException(nameof(expectType));
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }
            ConcurrentDictionary <string, ICallSite> dict;

            using (GA.Lock(expectType))
            {
                if (CacheTypeName.TryGetValue(expectType, out dict))
                {
                    ICallSite callSite;
                    dict.TryRemove(name, out callSite);
                }
            }
            if (this._hasParent && promote)
            {
                this.Parent.Remove(expectType, name, promote);
            }
        }
Esempio n. 2
0
        private object InnerGet(Type expectType, bool autoResolving, params object[] lastMappingValues)
        {
            if (expectType == null)
            {
                throw new ArgumentNullException(nameof(expectType));
            }

            using (GA.Lock(this.UUID + expectType.AssemblyQualifiedName))
            {
                var callSite = GetCallSite(this, expectType);
                if (callSite == null && autoResolving)
                {
                    callSite = this.AutoResolving(expectType, null);
                    if (callSite == null)
                    {
                        return(null);
                    }
                    CacheType.TryAdd(expectType, new List <ICallSite>(1)
                    {
                        callSite
                    });
                }
                return(callSite?.Invoke(lastMappingValues));
            }
        }