示例#1
0
 public static string Serialize(DaemonView view)
 {
     string str;
     var serializer = new DataContractJsonSerializer(typeof(DaemonView));
     using (var stream = new MemoryStream())
     {
         serializer.WriteObject(stream, view);
         stream.Position = 0L;
         using (var reader = new StreamReader(stream, Encoding.UTF8))
         {
             str = reader.ReadToEnd();
         }
     }
     return str;
 }
示例#2
0
 private void Persist()
 {
     string[] lines = urls.Lines;
     IEnumerable<JobLine> source = JobViewToItemList();
     var view = new DaemonView
         {
             Urls = lines,
             JobLines = source.ToArray()
         };
     new Repository().Save(DaemonView.Serialize(view));
 }