예제 #1
0
        public static async Task <IWorkspace> Create(string path, IFileSystem fileSystem, IConverterService converterService)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException(nameof(fileSystem));
            }
            if (!fileSystem.Directory.Exists(path))
            {
                throw new ArgumentException("Path does not exist in specified file system: " + (path ?? "<null>"));
            }

            var settings  = WorkspaceSettings.Create(fileSystem, path);
            var workspace = new Workspace(settings, fileSystem, converterService);

            workspace.Handlers.Add(new FileWorkspaceItemHandler());
            //if (!string.IsNullOrEmpty(settings.Sync))
            //{
            //    var user = AppViewModel.Instance.User;
            //    if (user.EnsureLoggedIn())
            //    {
            //        var webHandler = new WebWorkspaceItemHandler(user.Data);
            //        workspace.Handlers.Add(webHandler);
            //    }
            //}

            await workspace.Initialize();

            return(workspace);
        }
예제 #2
0
        public Workspace(WorkspaceSettings settings, IFileSystem fileSystem, IConverterService converterService)
        {
            FileSystem       = fileSystem;
            Settings         = settings;
            ConverterService = converterService;

            debouncedChange = UIUtility.Debounce(ExecuteChanges, 1000);
        }
예제 #3
0
        public static WorkspaceSettings Create(IFileSystem fileSystem, string workspacePath)
        {
            var settings = new WorkspaceSettings(fileSystem, workspacePath);

            if (!fileSystem.File.Exists(settings.FullPath))
            {
                return(settings);
            }

            var fullText = fileSystem.File.ReadAllText(settings.FullPath);
            var doc      = XDocument.Parse(fullText);

            settings.Parse(doc);

            return(settings);
        }