Exemplo n.º 1
0
        private void ParseOperands(string[] strings)
        {
            if (strings == null || strings.Length < 2)
                return;

            IPathInfo[] operands = new PathInfo[strings.Length - 1];
            for (int operandIndex = 0; operandIndex < operands.Length; operandIndex++)
                operands[operandIndex] = new PathInfo(strings[operandIndex + 1]);

            _operands = operands;
        }
Exemplo n.º 2
0
        public IPathInfo CopyWithoutLast()
        {
            PathInfo destinationPathInfo = new PathInfo();
            for (int elementIndex = 0; elementIndex < Count - 1; elementIndex++)
                destinationPathInfo.Elements.Add(this[elementIndex]);

            return destinationPathInfo;
        }
Exemplo n.º 3
0
        public void Test_PathInfo()
        {
            IPathInfo pathInfo = new PathInfo(@"c:\Dir1\Dir2\Dir3\file");
            Assert.AreEqual(pathInfo.Count, 4);
            Assert.IsTrue(pathInfo.HasRoot);
            Assert.AreEqual(pathInfo[0], "Dir1");
            Assert.AreEqual(pathInfo[1], "Dir2");
            Assert.AreEqual(pathInfo[2], "Dir3");
            Assert.AreEqual(pathInfo[3], "file");

            pathInfo = new PathInfo(@"\Dir1\Dir2\Dir3\file.txt");
            Assert.AreEqual(pathInfo.Count, 4);
            Assert.IsFalse(pathInfo.HasRoot);
            Assert.AreEqual(pathInfo[0], "Dir1");
            Assert.AreEqual(pathInfo[1], "Dir2");
            Assert.AreEqual(pathInfo[2], "Dir3");
            Assert.AreEqual(pathInfo[3], "file.txt");

            pathInfo = new PathInfo(@"c:\Dir1\hlink[c:\Dir4\Dir5]\Dir3\file");
            Assert.AreEqual(pathInfo.Count, 4);
            Assert.AreEqual(pathInfo[0], @"Dir1");
            Assert.AreEqual(pathInfo[1], @"hlink[c:\Dir4\Dir5]");
            Assert.AreEqual(pathInfo[2], @"Dir3");
            Assert.AreEqual(pathInfo[3], @"file");

            pathInfo = new PathInfo(@"c:\Dir1\dlink[c:\Dir4\Dir5]\Dir3\file");
            Assert.AreEqual(pathInfo.Count, 4);
            Assert.AreEqual(pathInfo[0], @"Dir1");
            Assert.AreEqual(pathInfo[1], @"dlink[c:\Dir4\Dir5]");
            Assert.AreEqual(pathInfo[2], @"Dir3");
            Assert.AreEqual(pathInfo[3], @"file");
        }