Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerWrapper" /> class.
        /// </summary>
        /// <param name="plugin">he interface to get access to the plugin.</param>
        /// <param name="assembly">TAn assembly containing the plug-in.</param>
        /// <param name="userInterface">The user interaction interface that provides basic functionality to implement user interactivity.</param>
        /// <param name="solutionPath">The solution path.</param>
        /// <param name="configuration">The file path containing the configuration.</param>
        public ServerWrapper(IConfiguration plugin, Assembly assembly, IGraphicalUserInterface userInterface, string solutionPath, string configuration)
        {
            Initialize(plugin, assembly);
            FileInfo _file = null;

            if (!string.IsNullOrEmpty(configuration))
            {
                if (!RelativeFilePathsCalculator.TestIfPathIsAbsolute(configuration))
                {
                    _file = new FileInfo(Path.Combine(solutionPath, configuration));
                }
                else
                {
                    _file = new FileInfo(configuration);
                }
            }
            if (_file == null)
            {
                Configuration = new ConfigurationWrapper(null, m_Server, userInterface);
            }
            else
            {
                Configuration = new ConfigurationWrapper(_file, m_Server, userInterface);
            }
        }
Ejemplo n.º 2
0
 public void TestIfPathIsAbsoluteTest()
 {
     Assert.IsTrue(RelativeFilePathsCalculator.TestIfPathIsAbsolute(m_AbsolutePath));
     Assert.ThrowsException <ArgumentOutOfRangeException>(() => RelativeFilePathsCalculator.TestIfPathIsAbsolute(m_Relative1));
     Assert.ThrowsException <ArgumentOutOfRangeException>(() => RelativeFilePathsCalculator.TestIfPathIsAbsolute(m_Relative2));
     Assert.IsFalse(RelativeFilePathsCalculator.TestIfPathIsAbsolute(m_Relative3));
     Assert.IsTrue(RelativeFilePathsCalculator.TestIfPathIsAbsolute(Path.Combine(m_Relative3, m_AbsolutePath)));
     Assert.IsTrue(RelativeFilePathsCalculator.TestIfPathIsAbsolute(Path.Combine(m_AbsolutePath, m_Relative3)));
 }
Ejemplo n.º 3
0
        private string ReplaceTokenAndReturnFullPath(string nameToBeReturned)
        {
            string myName = nameToBeReturned.Replace(Resources.Token_ProjectFileName, Path.GetFileNameWithoutExtension(FileName));

            if (RelativeFilePathsCalculator.TestIfPathIsAbsolute(myName))
            {
                return(myName);
            }
            string directory = Path.GetDirectoryName(FilePath);

            return(Path.Combine(directory, myName));
        }
        /// <summary>
        /// Prepares the path based on base directory.
        /// </summary>
        /// <param name="sourcePath">The source path.</param>
        /// <returns>FileInfo.</returns>
        public static FileInfo PreparePathBasedOnBaseDirectory(string sourcePath)
        {
            FileInfo file = null;

            if (!string.IsNullOrEmpty(sourcePath))
            {
                if (!RelativeFilePathsCalculator.TestIfPathIsAbsolute(sourcePath))
                {
                    file = new FileInfo(Path.Combine(CurrentDirectory, sourcePath));
                }
                else
                {
                    file = new FileInfo(sourcePath);
                }
            }
            return(file);
        }