Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualPath"/> class.
 /// </summary>
 /// <param name="elements">Path element array.</param>
 /// <param name="type">Type of the path.</param>
 /// <param name="drive">Drive letter of an absolute path.</param>
 private VirtualPath(string[] elements, VirtualPathType type, DriveLetter?drive)
     : this()
 {
     this.pathElements = elements.Length > 0 ? elements : Array.Empty <string>();
     this.pathType     = type;
     this.driveLetter  = drive;
 }
Exemplo n.º 2
0
        public void CanGetRootPath(string path, VirtualPathType expectedType)
        {
            var vPath = new VirtualPath(path);

            CollectionAssert.IsEmpty(vPath.Parts);
            Assert.AreEqual(expectedType, vPath.Type);
        }
Exemplo n.º 3
0
        public void CanDetectPathType(string path, VirtualPathType type, string expectedPath)
        {
            var vpath = new VirtualPath(path);

            Assert.AreEqual(type, vpath.Type);
            Assert.AreEqual(expectedPath, vpath.Path);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualPath"/> class.
 /// </summary>
 public VirtualPath()
 {
     this.pathElements   = Array.Empty <string>();
     this.pathType       = VirtualPathType.Relative;
     this.cachedPath     = new Lazy <string>(() => string.Join("\\", this.pathElements), true);
     this.cachedFullPath = new Lazy <string>(this.BuildFullPath, true);
 }
Exemplo n.º 5
0
        public ZipVirtualPathCollection (String virtualPath, VirtualPathType requestType, ZipFile zipFile) {
            _paths = new ArrayList();
            _virtualPath = virtualPath;
            _requestType = requestType;
            _zipFile = zipFile;

			PerformEnumeration ();
		}
 public void CanAppend(string first, string second, VirtualPathType expectedType, string expectedPath)
 {
     var v1 = new VirtualPath(first);
     var v2 = new VirtualPath(second);
     var actual = v1.Append(v2);
     Assert.AreEqual(expectedType, actual.Type);
     Assert.AreEqual(expectedPath, actual.Path);
 }
        public ZipVirtualPathCollection(String virtualPath, VirtualPathType requestType, ZipFile zipFile)
        {
            _paths       = new ArrayList();
            _virtualPath = virtualPath;
            _requestType = requestType;
            _zipFile     = zipFile;

            PerformEnumeration();
        }
Exemplo n.º 8
0
        public void CanAppend(string first, string second, VirtualPathType expectedType, string expectedPath)
        {
            var v1     = new VirtualPath(first);
            var v2     = new VirtualPath(second);
            var actual = v1.Append(v2);

            Assert.AreEqual(expectedType, actual.Type);
            Assert.AreEqual(expectedPath, actual.Path);
        }
Exemplo n.º 9
0
        private VirtualPath GetSubPathInternal(VirtualPath other, bool ignoreCase, VirtualPathType type)
        {
            if (this.Parts.Count > other.Parts.Count)
            {
                return(null);
            }
            var comparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;

            for (var i = 0; i < this.Parts.Count; i++)
            {
                if (!this.Parts[i].Equals(other.Parts[i], comparison))
                {
                    return(null);
                }
            }
            return(new VirtualPath(other.Parts.Skip(this.Parts.Count), type));
        }
Exemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="VirtualPath"/> class.
        /// </summary>
        /// <param name="path">String representation of an absolute or relative path.</param>
        public VirtualPath(string path) : this()
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            var instance = Parse(path, out var error);

            if (instance == null)
            {
                throw error;
            }

            this.driveLetter  = instance.driveLetter;
            this.pathElements = instance.pathElements;
            this.pathType     = instance.pathType;
        }
Exemplo n.º 11
0
        /// <summary>
        ///  Creates a new instance of the <see cref="VirtualPath"/> class,
        ///  from the constituent parts of the path and its type.
        /// </summary>
        /// <param name="parts"></param>
        /// <param name="type"></param>

        public VirtualPath(IEnumerable<string> parts, VirtualPathType type)
        {
            Type = type;
            Parts = GetParts(parts).ToList().AsReadOnly();
            Path = String.Join("/", Parts);
        }
Exemplo n.º 12
0
 private VirtualPath GetSubPathInternal(VirtualPath other, bool ignoreCase, VirtualPathType type)
 {
     if (this.Parts.Count > other.Parts.Count) return null;
     var comparison = ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal;
     for (var i = 0; i < this.Parts.Count; i++) {
         if (!this.Parts[i].Equals(other.Parts[i], comparison)) return null;
     }
     return new VirtualPath(other.Parts.Skip(this.Parts.Count), type);
 }
Exemplo n.º 13
0
        /// <summary>
        ///  Creates a new instance of the <see cref="VirtualPath"/> class,
        ///  from the constituent parts of the path and its type.
        /// </summary>
        /// <param name="parts"></param>
        /// <param name="type"></param>

        public VirtualPath(IEnumerable <string> parts, VirtualPathType type)
        {
            Type  = type;
            Parts = GetParts(parts).ToList().AsReadOnly();
            Path  = String.Join("/", Parts);
        }
Exemplo n.º 14
0
 public void CanGetRootPath(string path, VirtualPathType expectedType)
 {
     var vPath = new VirtualPath(path);
     CollectionAssert.IsEmpty(vPath.Parts);
     Assert.AreEqual(expectedType, vPath.Type);
 }
Exemplo n.º 15
0
 public void CanDetectPathType(string path, VirtualPathType type, string expectedPath)
 {
     var vpath = new VirtualPath(path);
     Assert.AreEqual(type, vpath.Type);
     Assert.AreEqual(expectedPath, vpath.Path);
 }