/// <summary> /// Creates a local score object from a score processor. /// </summary> /// <param name="processor"></param> /// <param name="md5"></param> /// <param name="name"></param> /// <param name="scrollSpeed"></param> /// <returns></returns> public static Score FromScoreProcessor(ScoreProcessor processor, string md5, string name, int scrollSpeed, int pauseCount) { var score = new Score() { MapMd5 = md5, Name = name, DateTime = $"{System.DateTime.Now.ToShortDateString()} {System.DateTime.Now.ToShortTimeString()}", Mode = processor.Map.Mode, TotalScore = processor.Score, Grade = processor.Failed ? Grade.F : GradeHelper.GetGradeFromAccuracy(processor.Accuracy), Accuracy = processor.Accuracy, MaxCombo = processor.MaxCombo, CountMarv = processor.CurrentJudgements[Judgement.Marv], CountPerf = processor.CurrentJudgements[Judgement.Perf], CountGreat = processor.CurrentJudgements[Judgement.Great], CountGood = processor.CurrentJudgements[Judgement.Good], CountOkay = processor.CurrentJudgements[Judgement.Okay], CountMiss = processor.CurrentJudgements[Judgement.Miss], Mods = processor.Mods, ScrollSpeed = scrollSpeed, PauseCount = pauseCount, JudgementBreakdown = GzipHelper.Compress(processor.GetJudgementBreakdown()), }; return(score); }
public void Gzip() { var utf8 = new UTF8Encoding(false, true); const string rawString = "HelloWorld你好世界"; var rawBytes = utf8.GetBytes(rawString); var zippedBytes = GzipHelper.Compress(rawBytes); var unzippedBytes = GzipHelper.UnCompressToBytes(zippedBytes); var result = utf8.GetString(unzippedBytes); Assert.AreEqual(rawString, result); }
public void Gzip压缩字符串() { string str1 = "aaaaaaaaaaaaaaaaaa"; // 压缩字符串 string base64 = GzipHelper.Compress(str1); // 解压缩 string str2 = GzipHelper.Decompress(base64); Assert.AreEqual(str1, str2); }
public void Test_Gzip压缩字符串() { string s = @" using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; "; string b = GzipHelper.Compress(s); string s2 = GzipHelper.Decompress(b); Assert.AreEqual(s, s2); }
public void Test_Gzip压缩二进制字节() { string s = @" using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; "; byte[] bb = Encoding.UTF8.GetBytes(s); byte[] b1 = GzipHelper.Compress(bb); byte[] b2 = GzipHelper.Decompress(b1); Assert.AreEqual(bb.Length, b2.Length); for (int i = 0; i < bb.Length; i++) { Assert.AreEqual((int)bb[i], (int)b2[i]); } }