Beispiel #1
0
        internal static Boolean CanCreateSubProxy(Type targetType)
        {
            ObservedType oType = GetObservedType(targetType);

            if (oType == null)
            {
                return(false);
            }
            return(oType.CanCreateSubProxy());
        }
Beispiel #2
0
        /// <summary>
        /// 根据类型创建它的代理类。如果代理不存在,返回 null。
        /// 如果方法非虚,不可以创建,那么抛出异常。
        /// </summary>
        /// <param name="targetType"></param>
        /// <returns></returns>
        public static Object CreateProxyBySub(Type targetType)
        {
            if (targetType == null)
            {
                throw new NullReferenceException("targetType");
            }

            ObservedType oType = GetObservedType(targetType);

            if (oType == null)
            {
                return(null);
            }
            if (oType.CanCreateSubProxy() == false)
            {
                String exMsg = "method not virtual. type=" + targetType.FullName + ", method=" + oType.GetNotVirtualMethodString();
                logger.Error(exMsg);
                throw new MethodNotVirtualException(exMsg);
            }

            return(createProxyBySub(targetType));
        }