Example #1
0
 void LoadChecker(ICheckerBase checker)
 {
     checkers.Add(checker);
     checker.StartEvent    += new CheckEven(checker_StartEvent);
     checker.MessageEvent  += new CheckEven(checker_MessageEvent);
     checker.FinalizeEvent += new CheckEven(checker_FinalizeEvent);
 }
Example #2
0
        /// <summary>
        /// Carga todos los checkes a ser ejecutados
        /// </summary>
        void LoadCheckers()
        {
            #region Cargo los checkers por defecto
            LoadChecker(new Check_DoNetFramework());
            LoadChecker(new Check_XP_SPK());
            LoadChecker(new Check_SQLServerAccess());
            #endregion

            #region Cargo los checkers por dinamicos
            CheckersAssemlist list = CheckersAssemlist.Load();
            if (list != null)
            {
                foreach (CheckersAssem assembly in list)
                {
                    try
                    {
                        if (assembly.Enabled)
                        {
                            ICheckerBase checker = (ICheckerBase)Helper.CreateInstance(assembly.Assembly);
                            LoadChecker(checker);
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            #endregion
        }
Example #3
0
 void LoadChecker(ICheckerBase checker)
 {
    
      checkers.Add(checker);
      checker.StartEvent += new CheckEven(checker_StartEvent);
      checker.MessageEvent += new CheckEven(checker_MessageEvent);
      checker.FinalizeEvent += new CheckEven(checker_FinalizeEvent);
 }
Example #4
0
        /// <summary>
        /// 开启新版序列化工具检查,检查两种反序列化得到的数据是否一致
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        /// <param name="start"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        private bool CheckImpl <T>(byte[] data, int start, int count, Socket socket) where T : class, IProtoBuffData, new()
        {
            if (!EnableCheck)
            {
                return(true);
            }

            ICheckerBase cb = null;

            if (!checkerDic.TryGetValue(typeof(T).FullName, out cb))
            {
                return(true);
            }

            T oldData = null;
            T newData = null;

            try
            {
                oldData = DataHelper.BytesToObject <T>(data, 0, count);
            }
            catch (Exception) { }

            try
            {
                newData = DataHelper.BytesToObject2 <T>(data, 0, count, socket);
            }
            catch (Exception) { }

            if (oldData == null && newData != null)
            {
                LogManager.WriteLog(LogTypes.Fatal, typeof(T).FullName + ", protobuf.net 解析数据为null,但是新解析方式不为null");
                return(false);
            }

            if (oldData != null && newData == null)
            {
                LogManager.WriteLog(LogTypes.Fatal, typeof(T).FullName + ", protobuf.net 解析数据不为null,但是新解析方式为null");
                return(false);
            }

            if (oldData == null && newData == null)
            {
                LogManager.WriteLog(LogTypes.Fatal, typeof(T).FullName + ", protobuf.net 解析数据为null,新解析方式为null");
                return(false);
            }

            if (!cb.Check(oldData, newData))
            {
                LogManager.WriteLog(LogTypes.Fatal, typeof(T).FullName + ", protobuf.net 解析数据不为null,新解析方式不为null,但是解析出来的数据不一致");
                return(false);
            }

            return(true);
        }