Beispiel #1
0
        /// <summary>
        /// 存储缓存到缓存仓库
        /// </summary>
        /// <param name="strCacheKey"></param>
        /// <param name="cacheObject"></param>
        /// <returns></returns>
        public bool CacheCache(string strCacheKey, System.Object cacheObject)
        {
            if (string.IsNullOrEmpty(strCacheKey) == true ||
                cacheObject == null)
            {
                return(false);
            }
            if (m_Cache == null)
            {
                return(false);
            }
            CCacheSet cacheSet = null;

            if (m_Cache.QuickFind(strCacheKey, ref cacheSet) == false || cacheSet == null)
            {
                cacheSet = new CCacheSet(m_nCacheSetSize);
                if (m_Cache.Add(strCacheKey, cacheSet) == false)
                {
                    return(false);
                }
            }

            if (cacheSet.PushCache(cacheObject) == false)
            {
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// 设置属性值
        /// </summary>
        /// <param name="strName"></param>
        /// <param name="objEntity"></param>
        /// <param name="objValue"></param>
        /// <returns></returns>
        public bool SetValue(string strName, System.Object objEntity, System.Object objValue)
        {
            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.CanWrite == false)
            {
                return(false);
            }
            try
            {
                info.SetValue(objEntity, objValue, null);
            }
            catch (System.Exception ex)
            {
                BTDebug.Exception(ex);
                return(false);
            }
            return(true);
        }
Beispiel #3
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.Exception(ex);
                return(false);
            }
            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// 试图命中缓存
        /// </summary>
        /// <param name="strCacheKey"></param>
        /// <param name="rOutCacheObject"></param>
        /// <returns></returns>
        public bool TryHitCache(string strCacheKey, ref System.Object rOutCacheObject)
        {
            rOutCacheObject = null;
            if (string.IsNullOrEmpty(strCacheKey) == true)
            {
                return(false);
            }
#if BTDEBUG
            CCacheHitRatio cacheHit = null;
            if (m_CacheHitRatio.QuickFind(strCacheKey, ref cacheHit) == false || cacheHit == null)
            {
                cacheHit = new CCacheHitRatio();
                m_CacheHitRatio.Add(strCacheKey, cacheHit);
            }
#endif
            if (m_Cache == null)
            {
#if BTDEBUG
                cacheHit.MissTime += 1;
#endif
                return(false);
            }
            CCacheSet cacheSet = null;
            if (m_Cache.QuickFind(strCacheKey, ref cacheSet) == false ||
                cacheSet == null)
            {
#if BTDEBUG
                cacheHit.MissTime += 1;
#endif
                return(false);
            }

            rOutCacheObject = cacheSet.PopCache();
            if (rOutCacheObject == null)
            {
#if BTDEBUG
                cacheHit.MissTime += 1;
#endif
                return(false);
            }
#if BTDEBUG
            cacheHit.HitTime += 1;
#endif
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// 获取子节点
        /// </summary>
        /// <param name="uChildId"></param>
        /// <returns></returns>
        public CTreeNode GetChildNode(UInt32 uChildId)
        {
            if (m_Children == null)
            {
                return(null);
            }
            CTreeNode child = null;

            if (m_Children.QuickFind(uChildId, ref child) == false)
            {
                return(null);
            }
            return(child);
        }