void OnWizardCreate() { string Allfile = ""; foreach (PuzzleComponent puzzle in Selection.activeGameObject.GetComponentsInChildren <PuzzleComponent>()) { Dictionary <Vector2, string> letterPos = new Dictionary <Vector2, string>(); WordSet wordset = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(puzzle.Content), wordset); foreach (SWord word in wordset.Words) { for (int i = 0; i < word.LocationList.Count; i++) { Vector2 l = word.LocationList[i]; if (letterPos.ContainsKey(l)) { if (letterPos[l] != word.Name[i].ToString()) { Allfile += $"کلمه : {word.Name} در جدول : {puzzle.Clue}+{puzzle.PuzzleData.Row} در مجموعه : {puzzle.transform.parent.GetComponent<CategoryComponent>().CategoryData.Name} \n"; break; } } else { letterPos.Add(l, word.Name[i].ToString()); } } } } System.IO.File.WriteAllText(FileAddress, Allfile); }
internal UsuarioViewModel GetAuthData() { var id = (ClaimsIdentity)System.Web.HttpContext.Current.User.Identity; if (id.IsAuthenticated) { try { var user = StringCompressor.DecompressString(id.Name); loggedUser = user.DeserializarToJson <UsuarioViewModel>(); if (loggedUser != null && loggedUser.Id != 0) { return(loggedUser); } } catch { } string[] substrings = id.Name.Split('|'); loggedUser.Id = long.Parse(substrings[1]); loggedUser.DatosPersonaId = long.Parse(substrings[1]); loggedUser.Mail = substrings[0].ToString(); return(loggedUser); } else { return(loggedUser); } }
private static int GetWordCount(PuzzleComponent p) { WordSet ws = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(p.Content), ws); return(ws.Words.Count); }
void OnWizardCreate() { foreach (PuzzleComponent puzzle in Selection.activeTransform.GetComponentsInChildren <PuzzleComponent>()) { string c = puzzle.Clue; WordSet ws = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(puzzle.PuzzleData.Content), ws); foreach (SWord word in ws.Words) { List <string> list = new List <string>(); if (_allWords.ContainsKey(word.Name)) { list.AddRange(_allWords[word.Name]); } list.Add(c); _allWords[word.Name] = list; } string export = ""; foreach (string word in _allWords.Keys) { List <string> cats = _allWords[word]; if (cats.Count > 1) { if (CheckSameCetegoryName) { CheckSameCat: for (var i = 0; i < cats.Count - 1; i++) { for (var j = i + 1; j < cats.Count; j++) { if (cats[i].Replace(cats[j], "").Length != cats[i].Length || cats[j].Replace(cats[i], "").Length != cats[j].Length) { cats.RemoveAt(i); goto CheckSameCat; } } } } if (cats.Count < 2) { continue; } export += "\n:\t" + word + "\t"; foreach (string cat in cats) { export += "," + cat; } } } System.IO.File.WriteAllText(FileAddress, export); } }
protected void Page_PreInit(object sender, EventArgs e) { if (Request.QueryString ["data"] != null) { this.PageData = StringCompressor.DecompressString(Request.QueryString ["data"]); this.ExtractPageData( ); } }
public WordSet GetWordSet() { WordSet wordSet = new WordSet(); string decompressString = StringCompressor.DecompressString(Content); string replace = decompressString.Replace("\"Direction\"", "\"WordDirection\""); JsonUtility.FromJsonOverwrite(replace, wordSet); return(wordSet); }
public static string GetSettingsFromCollection(string collectionId) { var nameValue = new Dictionary <string, string>(); var retStr = string.Empty; try { var wmiQuery = $"SELECT * FROM SMS_CollectionSettings WHERE CollectionID='{collectionId}'"; var result = Globals.Sccm.QueryProcessor.ExecuteQuery(wmiQuery) as WqlQueryResultsObject; foreach (WqlResultObject setting in result) { setting.Get(); var collVars = setting.GetArrayItems("CollectionVariables"); foreach (var v in collVars) { if (v["Name"].StringValue.Contains("DPLSCH")) { nameValue.Add(v["Name"].StringValue, v["Value"].StringValue); } } if (nameValue.Count() == 0) { return(retStr); } var sortedVars = nameValue.OrderBy(x => x.Key).ToList(); foreach (var pair in sortedVars) { retStr += pair.Value.Trim().TrimEnd('\0'); } } } catch (SmsQueryException ex) { Logger.Log(ex.Details, LogType.Error); } catch (SmsException ex) { Logger.Log(ex.Details, LogType.Error); } catch (Exception ex) { Logger.Log(ex.Message, LogType.Error); } return(StringCompressor.DecompressString(retStr)); }
public void CompressDecompressTest() { var text = " asd fdghfg d werwse uyiy uyui bn cvgbh dfgd fg"; var bytes = Encoding.UTF8.GetBytes(text); var base64 = Convert.ToBase64String(bytes); var textLength = text.Length; var base64Length = base64.Length; var compressedText = StringCompressor.CompressString(text); var decompressedText = StringCompressor.DecompressString(compressedText); Assert.AreEqual(text, decompressedText); }
public void SampleTest1() { //Arrange string s1 = "abcdefghijklmnop"; //Act string compressed = StringCompressor.CompressString(s1); string uncompressed = StringCompressor.DecompressString(compressed); //Artifacts mTestHelper.CreateTestArtifact("Stringcompression", s1 + Environment.NewLine + compressed); //Assert Assert.AreEqual(uncompressed, s1, "uncompressed=s1"); }
public void SpawnInvitedPuzzle() { var json = StringCompressor.DecompressString(ServerRespond["Content"].ToString()); WordSet wordSet = new WordSet(); JsonUtility.FromJsonOverwrite(json, wordSet); Singleton.Instance.WordSpawner.WordSet = wordSet; Singleton.Instance.WordSpawner.Clue = ServerRespond["Clue"].ToString(); Singleton.Instance.WordSpawner.PuzzleID = -1; Singleton.Instance.WordSpawner.PuzzleRow = ServerRespond["Creator"].ToString(); Singleton.Instance.WordSpawner.EditorInstatiate = null; FollowMachine.SetOutput("Success"); }
public void SetForSpawn() { var selectedPuzzle = PuzzleSelectionWindow.SelectedPuzzle; var json = StringCompressor.DecompressString(selectedPuzzle.Content); WordSet wordSet = new WordSet(); JsonUtility.FromJsonOverwrite(json, wordSet); Singleton.Instance.WordSpawner.WordSet = wordSet; Singleton.Instance.WordSpawner.Clue = selectedPuzzle.Clue; Singleton.Instance.WordSpawner.PuzzleID = -1; Singleton.Instance.WordSpawner.PuzzleRow = ""; Singleton.Instance.WordSpawner.EditorInstatiate = null; }
public IEnumerator SetForSpawn(int ID) { UserPuzzle selectedPuzzle = null; _pID = ID; // Ask command center to connect to account /* * yield return ServerController * .Get<UserPuzzle>($@"UserPuzzles/{ID}", * puzzle => { selectedPuzzle = (UserPuzzle)puzzle; }); */ ServerRespond = null; yield return(ServerController .Post <string>($@"UserPuzzles/GetInviteData?puzzleID={ID}&senderID={Singleton.Instance.PlayerController.PlayerID}", null, r => { ServerRespond = JObject.Parse(r); }, request => { FollowMachine.SetOutput("Fail"); } )); if (ServerRespond == null) { FollowMachine.SetOutput("Fail"); yield break; } var json = StringCompressor.DecompressString(ServerRespond["Content"].ToString()); WordSet wordSet = new WordSet(); JsonUtility.FromJsonOverwrite(json, wordSet); Singleton.Instance.WordSpawner.WordSet = wordSet; Singleton.Instance.WordSpawner.Clue = ServerRespond["Clue"].ToString(); Singleton.Instance.WordSpawner.PuzzleID = -1; Singleton.Instance.WordSpawner.PuzzleRow = ServerRespond["Creator"].ToString(); Singleton.Instance.WordSpawner.EditorInstatiate = null; FollowMachine.SetOutput("Success"); }
void OnWizardCreate() { string Allfile = ""; foreach (PuzzleComponent puzzle in Selection.activeGameObject.GetComponentsInChildren <PuzzleComponent>()) { string p = "اشاره: " + puzzle.Clue + ","; WordSet ws = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(puzzle.PuzzleData.Content), ws); foreach (SWord word in ws.Words) { p += word.Name + ","; } p += "\n"; Allfile += p; } System.IO.File.WriteAllText(FileAddress, Allfile); }
private void LookForNewSettings() { var settingFile = string.Empty; var collVars = CcmUtils.GetSettingsVariables(); if (collVars.Count() < 2) { return; } collVars = collVars.OrderBy(x => x.Name).ToList(); foreach (var collVar in collVars) { var tmp = GetCDataFromString(collVar.Value); if (tmp == null) { return; } settingFile += DecryptVariableValue(tmp).Trim().TrimEnd('\0'); } if (!string.IsNullOrEmpty(settingFile)) { settingFile = StringCompressor.DecompressString(settingFile); } if (settingFile.StartsWith("<?xml") && settingFile.EndsWith("</Settings>") && !settingFile.Equals(_oldSettings)) { SettingsUtils.WriteStringToSettingsFile(settingFile); Globals.Log.Information("Wrote new settings to 'Settings.xml'"); _oldSettings = settingFile; } else { Globals.Log.Information("No new settings found in Policy"); } }
/// <summary> /// Load the data contained in a file at the specified path /// </summary> public void Load(string path) { // Read the data byte[] raw = File.ReadAllBytes(path); // Re-encode the text to utf8 string compressed = Encoding.UTF8.GetString(raw); // Uncompress the file and split the line delimeter string[] data = StringCompressor.DecompressString(compressed).Split("*"); // Clear the file array files.Clear(); // Loop through the lines and re-construct each file foreach (string file in data) { string[] chunks = file.Split("|"); // Convert each chunk back into the original type files.Add(new Scanning.File(long.Parse(chunks[1]), chunks[0], Convert.ToBoolean(Convert.ToInt16(chunks[2])), Convert.ToBoolean(Convert.ToInt16(chunks[3])))); } }
public void CompressDecomPressString() { // Arrange var subject = StringEncryptor.Instance; var originalString = "Testing 123: Add some special characters &é@#'öçà!£$<ù}"; // Act var encryptedString1 = subject.Encrypt(originalString); var compressedString1 = StringCompressor.CompressString(encryptedString1); var decompressedString1 = StringCompressor.DecompressString(compressedString1); var decryptedString1 = subject.Decrypt(decompressedString1); var compressedString2 = StringCompressor.CompressString(originalString); var decompressedString2 = StringCompressor.DecompressString(compressedString2); // Assert Assert.AreEqual(originalString, decryptedString1, "Compressed and Decrypted string should match original string"); //Assert.IsTrue((compressedString1.Length <= encryptedString1.Length), "Compressed Encrypted String should be smaller than the Encrypted string"); Assert.AreEqual(originalString, decompressedString2, "Decompressed string should match original string"); //Assert.IsTrue((compressedString2.Length <= originalString.Length), "Compressed String should be smaller than the original"); }
private static IEnumerable <Dictionary <string, MedalCount> > DecompressAndDeserialize(IEnumerable <string> input) { return(input .Select(x => JsonConvert.DeserializeObject <Dictionary <string, MedalCount> >(StringCompressor.DecompressString(x)))); }
private static Dictionary <string, List <string> > DecompressAndDeserializeFunctionInput(string input) { return(JsonConvert.DeserializeObject <Dictionary <string, List <string> > >(StringCompressor.DecompressString(input))); }
public static string DeCompressString(string input) { return(StringCompressor.DecompressString(input)); }
void OnGUI() { #region Get clue and category GUILayout.Label("Generator", EditorStyles.boldLabel); _clue = EditorGUILayout.TextField("Clue", _clue); _puzzle = (PuzzleComponent)EditorGUILayout.ObjectField(_puzzle, typeof(PuzzleComponent), true); #endregion #region Spawn wordSet if (GUILayout.Button("Spawn")) { _clue = _puzzle.Clue; var Wordspawner = FindObjectOfType <WordSpawner>(); if (Wordspawner == null) { EditorUtility.DisplayDialog("Error", "Can't find word spawner", "Ok"); return; } Wordspawner.EditorInstatiate = EditorInstantiate; WordSet wSet = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(_puzzle.Content), wSet); Wordspawner.WordSet = wSet; _wordSet = wSet; Wordspawner.SpawnWords(); } #endregion #region Regenerate wordSet if (GUILayout.Button("Regenerate")) { var wordGenerator = FindObjectOfType <WordSetGenerator>(); if (wordGenerator == null) { EditorUtility.DisplayDialog("Error", "Can't find word spawner", "Ok"); return; } wordGenerator.AllWords = ""; foreach (var word in _wordSet.Words) { wordGenerator.AllWords += word.Name + " "; } wordGenerator.UsedWordCount = _wordSet.Words.Count; MgsCoroutine.GetTime = GetTime; MgsCoroutine.Start( wordGenerator.MakeWordSet(), () => EditorUtility.DisplayCancelableProgressBar(MgsCoroutine.Title, MgsCoroutine.Info, MgsCoroutine.Percentage), 0.1); EditorUtility.ClearProgressBar(); wordGenerator.EditorInstantiate = EditorInstantiate; wordGenerator.SpawnWordSet(); Selection.activeObject = wordGenerator.gameObject; } #endregion if (GUILayout.Button("Save")) { #region Get word manager var wordManagers = FindObjectsOfType <WordManager>(); if (wordManagers.Length == 0) { EditorUtility.DisplayDialog("Error", "Word manager not found!", "OK"); return; } if (wordManagers.Length > 1) { EditorUtility.DisplayDialog("Error", "More than one Word manager!", "OK"); return; } var wordManager = wordManagers[0]; #endregion #region Create New wordSet WordSet wordSet = new WordSet(); wordSet.Clue = _clue; wordSet.Words = new List <SWord>(); foreach (var word in wordManager.GetComponentsInChildren <Word>()) { wordSet.Words.Add(new SWord(word)); } #endregion #region Replace Puzzle TO Server // create category in database var puzzle = new Puzzle { ID = _puzzle.PuzzleData.ID, CategoryID = _puzzle.PuzzleData.CategoryID, Clue = _clue, Row = _puzzle.PuzzleData.Row, Content = StringCompressor.CompressString(JsonUtility.ToJson(wordSet)), LastUpdate = DateTime.Now }; _puzzle.Content = puzzle.Content; _puzzle.Clue = puzzle.Clue; _puzzle.Dirty = true; _puzzle.UpdateData(); ServerEditor.Post(@"Puzzles/Update/" + _puzzle.PuzzleData.ID, puzzle, "Update puzzle", "Update"); #endregion } }
/// <summary> /// Decompresses a deflate compressed, Base64 encoded string and returns an uncompressed string. /// </summary> /// <param name="compressedString">String to decompress.</param> public static string ToDecompressString(this string compressedString) { return(StringCompressor.DecompressString(compressedString)); }
private static IEnumerable <string> DecompressAndDeserialize(string input) { return(JsonConvert.DeserializeObject <IEnumerable <string> >(StringCompressor.DecompressString(input))); }
public void Frame() { if (!QRScene.activeSelf) { SetWindow("Close"); } if (Create.activeSelf) { if (Generated) { QROutput.texture = QRarr[CurrentQR]; Progress.text = "Showing QR " + (CurrentQR + 1) + "/" + (MaxQR + 1); if (MaxQR > 0) { Multi.SetActive(true); } else { Multi.SetActive(false); } } } if (Scan.activeSelf) { if (hasCamera == true) { if (hasScanned == false) { string Part1; string Part2; if (CurrentUUID == "None") { if (Percent > 0) { Part1 = "Scanning,"; } else { Part1 = "Ready to scan"; } } else { if (Percent > 0) { Part1 = "Scanning,"; } else { Part1 = "Ready to scan code " + (ThisQR) + "/" + (TotalQR + 1); } } if (Percent == 0) { Part2 = ""; } else if (Percent == 1) { Part2 = "33%"; } else if (Percent == 2) { Part2 = "66%"; } else { Part2 = "100%... but this will never be seen :("; } StatusText.text = "Status: " + Part1 + " " + Part2; if (QR1 || QR2 || QR3) { string Result; if (UseHighDensityScan.isOn) { if (QR1 && QR2 && QR3) { Result = result1.Text + result2.Text + result3.Text; } else { return; } } else { if (QR1) { Result = result1.Text; } else if (QR2) { Result = result2.Text; } else { Result = result3.Text; } } string check = FileTest.QRCheck(Result); switch (check) { case "Future": StatusText.text = "Status: That code is for a future version and is unreadable in RS2"; break; case "RS2": QRClass QRHeader; QRHeader = JsonUtility.FromJson <QRClass>(Result); if (QRHeader.Master) { if (CurrentUUID == "None") { if (!Devices.Contains(QRHeader.UUID)) { CurrentUUID = QRHeader.UUID; TotalQR = QRHeader.MaxFiles; ThisQR = 2; StatusText.text = "Status: Scan Successful"; } else { StatusText.text = "Status: Device already scanned"; } } else { if (CurrentUUID == QRHeader.UUID) { StatusText.text = "Status: Please scan the code " + ThisQR + "/" + (TotalQR + 1); } else { StatusText.text = "Status: Please finish scanning the current device"; } } } else { if (CurrentUUID == "None") { if (QRHeader.ThisQR == 1) { if (!Devices.Contains(QRHeader.UUID)) { if (QRHeader.Compression) { string CompressedData = StringCompressor.DecompressString(QRHeader.Data); Import(CompressedData); } else { Import(QRHeader.Data); } Devices.Add(QRHeader.UUID); } else { StatusText.text = "Status: Device already scanned"; } } else { StatusText.text = "Status: Please scan the first QR before scaning the others"; } } else { if (CurrentUUID == QRHeader.UUID) { if (ThisQR < QRHeader.ThisQR) { StatusText.text = "Status: Code not ready to be scanned, Please scan the code " + ThisQR + "/" + (TotalQR + 1); } else if (ThisQR == QRHeader.ThisQR) { StatusText.text = "Status: Scan Successful"; if (QRHeader.Compression) { string CompressedData = StringCompressor.DecompressString(QRHeader.Data); DataString += CompressedData; } else { DataString += QRHeader.Data; } ThisQR++; if (ThisQR > TotalQR + 1) { Import(DataString); Devices.Add(QRHeader.UUID); DataString = ""; } } else if (ThisQR > QRHeader.ThisQR) { StatusText.text = "Status: Code already scanned, Please scan the code " + ThisQR + "/" + (TotalQR + 1); } } else { StatusText.text = "Status: Please finish scanning the current device"; } } } break; case "RS1.5": StatusText.text = "Status: That code is for RS1.5 and is incompatible in RS2"; break; case "RS1": StatusText.text = "Status: Scan Sucessful in RS1 Compatibility mode"; break; case "Error": StatusText.text = "Status: That code is unreadable"; break; } RescanButton.SetActive(true); Camera.Stop(); hasScanned = true; } } } } else { if (hasCamera == true) { Camera.Stop(); hasCamera = false; StartCoroutine(StartCam()); } } }
public override void OnInspectorGUI() { _puzzleComponent = target as PuzzleComponent; EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); #region Update if (GUILayout.Button("Update")) { UpdateServer(_puzzleComponent); } #endregion #region Delete if (GUILayout.Button("Delete!!")) { if (EditorUtility.DisplayDialog("Delete Puzzle", "Are you sure?", "Delete", "Cancel")) { if (!ServerEditor.Post(@"Puzzles/Delete/" + _puzzleComponent.ID, null, "Delete Puzzle", "Delete")) { EditorUtility.DisplayDialog("Error", "Can't delete Puzzle in database", "Ok"); } _puzzleComponent.Delete(); return; } } #endregion EditorGUILayout.EndHorizontal(); #region Spawn if (GUILayout.Button("Spawn")) { var Wordspawner = FindObjectOfType <WordSpawner>(); if (Wordspawner == null) { EditorUtility.DisplayDialog("Error", "Can't find word spawner", "Ok"); return; } Wordspawner.EditorInstatiate = EditorInstantiate; WordSet wordSet = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(_puzzleComponent.Content), wordSet); Wordspawner.WordSet = wordSet; Wordspawner.SpawnWords(); } #endregion EditorGUILayout.Space(); EditorGUILayout.LabelField("ID", _puzzleComponent.ID.ToString()); DrawDefaultInspector(); }