/// <summary> /// 挂接子节点 /// </summary> /// <param name="childNode"></param> /// <returns></returns> public bool AttachChild(CTreeNode childNode) { if (childNode == null) { return(false); } if (childNode.m_NodeParent != null) { return(false); } UInt32 uChildID = childNode.GetNodeID(); if (ContainChild(uChildID) == true) { return(false); } // 挂接到父节点 childNode.m_NodeParent = this; // 添加到子节点 if (m_Children == null) { m_Children = new QuickList <UInt32, CTreeNode>(); } if (m_Children.Add(uChildID, childNode) == false) { childNode.m_NodeParent = null; return(false); } return(true); }
/// <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); }
/// <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); }
// 初始化方法数据 private bool InitMethodRelfector(Type type) { if (type == null || type.IsClass == false) { return(false); } if (m_MethodInfoList == null) { return(false); } MethodInfo[] methodInfoArray = type.GetMethods(); Int32 nPropSize = methodInfoArray == null ? 0 : methodInfoArray.Length; for (Int32 i = 0; i < nPropSize; ++i) { MethodInfo info = methodInfoArray[i]; if (info == null) { continue; } CMethodAttribute[] cusAttrArray = info.GetCustomAttributes(typeof(CMethodAttribute), false) as CMethodAttribute[]; Int32 nAttrSize = cusAttrArray == null ? 0 : cusAttrArray.Length; for (Int32 nAttrIndex = 0; nAttrIndex < nAttrSize; ++nAttrIndex) { CMethodAttribute attribute = cusAttrArray[nAttrIndex]; if (attribute == null) { continue; } string strName = attribute.GetName(); if (string.IsNullOrEmpty(strName) == true || m_MethodInfoList.Add(strName, info) == false) { BTDebug.Warning(string.Format("<BTRELFECT> Type:{0} Add Method Info:{1} Failed", type.Name, strName)); continue; } } } return(true); }
// 初始化属性数据 private bool InitPropertyRelfector(Type type) { if (type == null || type.IsClass == false) { return(false); } if (m_PropertyInfoList == null) { return(false); } PropertyInfo[] propertyInfoArray = type.GetProperties(); Int32 nPropSize = propertyInfoArray == null ? 0 : propertyInfoArray.Length; for (Int32 i = 0; i < nPropSize; ++i) { PropertyInfo info = propertyInfoArray[i]; if (info == null) { continue; } CPropertyAttribute[] cusAttrArray = info.GetCustomAttributes(typeof(CPropertyAttribute), false) as CPropertyAttribute[]; Int32 nAttrSize = cusAttrArray == null ? 0 : cusAttrArray.Length; for (Int32 nAttrIndex = 0; nAttrIndex < nAttrSize; ++nAttrIndex) { CPropertyAttribute attribute = cusAttrArray[nAttrIndex]; string strName = attribute.GetName(); if (string.IsNullOrEmpty(strName) == true || m_PropertyInfoList.Add(strName, info) == false) { BTDebug.Warning(string.Format("Type:{0} Add Property Info:{1} Failed", type.Name, strName), "RELFECT"); continue; } } } return(true); }