Пример #1
0
        public static byte[] SaveReplay(ReplayContainer replayContainer)
        {
            JsonSerializer serializer = new JsonSerializer();

            serializer.ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor;

            //if (!System.IO.Directory.Exists(MapFolder)) {
            //    System.IO.Directory.CreateDirectory(MapFolder);
            //}

            //string fileName = replayContainer.RedTeamName + "_VS_" + replayContainer.BlueTeamName + "_" + DateTime.Now.ToString("yyyyMMddTHHmmss");

            byte[] data = null;
            //using (FileStream fileStream = File.Create(MapFolder + fileName + ".hcrep")) {
            using (MemoryStream ms = new MemoryStream()) {
                using (var zipStream = new GZipStream(ms, CompressionMode.Compress, true)) {
                    using (var streamWriter = new StreamWriter(zipStream)) {
                        using (var jsonWriter = new JsonTextWriter(streamWriter)) {
                            serializer.Serialize(jsonWriter, replayContainer);
                        }
                    }
                }
                data = ms.ToArray();
            }


            return(data);
        }
Пример #2
0
 public ReplayController(ReplayContainer replayContainer)
 {
     _ReplayContainer = replayContainer;
 }