コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 private static string ConvertToJson(TypeMetaData metaData)
 {
     return(JsonSerializer.ConvertToJson(metaData));
 }
コード例 #4
0
        private void WriteStorageInfo(ApplicationInfoCollection result)
        {
            String json = JsonSerializer.ConvertToJson(result);

            File.WriteAllText(this.FilePath, json);
        }
コード例 #5
0
 protected virtual string SerializeToJson(object request)
 {
     return(JsonSerializer.ConvertToJson(request));
 }