/// <summary> /// Initializes a new instance of the <see cref="SambaServiceDriver"/> class. /// </summary> /// <param name="fullPath">The working full path.</param> /// <param name="rootUrl">The root host url.</param> /// <param name="connectionString">The connection string.</param> /// <param name="maxDays">The maximum number of days to cache blob items for in the browser.</param> /// <param name="virtualPathRoute">When defined, Whether to use the default "media" route in the url independent of the blob container.</param> protected SambaServiceDriver(string fullPath, string rootUrl, string connectionString, int maxDays, string virtualPathRoute) { if (string.IsNullOrWhiteSpace(fullPath)) { throw new ArgumentNullException(nameof(fullPath)); } if (string.IsNullOrWhiteSpace(connectionString)) { throw new ArgumentNullException(nameof(connectionString)); } this.VirtualPathRouteDisabled = string.IsNullOrEmpty(virtualPathRoute); var connectionStringParser = new ConnectionStringParser(); var connectionStringData = connectionStringParser.Decode(connectionString); // Full path must use `directorySeparatorChar` and ends with separator. this.rootFullPath = fullPath.Replace(System.IO.Path.AltDirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar); if (this.rootFullPath.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString()) == false) { this.rootFullPath += System.IO.Path.DirectorySeparatorChar; } // SambaPath must be use `directorySeparatorChar` and do not end with separator. this.SambaPath = connectionStringData.SambaPath .Replace(System.IO.Path.AltDirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar) .TrimEnd(System.IO.Path.DirectorySeparatorChar); this.sambaCredential = new NetworkCredential(connectionStringData.Username, connectionStringData.Password, connectionStringData.Domain); this.instanceKey = CreateInstanceKey(fullPath, rootUrl, connectionString, virtualPathRoute); this.MaxDays = maxDays; this.VirtualPathRoute = this.VirtualPathRouteDisabled ? null : virtualPathRoute; this.rootHostUrl = rootUrl; if (string.IsNullOrEmpty(this.rootHostUrl)) { this.rootHostUrl = $"/{this.VirtualPathRoute}"; } if (this.rootHostUrl.EndsWith("/") == false) { this.rootHostUrl += "/"; } this.rootFullPathUrlCache = null; this.LogHelper = new WrappedLogHelper(); this.MimeTypeResolver = new MimeTypeResolver(); }