void ISolutionConfigurationManagement.Save(bool prompt) { m_Server.Save(this); this.SelectSavePath(prompt, SetupFileDialog); List <UAModelDesignerProject> _projects = new List <UAModelDesignerProject>(); foreach (IProjectConfigurationManagement _item in m_Projects) { UAModelDesignerProject _projectDescriptor = _item.UAModelDesignerProject; string _effectiveAbsolutePath = _item.DefaultFileName; _projectDescriptor.FileName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _effectiveAbsolutePath); } string _codebaseRelativePathName = string.Empty; string _configurationRelativePathName = string.Empty; ServerSelector.ServerDescriptor _plugin = m_Server.ServerConfiguration; if (_plugin != null) { _codebaseRelativePathName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _plugin.Codebase); _configurationRelativePathName = RelativeFilePathsCalculator.TryComputeRelativePath(this.DefaultDirectory, _plugin.Configuration); } UAModelDesignerSolution _solutionDesription = new UAModelDesignerSolution() { Name = this.m_Name, Projects = m_Projects.Select <IProjectConfigurationManagement, UAModelDesignerProject>(x => x.UAModelDesignerProject).ToArray <UAModelDesignerProject>(), ServerDetails = new UAModelDesignerSolutionServerDetails { codebase = _codebaseRelativePathName, configuration = _configurationRelativePathName } }; this.Save(_solutionDesription); }
private string GetRelativePath(string fileName) { if (!string.IsNullOrEmpty(m_SolutionHomeDirectory.GetBaseDirectory()) && !string.IsNullOrEmpty(fileName)) { Directory.SetCurrentDirectory(m_SolutionHomeDirectory.GetBaseDirectory()); string _fullPath = Path.GetFullPath(fileName); fileName = RelativeFilePathsCalculator.TryComputeRelativePath(m_SolutionHomeDirectory.GetBaseDirectory(), _fullPath); } return(fileName); }
public void TryComputeRelativePathTest() { Assert.ThrowsException <ArgumentOutOfRangeException>(() => RelativeFilePathsCalculator.TryComputeRelativePath(m_Relative1, m_Relative3)); Assert.ThrowsException <ArgumentOutOfRangeException>(() => RelativeFilePathsCalculator.TryComputeRelativePath(m_AbsolutePath, m_AbsolutePath)); Assert.AreEqual <string>(m_FileName, RelativeFilePathsCalculator.TryComputeRelativePath(m_AbsolutePath, Path.Combine(m_AbsolutePath, m_FileName))); Assert.AreEqual <string>(m_Relative3, RelativeFilePathsCalculator.TryComputeRelativePath(m_AbsolutePath, m_Relative3)); Assert.AreEqual <string>(m_Relative3, RelativeFilePathsCalculator.TryComputeRelativePath(m_AbsolutePath, Path.Combine(m_AbsolutePath, m_Relative3))); Assert.AreEqual <string>(@"..\x\FileName.txt", RelativeFilePathsCalculator.TryComputeRelativePath(m_AbsolutePath, m_AbsoluteFilePath)); Assert.AreEqual <string>(@"..\..\..\a\b\x\FileName.txt", RelativeFilePathsCalculator.TryComputeRelativePath(@"C:\c\b\a\", m_AbsoluteFilePath)); Assert.AreEqual <string>(@"C:\a\b\x\FileName.txt", RelativeFilePathsCalculator.TryComputeRelativePath(@"D:\c\b\a\", m_AbsoluteFilePath)); }
private ProjectTreeNode(ISolutionDirectoryPathManagement solutionPath, string filePath, OPCFModelDesign model) : this(solutionPath, Path.GetFileNameWithoutExtension(filePath)) { UAModelDesignerProject = new UAModelDesignerProject() { BuildOutputDirectoryName = Resources.DefaultOutputBuildDirectory, CSVFileName = Resources.DefaultCSVFileName, FileName = RelativeFilePathsCalculator.TryComputeRelativePath(solutionPath.BaseDirectory, filePath), ProjectIdentifier = Guid.NewGuid().ToString(), Name = m_GetNextUniqueProjectName }; InitializeComponent(new ModelDesign(model, false)); }