Example #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.Locking(expectType))
            {
                if (CacheTypeName.TryGetValue(expectType, out dict))
                {
                    ICallSite callSite;
                    dict.TryRemove(name, out callSite);
                }
            }
            if (this._hasParent && promote)
            {
                this.Parent.Remove(expectType, name, promote);
            }
        }
Example #2
0
 /// <summary>
 /// 销毁所有的映射。
 /// </summary>
 public virtual void DestroyAll()
 {
     CacheTypeName.Clear();
     CacheName.Clear();
     CacheType.Clear();
     GC.WaitForFullGCComplete();
 }
Example #3
0
        internal bool FindCallSite(Type expectType, string name, out ICallSite callSite)
        {
            ConcurrentDictionary <string, ICallSite> nameCallSites;

            if (CacheTypeName.TryGetValue(expectType, out nameCallSites) && nameCallSites.TryGetValue(name, out callSite))
            {
                return(true);
            }
            callSite = null;
            return(false);
        }