Beispiel #1
0
        /// <summary>
        /// Loads existing workspaces.
        /// </summary>
        public void LoadWorkspaces()
        {
            if (Directory.Exists(this.baseFolder))
            {
                this.availableWorkspaces.Clear();

                DirectoryInfo   di          = new DirectoryInfo(this.baseFolder);
                DirectoryInfo[] directories = di.GetDirectories();

                foreach (DirectoryInfo directoryInfo in directories)
                {
                    string filePath = this.baseFolder + directoryInfo.Name + @"\workspace.dob";
                    if (File.Exists(filePath))
                    {
                        try
                        {
                            using (var stream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                            {
                                WorkspaceConfiguration workspaceConfiguration = WorkspaceConfiguration.Load(stream, SerializationMode.Xml);
                                this.availableWorkspaces.Add(workspaceConfiguration.Name, workspaceConfiguration);
                            }
                        }
                        catch (Exception)
                        {
                            // nop
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Deletes workspace associated with given configuration key.
        /// </summary>
        /// <param name="configurationKey">
        /// The configuration key.
        /// </param>
        public void DeleteWorkspace(WorkspaceConfiguration workspace, string configurationKey)
        {
            var keys = this.AvailableWorkspaces.Where(kvp => kvp.Value == workspace).Select(kvp => kvp.Key).ToList();

            foreach (string key in keys)
            {
                this.AvailableWorkspaces.Remove(key);
            }

            #if (!SILVERLIGHT)
            string folderPath = _foldersService.GetConfigurationFolderPath() + TranslateKeyToLocalFolder(configurationKey) + @"\";
            if (Directory.Exists(folderPath))
            {
                Directory.Delete(folderPath, true);
            }
            #endif
        }
Beispiel #3
0
 public void SetWorkspace(WorkspaceConfiguration workspace, string newConfigurationKey, bool loadConfiguration)
 {
     this.CurrentWorkspace = workspace;
     #if (!SILVERLIGHT)
     this.configurationFolder = _foldersService.GetConfigurationFolderPath() + TranslateKeyToLocalFolder(newConfigurationKey) + @"\";
     #endif
     if (loadConfiguration)
     {
         bool oldAutoLoad = this.autoLoad;
         this.ConfigurationKey = newConfigurationKey;
         this.autoLoad         = oldAutoLoad;
     }
     else
     {
         this.configurationKey = newConfigurationKey;
     }
 }