Esempio n. 1
0
 private List <DeviceForXml> ReadXml(string path)
 {
     using (FileStream fsWrite = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read))
     {
         StreamReader sReader = new StreamReader(fsWrite);
         string       xmlStr  = sReader.ReadToEnd();
         Type         type    = typeof(List <DeviceForXml>);
         return((List <DeviceForXml>)SimpleSerializer.Deserialize(type, xmlStr));
     }
 }
Esempio n. 2
0
        static void Main()
        {
            Settings settings;
              var serializer = new SimpleSerializer<Settings>(SettingsPath);
              if (!File.Exists(SettingsPath))
              {
            settings = new Settings { WatchPath = " ", TargetPath = " ", Patterns = new[] { " " }, Overwrite = false, ActivityTimeout = 1000 };
            serializer.Serialize(settings);
              }
              else
              {
            settings = serializer.Deserialize();
              }

              LiveSync liveSync = null;
              if (settings == null
            || string.IsNullOrWhiteSpace(settings.WatchPath)
            || string.IsNullOrWhiteSpace(settings.TargetPath)
            || settings.Patterns == null)
              {
            Console.Title = "LiveSync";
            Console.WriteLine("Please create a {0} file first!", SettingsPath);
              }
              else
              {
            Console.Title = string.Format("LiveSync - {0}",
                                      string.IsNullOrWhiteSpace(settings.Title)
                                        ? settings.WatchPath
                                        : Environment.ExpandEnvironmentVariables(settings.Title));
            liveSync = new LiveSync(
              Environment.ExpandEnvironmentVariables(settings.WatchPath),
              Environment.ExpandEnvironmentVariables(settings.TargetPath),
              settings.Patterns,
              settings.Overwrite,
              settings.ActivityTimeout);
            liveSync.Start();
              }
              Console.WriteLine("Press Q to quit!");
              var isRunning = true;
              while (isRunning)
              {
            var key = Console.ReadKey(true);
            switch (key.Key)
            {
              case ConsoleKey.Q:
            isRunning = false;
            break;
            }
              }
              if (liveSync != null)
              {
            liveSync.Stop();
              }
        }
Esempio n. 3
0
        public void DeserializeDoesNothingIfFileDoesNotExist()
        {
            var dataPath = Path.Combine(_tempPath, DatacardConstants.DataFolder);

            Directory.CreateDirectory(dataPath);

            var serializer = new SimpleSerializer <Catalog>(DatacardConstants.CatalogFile);

            serializer.Deserialize(_baseSerializerMock.Object, dataPath);

            _baseSerializerMock.Verify(x => x.Deserialize <Catalog>(It.IsAny <string>()), Times.Never());
        }
        public PresetVoiLutConfiguration GetConfiguration()
        {
            Validate();

            PresetVoiLutConfiguration configuration = PresetVoiLutConfiguration.FromFactory(_sourceFactory);

            foreach (KeyValuePair <string, string> pair in SimpleSerializer.Deserialize <PresetVoiLutConfigurationAttribute>(this))
            {
                configuration[pair.Key] = pair.Value;
            }

            return(configuration);
        }
Esempio n. 5
0
        public void DeserializeCallsBaseSerializerIfFileExists()
        {
            var dataPath = Path.Combine(_tempPath, DatacardConstants.DataFolder);

            Directory.CreateDirectory(dataPath);
            var filePath = Path.Combine(dataPath, DatacardConstants.CatalogFile);

            File.WriteAllText(filePath, string.Empty);

            var serializer = new SimpleSerializer <Catalog>(DatacardConstants.CatalogFile);

            serializer.Deserialize(_baseSerializerMock.Object, dataPath);

            _baseSerializerMock.Verify(x => x.Deserialize <Catalog>(filePath), Times.Once());
        }
Esempio n. 6
0
 public void LoadConfig(string fileName)
 {
     if (File.Exists(fileName))
     {
         string content = File.ReadAllText(fileName);
         BindingList <DeviceUiInfo> deviceUiInfos =
             SimpleSerializer.Deserialize(DeviceUiInfos.GetType(), content) as BindingList <DeviceUiInfo>;
         if (deviceUiInfos != null)
         {
             DeviceUiInfos.Clear();
             foreach (var deviceUiInfo in deviceUiInfos)
             {
                 DeviceUiInfos.Add(deviceUiInfo);
             }
         }
     }
 }
Esempio n. 7
0
        private void OnImportBoardSetting(object o, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.RestoreDirectory = true;
            openFileDialog.Filter           = @"xml files(*.devcfg)|*.devcfg";
            DialogResult result = openFileDialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                string fileName = openFileDialog.FileName;
                if (File.Exists(fileName))
                {
                    string         content        = File.ReadAllText(fileName);
                    AbstractDevice selectedDevice = StaticMethods.GetSeletecedDevice(_busName, _deviceName);
                    IParameter     parameter      = selectedDevice.Parameter;
                    IParameter     para           = SimpleSerializer.Deserialize(parameter.GetType(), content) as IParameter;
                    parameter.UpdateParameter(para);
                }
            }
        }