Exemple #1
0
      public SlotModel Read(string filePath, string name, ClientSettings settings)
      {
         var slots = new List<SlotData>();
         var serializer = new XmlFileSerializer<SlotSummary>();
         
         try
         {
            slots = serializer.Deserialize(filePath).Slots;
         }
         catch (Exception ex)
         {
            _logger.ErrorFormat(ex, "{0}", ex.Message);
         }

         var slotData = slots.FirstOrDefault(x => x.GridData.Name == name);
         if (slotData != null)
         {
            var slot = AutoMapper.Mapper.Map<SlotData, SlotModel>(slotData);
            Protein protein = _proteinDictionary.GetProteinOrDownload(slotData.UnitInfo.ProjectID);

            // build unit info logic
            var unitInfoLogic = ServiceLocator.Resolve<UnitInfoLogic>();
            unitInfoLogic.CurrentProtein = protein;
            unitInfoLogic.UnitInfoData = slotData.UnitInfo;
            slot.Prefs = _prefs;
            slot.Settings = settings;
            slot.UnitInfoLogic = unitInfoLogic;
            return slot;
         }

         return new SlotModel { Prefs = _prefs, Settings = settings };
      }
      public void WriteAndReadXmlTest()
      {
         var data1 = CreateTestList();
         var serializer = new XmlFileSerializer<List<ProteinBenchmark>>();
         serializer.Serialize("TestProteinBenchmark.xml", data1);

         var data2 = serializer.Deserialize("TestProteinBenchmark.xml");
         ValidateTestList(data2);
      }
        public void WriteAndReadXmlTest()
        {
            var data1 = CreateTestList();
             var serializer = new XmlFileSerializer<List<UnitInfo>>();
             serializer.Serialize("TestUnitInfo.xml", data1);

             var data2 = serializer.Deserialize("TestUnitInfo.xml");
             Assert.IsTrue(data1.SequenceEqual(data2));
        }
Exemple #4
0
        private IEnumerable<string> DoXmlGeneration(string folderPath, IEnumerable<SlotModel> slots)
        {
            Debug.Assert(!String.IsNullOrEmpty(folderPath));
             Debug.Assert(slots != null);

             var fileList = new List<string>();

             DateTime updateDateTime = DateTime.Now;
             var slotSummary = CreateSlotSummary(slots, updateDateTime);
             var serializer = new XmlFileSerializer<SlotSummary>();
             string filePath = Path.Combine(Path.GetTempPath(), "SlotSummary.xml");
             fileList.Add(filePath);
             serializer.Serialize(filePath, slotSummary);

             var slotDetailSerializer = new XmlFileSerializer<SlotDetail>();
             foreach (var slot in slots)
             {
            var slotDetail = CreateSlotDetail(slot, updateDateTime);
            filePath = Path.Combine(Path.GetTempPath(), String.Concat(slot.Name, ".xml"));
            fileList.Add(filePath);
            slotDetailSerializer.Serialize(filePath, slotDetail);
             }

             return fileList.AsReadOnly();
        }
Exemple #5
0
 public IEnumerable<SlotData> Read(string filePath)
 {
    var serializer = new XmlFileSerializer<SlotSummary>();
    return serializer.Deserialize(filePath).Slots;
 }