Ejemplo n.º 1
0
 /// <summary>
 /// 移除代理者
 /// </summary>
 /// <param name="realObject">真实对象</param>
 public void RemoveProxyer(IAspectTrackObject realObject)
 {
     if (ProxyObjects.ContainsKey(realObject))
     {
         ProxyObjects.Remove(realObject);
     }
     if (Proxys.ContainsKey(realObject))
     {
         Proxys.Remove(realObject);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取代理对象
 /// </summary>
 /// <typeparam name="T">代理对象类型</typeparam>
 /// <param name="realObject">真实对象</param>
 /// <returns>代理对象</returns>
 public T GetProxyObject <T>(IAspectTrackObject realObject) where T : class, IAspectTrackObject
 {
     if (ProxyObjects.ContainsKey(realObject))
     {
         return(ProxyObjects[realObject] as T);
     }
     else
     {
         Log.Warning("获取代理对象失败:真实对象 " + realObject.ToString() + " 并不存在代理对象!");
         return(null);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建代理者
        /// </summary>
        /// <typeparam name="T">代理对象类型</typeparam>
        /// <param name="proxyObject">代理者</param>
        /// <returns>代理对象</returns>
        public T CreateProxyer <T>(AspectProxyBase <T> proxyObject) where T : class, IAspectTrackObject
        {
            IAspectTrackObject proxyObj = proxyObject.GetTransparentProxy() as IAspectTrackObject;
            IAspectTrackObject realObj  = proxyObject.RealObject;

            if (!ProxyObjects.ContainsKey(realObj))
            {
                ProxyObjects.Add(realObj, proxyObj);
            }
            if (!Proxys.ContainsKey(realObj))
            {
                Proxys.Add(realObj, proxyObject);
            }

            return(proxyObj as T);
        }