Beispiel #1
0
        /// <summary>
        /// 创建代理类
        /// </summary>
        /// <param name="target">服务实例</param>
        /// <param name="bindData">服务绑定数据</param>
        /// <returns>如果构建成功则返回服务透明代理实例,否则返回服务实例</returns>
        public object Bound(object target, BindData bindData)
        {
            if (target == null)
            {
                return(null);
            }

            var interceptors = bindData.GetInterceptors();

            if (interceptors == null)
            {
                return(target);
            }

            IInterceptingProxy proxy = null;

            if (target is MarshalByRefObject)
            {
                if (target.GetType().IsDefined(typeof(AopAttribute), false))
                {
                    proxy = CreateRealProxy(target);
                }
            }

            if (proxy == null)
            {
                return(target);
            }

            AddInterceptions(proxy, interceptors);
            return(proxy.GetTransparentProxy());
        }