protected DictionaryNode baseQuery(DataSet dataSet) { DictionaryNode result = new DictionaryNode(); try { foreach (DataColumn column in dataSet.Tables[0].Columns) { result.Add(column.ColumnName, new ListNode()); } foreach (DataColumn column in dataSet.Tables[0].Columns) { foreach (DataRow row in dataSet.Tables[0].Rows) { result[column.ColumnName].Add(new nodeContent(row[column.ColumnName].ToString())); } } dataSet.Dispose(); } catch (Exception e) { Console.WriteLine(e.Message); } return(result); }
public void UpdateFileHash(string fileName, byte[] fileBytes) { DictionaryNode filesNode = PListHelper.GetDictionaryValueFromPList(RootNode, "files"); byte[] sha1Hash = new SHA1Managed().ComputeHash(fileBytes); byte[] sha256Hash = new SHA256Managed().ComputeHash(fileBytes); if (filesNode.ContainsKey(fileName)) { filesNode[fileName] = new DataNode(sha1Hash); } DictionaryNode files2Node = PListHelper.GetDictionaryValueFromPList(RootNode, "files2"); if (files2Node != null && files2Node.ContainsKey(fileName)) { DictionaryNode entryNode = new DictionaryNode(); entryNode.Add("hash", new DataNode(sha1Hash)); entryNode.Add("hash2", new DataNode(sha256Hash)); files2Node[fileName] = entryNode; } }
private static byte[] GenerateHashesPList(byte[] codeDirectoryBytes, byte[] alternativeCodeDirectory1Bytes) { PListFile plist = new PListFile(); DictionaryNode rootNode = new DictionaryNode(); ArrayNode hashesNode = new ArrayNode(); hashesNode.Add(new DataNode(HashAlgorithmHelper.ComputeHash(HashType.SHA1, codeDirectoryBytes))); hashesNode.Add(new DataNode(HashAlgorithmHelper.ComputeHash(HashType.SHA256Truncated, alternativeCodeDirectory1Bytes))); rootNode.Add("cdhashes", hashesNode); plist.RootNode = rootNode; return(plist.GetBytes(PListFormat.Xml)); }
public void WhenBooleanValueIsSaved_ThenThereIsNoWhiteSpace() { using (var outStream = new MemoryStream()) { // create basic PList containing a boolean value var node = new DictionaryNode(); node.Add("Test", new BooleanNode(true)); // save and reset stream PList.Save(node, outStream, PListFormat.Xml); outStream.Seek(0, SeekOrigin.Begin); // check that boolean was written out without a space per spec (see also issue #11) using (var reader = new StreamReader(outStream)) { var contents = reader.ReadToEnd(); Assert.IsTrue(contents.Contains("<true/>")); } } }
public void WhenStringContainsUnicode_ThenStringIsWrappedInUstringTag() { using (var outStream = new MemoryStream()) { var utf16value = "😂test"; // create basic PList containing a boolean value var node = new DictionaryNode(); node.Add("Test", new StringNode(utf16value)); // save and reset stream PList.Save(node, outStream, PListFormat.Xml); outStream.Seek(0, SeekOrigin.Begin); // check that boolean was written out without a space per spec (see also issue #11) using (var reader = new StreamReader(outStream)) { var contents = reader.ReadToEnd(); Assert.IsTrue(contents.Contains($"<ustring>{utf16value}</ustring>")); } } }
public void Add(string word) { _root.Add(word); }
public void Deserialize_Class_With_Properties_Same_Test() { var node = new DictionaryNode(); var arrayNode = new ArrayNode(); var dictionaryNode = new DictionaryNode(); node.Add("ArraySameType", arrayNode); node.Add("ArraySameType2", arrayNode); node.Add("ArraySameType3", arrayNode); node.Add("List1", arrayNode); node.Add("List2", arrayNode); node.Add("List3", arrayNode); node.Add("ClassSameType", dictionaryNode); node.Add("ClassSameType2", dictionaryNode); node.Add("ClassSameType3", dictionaryNode); node.Add("DictionarySameType", dictionaryNode); node.Add("DictionarySameType2", dictionaryNode); node.Add("DictionarySameType3", dictionaryNode); var res = _deserializer.Deserialize <ClassWithSameTypes>(node); Assert.IsNotNull(res.ArraySameType); Assert.IsNotNull(res.ArraySameType2); Assert.IsNotNull(res.ArraySameType); Assert.IsNotNull(res.ClassSameType); Assert.IsNotNull(res.ClassSameType2); Assert.IsNotNull(res.ClassSameType3); Assert.IsNotNull(res.DictionarySameType); Assert.IsNotNull(res.DictionarySameType2); Assert.IsNotNull(res.List1); Assert.IsNotNull(res.List2); Assert.IsNotNull(res.List3); }
public void Deserialize_BigObject_Tests() { var node = new DictionaryNode(); var arrayNode = new ArrayNode(); var dictionaryNode = new DictionaryNode(); node.Add("Array0", arrayNode); node.Add("Array1", arrayNode); node.Add("Array2", arrayNode); node.Add("List0", arrayNode); node.Add("List1", arrayNode); node.Add("List2", arrayNode); node.Add("Ints1", arrayNode); node.Add("Dictionary0", dictionaryNode); node.Add("Dictionary1", dictionaryNode); node.Add("Dictionary2", dictionaryNode); node.Add("Dictionary3", dictionaryNode); node.Add("DictionarySameType", dictionaryNode); node.Add("DictionarySameType2", dictionaryNode); node.Add("DictionarySameType3", dictionaryNode); var res = _deserializer.Deserialize <BigObject>(node); Assert.IsNotNull(res.Array0); Assert.IsNotNull(res.Array1); Assert.IsNotNull(res.Array2); Assert.IsNotNull(res.Dictionary0); Assert.IsNotNull(res.Dictionary1); Assert.IsNotNull(res.Dictionary2); Assert.IsNotNull(res.Dictionary3); Assert.IsNotNull(res.Ints1); Assert.IsNotNull(res.List0); Assert.IsNotNull(res.List1); Assert.IsNotNull(res.List2); }