Example #1
0
        public static async Task GeneratePickBanStyleFileAsync(string sessID, string path)
        {
            PickAndBan pb      = new PickAndBan(sessID);
            string     json_in = JsonConvert.SerializeObject(pb, Formatting.Indented);

            byte[] tmp = Encoding.ASCII.GetBytes(json_in);
            while (IO_Related.IsFileLocked(new FileInfo(path), FileMode.Create, FileAccess.Write))
            {
            }
            using (var fs = File.Open(path, FileMode.Open, FileAccess.Write, FileShare.Write))
            {
                await fs.WriteAsync(tmp);
            }
        }
Example #2
0
        public static async Task GenerateChampionStyleFileAsync(string sessID, string path)
        {
            //init style per session
            string[] champion_name = Directory.GetFiles(UserDataConstant.ChampionSquareDir).Select(s => Path.GetFileName(s).Replace("_", "").Replace("Square.png", "").ToLower()).ToArray();
            //Util.Generate.SerializeStyleDic(champion_name, StylePerSess_path);
            ChampionStyle ch      = GenerateStyle(sessID, champion_name);
            string        json_in = JsonConvert.SerializeObject(ch, Formatting.Indented);

            byte[] tmp = Encoding.ASCII.GetBytes(json_in);
            while (IO_Related.IsFileLocked(new FileInfo(path), FileMode.Create, FileAccess.Write))
            {
            }
            using (var fs = File.Open(path, FileMode.Open, FileAccess.Write, FileShare.Write))
            {
                await fs.WriteAsync(tmp);
            }
        }