示例#1
0
        /// <summary>
        /// NOTE: Code-generation-invoked method, method name and parameter order matters
        /// </summary>
        /// <param name="descriptor">descriptor</param>
        /// <param name="underlying">underlying</param>
        /// <param name="ex">exception</param>
        /// <returns>exception</returns>
        public static PropertyAccessException HandleException(
            DynamicPropertyDescriptorByMethod descriptor,
            object underlying,
            Exception ex)
        {
            if (ex is InvalidCastException invalidCastException)
            {
                throw PropertyUtility.GetMismatchException(descriptor.Method, underlying, invalidCastException);
            }

            if (ex is TargetException targetException)
            {
                throw PropertyUtility.GetTargetException(descriptor.Method, targetException);
            }

            if (ex is TargetInvocationException targetInvocationException)
            {
                throw PropertyUtility.GetTargetException(descriptor.Method, targetInvocationException);
            }

            if (ex is ArgumentException argumentException)
            {
                throw PropertyUtility.GetArgumentException(descriptor.Method, argumentException);
            }

            if (ex is MemberAccessException memberAccessException)
            {
                throw PropertyUtility.GetMemberAccessException(descriptor.Method, memberAccessException);
            }

            throw PropertyUtility.GetGeneralException(descriptor.Method, ex);
        }
示例#2
0
 public object GetBeanProp(object @object)
 {
     try {
         return _property.GetValue(@object);
     }
     catch (ArgumentException e) {
         throw PropertyUtility.GetArgumentException(_property, e);
     }
     catch (MemberAccessException e) {
         throw PropertyUtility.GetMemberAccessException(_property, e);
     }
     catch (TargetException e) {
         throw PropertyUtility.GetGeneralException(_property, e);
     }
 }