public void SendObject(object obj) { if (this.isSocketDisposed || !this.clientSocket.Connected) { Console.WriteLine("Нет соединения!"); return; } try { String str = JsonSerializer.ConvertToJson(obj); str += CommonData.EndOfMessage; this.buffer = Encoding.Unicode.GetBytes(str); this.clientSocket.BeginSend(this.buffer, 0, this.buffer.Length, SocketFlags.None, this.SendingCallback, this.clientSocket ); } catch (Exception exc) { Console.WriteLine(exc.Message); } }
public void SerializeTest() { ApplicationInfoCollection collection = new ApplicationInfoCollection(); ApplicationInfo info = new ApplicationInfo { Name = "proc1", PPID = 3333, IsRunning = true, Modules = new List <ModuleInfo> { new ModuleInfo { Name = "lib.dll" } } }; collection.Add(info); string result = JsonSerializer.ConvertToJson(collection); const string expectedResult = "[{\"Name\":\"proc1\",\"PPID\":3333,\"StartTime\":null,\"ActivityTime\":null,\"EndTime\":null,\"IsRunning\":true,\"Modules\":[{\"Name\":\"lib.dll\"}]}]"; Assert.AreEqual(result, expectedResult); }
private static string ConvertToJson(TypeMetaData metaData) { return(JsonSerializer.ConvertToJson(metaData)); }
private void WriteStorageInfo(ApplicationInfoCollection result) { String json = JsonSerializer.ConvertToJson(result); File.WriteAllText(this.FilePath, json); }
protected virtual string SerializeToJson(object request) { return(JsonSerializer.ConvertToJson(request)); }