Exemplo n.º 1
0
        private void RecoveryFormState()
        {
            var directory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Backlog Killer");

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            _pathFileFormState = Path.Combine(directory, "form-state.xml");

            var serializeService = new SerializeService <ConfigurationViewModel>();

            if (File.Exists(_pathFileFormState))
            {
                var configurationViewModel = serializeService.Deserialize(_pathFileFormState);
                txtProjectDirectoryRoot.Text = configurationViewModel.Directory;
                txtFilters.Text = configurationViewModel.Filters;

                dgvSubstitutions.AllowUserToAddRows    = false;
                dgvSubstitutions.AllowUserToDeleteRows = false;

                foreach (var subs in configurationViewModel.Substitutions)
                {
                    dgvSubstitutions.Rows.Add();

                    dgvSubstitutions.Rows[dgvSubstitutions.Rows.Count - 1].Cells[(int)Column.Find].Value        = subs.Find;
                    dgvSubstitutions.Rows[dgvSubstitutions.Rows.Count - 1].Cells[(int)Column.ReplaceWith].Value = subs.ReplaceWith;
                }

                dgvSubstitutions.AllowUserToAddRows    = true;
                dgvSubstitutions.AllowUserToDeleteRows = true;
            }
        }
Exemplo n.º 2
0
        public static T Deserialize <T>(string data)
            where T : class
        {
            CheckHelper.ArgumentNotNullAndNotWhiteSpace(data, "data");

            var serializeService = new SerializeService();

            return(serializeService.Deserialize <T>(data));
        }
Exemplo n.º 3
0
        public void Deserialize_Should_Deserialize_Data()
        {
            // Arrange
            var          serializeService = new SerializeService();
            const string data             = "<?xml version=\"1.0\" encoding=\"utf-16\"?>\r\n<TestClass xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\r\n  <TestProperty1>3</TestProperty1>\r\n  <TestProperty2>test</TestProperty2>\r\n</TestClass>";

            // Act
            var obj = serializeService.Deserialize <TestClass>(data);

            // Assert
            Assert.IsNotNull(obj);
            Assert.AreEqual(3, obj.TestProperty1);
            Assert.AreEqual("test", obj.TestProperty2);
        }