public static void InitController(Assembly assembly)
        {
            foreach (var row in assembly.GetTypes())
            {
                if (row.BaseType == typeof(ControllerBase))
                {
                    ControllerProtocolAttribute ca = row.GetCustomAttribute <ControllerProtocolAttribute>();

                    if (ca != null)
                    {
                        _controllerInitCache.Add(ca.ProtocolNumber, ReflectionUtil.CreateInstanceDelegate <ControllerContext>(row));
                    }
                }
            }
        }
        private static void InitEntity(Assembly assembly)
        {
            foreach (var row in assembly.GetTypes())
            {
                RedisTableAttribute rt = row.GetCustomAttribute <RedisTableAttribute>();
                if (rt != null)
                {
                    if (!_objectCache.ContainsKey(row))
                    {
                        _objectCache.Add(row, ReflectionUtil.CreateInstanceDelegate(row));
                    }

                    if (!_keyCache.ContainsKey(row))
                    {
                        foreach (var propertie in row.GetProperties())
                        {
                            RedisColumnAttribute redisColumn = propertie.GetCustomAttribute <RedisColumnAttribute>();
                            if (redisColumn != null && redisColumn.ColumnType == RedisColumnType.RedisKey)
                            {
                                _keyCache.Add(row,
                                              new ReflectionUtil(
                                                  ReflectionUtil.CreatePropertyGetter(propertie),
                                                  ReflectionUtil.CreatePropertySetter(propertie)
                                                  ));
                            }
                            if (redisColumn != null && redisColumn.ColumnType == RedisColumnType.RedisScore)
                            {
                                _scoreCache.Add(row, new ReflectionUtil(
                                                    ReflectionUtil.CreatePropertyGetter(propertie),
                                                    ReflectionUtil.CreatePropertySetter(propertie)
                                                    ));
                            }
                        }
                    }
                }
            }
        }
示例#3
0
 public static void InitGameUserType <T>()
 {
     _gameUserFunc = ReflectionUtil.CreateInstanceDelegate(typeof(T));
 }