Esempio n. 1
0
        public Task GameGetSetting([FromForm] GameProviderType type)
        {
            IGameProvider iProvider = GameFactory.GetFactory(type, string.Empty);

            return(this.GetResult(new
            {
                Setting = iProvider == null ? new JsonString("[]") : new JsonString(iProvider.ToSetting())
            }));
        }
Esempio n. 2
0
        /// <summary>
        /// 创建游戏工厂实现
        /// </summary>
        /// <param name="type"></param>
        /// <param name="setting"></param>
        /// <returns></returns>
        public static IGameProvider GetFactory(GameProviderType type, string setting)
        {
            string key = $"{type}{setting.GetHash(8)}";

            return(MemoryUtils.Get(key, TimeSpan.FromHours(1), () =>
            {
                Type assembly = typeof(GameFactory).Assembly.GetType($"{typeof(GameFactory).Namespace}.Clients.{type}");
                if (assembly == null)
                {
                    return null;
                }
                return (IGameProvider)Activator.CreateInstance(assembly, setting);
            }));
        }
Esempio n. 3
0
        public Task SaveGameInfo([FromForm] int id, [FromForm] GameProviderType type, [FromForm] string name, [FromForm] string setting)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(this.ShowError("请输入供应商名称"));
            }
            if (type == 0)
            {
                return(this.ShowError("请选择类型"));
            }

            GameProvider provider = new GameProvider()
            {
                ID            = id,
                Name          = name,
                Type          = type,
                SettingString = setting
            };

            return(this.GetResult(ProviderAgent.Instance().SaveGameProvider(provider)));
        }