Exemplo n.º 1
0
        public void Save(Project project, FileInfo path)
        {
            using (var stream = new MemoryStream())
            {
                var serializer = new DataContractSerializer(typeof(Project));
                serializer.WriteObject(stream, project);

                FileStream writer = null;

                try
                {
                    writer = path.Create();
                    writer.Write(stream.GetBuffer(), 0, (int) stream.Length);
                    writer.Flush();
                }
                finally
                {
                    if (writer != null)
                    {
                        writer.Close();
                        writer.Dispose();
                    }
                }
            }
        }
        public void Project_Fires_Property_Changed()
        {
            var project = new Project();

            project.AssertThatAllProperties()
                   .RaiseChangeNotification();
        }
        public void Open_Loads_Project()
        {
            var p = new Project();
            _projectService.Expect(x => x.Open(Arg<FileInfo>.Is.Anything)).Return(p);

            var dialogModel = new OpenFileDialogViewModel { Result = true, FileName = "C:\\" };
            _viewModelFactory.Expect(x => x.Create<IOpenFileDialogViewModel>()).Return(dialogModel);

            var vm = CreateProjectViewModel();
            vm.Open();

            Assert.NotNull(vm.CurrentProject);
            Assert.Same(p, vm.CurrentProject);
        }
Exemplo n.º 4
0
        public virtual bool Open()
        {
            var model = CreateOpenDialogModel();

            _dialogService.ShowOpenFileDialog(model);

            if(model.Result.GetValueOrDefault(false) && model.FileName.IsNotEmpty())
            {
                _filePath = model.FileName;
                CurrentProject = _projectService.Open(new FileInfo(_filePath));

                return true;
            }

            return false;
        }