Exemplo n.º 1
0
        /// <summary>
        /// 调用方法
        /// </summary>
        /// <param name="strName"></param>
        /// <param name="objEntity"></param>
        /// <param name="objParamArray"></param>
        /// <param name="rOutReturnValue"></param>
        /// <returns></returns>
        public bool InvokeMethod(string strName, System.Object objEntity, System.Object[] objParamArray, out System.Object rOutReturnValue)
        {
            rOutReturnValue = default(System.Object);
            if (objEntity == null)
            {
                return(false);
            }

            MethodInfo info = null;

            if (m_MethodInfoList.QuickFind(strName, ref info) == false || info == null)
            {
                return(false);
            }
            if (objEntity.GetType() != info.DeclaringType &&
                objEntity.GetType().IsAssignableFrom(info.DeclaringType) == false)
            {
                return(false);
            }

            try
            {
                rOutReturnValue = info.Invoke(objEntity, objParamArray);
            }
            catch (System.Exception ex)
            {
                BTDebug.ExceptionEx(ex);
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取属性值
        /// </summary>
        /// <param name="strName"></param>
        /// <param name="objEntity"></param>
        /// <param name="rOutValue"></param>
        /// <returns></returns>
        public bool GetValue(string strName, System.Object objEntity, out System.Object rOutValue)
        {
            rOutValue = default(System.Object);
            if (objEntity == null)
            {
                return(false);
            }

            PropertyInfo info = null;

            if (m_PropertyInfoList.QuickFind(strName, ref info) == false || info == null)
            {
                return(false);
            }
            if (objEntity.GetType() != info.DeclaringType &&
                objEntity.GetType().IsAssignableFrom(info.DeclaringType) == false)
            {
                return(false);
            }
            if (info.CanRead == false)
            {
                return(false);
            }
            try
            {
                rOutValue = info.GetValue(objEntity, null);
            }
            catch (System.Exception ex)
            {
                BTDebug.ExceptionEx(ex);
                return(false);
            }
            return(true);;
        }