Exemple #1
0
 /// <summary>
 /// 开始计时
 /// </summary>
 public void StartNewCall()
 {
     if (m_stopwatch.IsRunning == true)
     {
         BTDebug.Warning("<BTDEBUG> Start A CPU Profiler While It is Running, Result will not be correct");
     }
     m_stopwatch.Start();
     m_nCallTime += 1;
 }
Exemple #2
0
        // 初始化方法数据
        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);
        }