public void Normalize_OnInvalidUrlPath_ThrowsArgumentException(bool isBasePath) => Assert.Throws <ArgumentException>(() => UrlPath.Normalize("does/not/start/with/slash", isBasePath));
public void IsEqualOrSubDirectory_UnixPath(string dir, string subdir, bool expected) { bool actual = UrlPath.IsEqualOrSubdirectory(dir, subdir); Assert.Equal(expected, actual); }
public void IsEqualOrSubDirectory_NullSubDir() { bool test = UrlPath.IsEqualOrSubdirectory("Hello", null); Assert.False(test); }
public void IsEqualOrSubDirectory_True_DirBackslash() { bool test = UrlPath.IsEqualOrSubdirectory("C:\\Directory\\", "C:\\Directory\\SubDirectory"); Assert.True(test); }
public void IsEqualOrSubDirectory_Equal_BothBackslashes() { bool test = UrlPath.IsEqualOrSubdirectory("C:\\Directory\\", "C:\\Directory\\"); Assert.True(test); }
public void IsEqualOrSubDirectory_EmptyDir() { bool test = UrlPath.IsEqualOrSubdirectory("", null); Assert.True(test); }
public void IsEqualOrSubDirectory_SubDirAndDirAreReversed_NoTrailingBackslash() { bool test = UrlPath.IsEqualOrSubdirectory("C:\\Directory\\SubDirectory", "C:\\Directory"); Assert.False(test); }
public void Split_OnEmptyUrlPath_ThrowsArgumentException() => Assert.Throws <ArgumentException>(() => UrlPath.Split(""));
internal static string GetWebResourceUrlInternal(Assembly assembly, string resourceName, bool htmlEncoded, bool forSubstitution, IScriptManager scriptManager, bool enableCdn) { // When this url is being inserted as a substitution in another resource, // it should just be "WebResource.axd?d=..." since the resource is already coming // from the app root (i.e. no need for a full absolute /app/WebResource.axd). // Otherwise we must return a path that is absolute (starts with '/') or // a full absolute uri (http://..) as in the case of a CDN Path. EnsureHandlerExistenceChecked(); if (!_handlerExists) { throw new InvalidOperationException(SR.GetString(SR.AssemblyResourceLoader_HandlerNotRegistered)); } Assembly effectiveAssembly = assembly; string effectiveResourceName = resourceName; bool debuggingEnabled = false; bool secureConnection; if (scriptManager != null) { debuggingEnabled = scriptManager.IsDebuggingEnabled; secureConnection = scriptManager.IsSecureConnection; } else { secureConnection = ((HttpContext.Current != null) && (HttpContext.Current.Request != null) && HttpContext.Current.Request.IsSecureConnection); debuggingEnabled = (HttpContext.Current != null) && HttpContext.Current.IsDebuggingEnabled; } int urlCacheKey = CreateWebResourceUrlCacheKey(assembly, resourceName, htmlEncoded, forSubstitution, enableCdn, debuggingEnabled, secureConnection); string url = (string)_urlCache[urlCacheKey]; if (url == null) { IScriptResourceDefinition definition = null; if (ClientScriptManager._scriptResourceMapping != null) { definition = ClientScriptManager._scriptResourceMapping.GetDefinition(resourceName, assembly); if (definition != null) { if (!String.IsNullOrEmpty(definition.ResourceName)) { effectiveResourceName = definition.ResourceName; } if (definition.ResourceAssembly != null) { effectiveAssembly = definition.ResourceAssembly; } } } string path = null; // if a resource mapping exists, take it's settings into consideration // it might supply a path or a cdnpath. if (definition != null) { if (enableCdn) { // Winner is first path defined, falling back on the effectiveResourceName/Assembly // Debug Mode : d.CdnDebugPath, d.DebugPath, *wra.CdnPath, d.Path // Release Mode: d.CdnPath , *wra.CdnPath, d.Path // * the WebResourceAttribute corresponding to the resource defined in the definition, not the // the original resource. // Also, if the definition has a CdnPath but it cannot be converted to a secure one during https, // the WRA's CdnPath is not considered. if (debuggingEnabled) { path = secureConnection ? definition.CdnDebugPathSecureConnection : definition.CdnDebugPath; if (String.IsNullOrEmpty(path)) { path = definition.DebugPath; if (String.IsNullOrEmpty(path)) { // Get CDN Path from the redirected resource name/assembly, not the original one, // but not if this is a secure connection and the only reason we didn't use the definition // cdn path is because it doesnt support secure connections. if (!secureConnection || String.IsNullOrEmpty(definition.CdnDebugPath)) { path = GetCdnPath(effectiveResourceName, effectiveAssembly, secureConnection); } if (String.IsNullOrEmpty(path)) { path = definition.Path; } } } } else { path = secureConnection ? definition.CdnPathSecureConnection : definition.CdnPath; if (String.IsNullOrEmpty(path)) { // Get CDN Path from the redirected resource name/assembly, not the original one // but not if this is a secure connection and the only reason we didn't use the definition // cdn path is because it doesnt support secure connections. if (!secureConnection || String.IsNullOrEmpty(definition.CdnPath)) { path = GetCdnPath(effectiveResourceName, effectiveAssembly, secureConnection); } if (String.IsNullOrEmpty(path)) { path = definition.Path; } } } } // cdn else { // Winner is first path defined, falling back on the effectiveResourceName/Assembly // Debug Mode : d.DebugPath, d.Path // Release Mode: d.Path if (debuggingEnabled) { path = definition.DebugPath; if (String.IsNullOrEmpty(path)) { path = definition.Path; } } else { path = definition.Path; } } } // does not have definition else if (enableCdn) { path = GetCdnPath(effectiveResourceName, effectiveAssembly, secureConnection); } if (!String.IsNullOrEmpty(path)) { // assembly based resource has been overridden by a path, // whether that be a CDN Path or a definition.Path or DebugPath. // We must return a path that is absolute (starts with '/') or // a full absolute uri (http://..) as in the case of a CDN Path. // An overridden Path that is not a CDN Path is required to be absolute // or app relative. if (UrlPath.IsAppRelativePath(path)) { // expand ~/. If it is rooted (/) or an absolute uri, no conversion needed if (_applicationRootPath == null) { url = VirtualPathUtility.ToAbsolute(path); } else { url = VirtualPathUtility.ToAbsolute(path, _applicationRootPath); } } else { // must be a full uri or already rooted. url = path; } if (htmlEncoded) { url = HttpUtility.HtmlEncode(url); } } else { string urlAssemblyName; Pair assemblyInfo = GetAssemblyInfo(effectiveAssembly); AssemblyName assemblyName = (AssemblyName)assemblyInfo.First; long assemblyDate = (long)assemblyInfo.Second; string assemblyVersion = assemblyName.Version.ToString(); if (effectiveAssembly.GlobalAssemblyCache) { // If the assembly is in the GAC, we need to store a full name to load the assembly later if (effectiveAssembly == HttpContext.SystemWebAssembly) { urlAssemblyName = "s"; } else { // Pack the necessary values into a more compact format than FullName StringBuilder builder = new StringBuilder(); builder.Append('f'); builder.Append(assemblyName.Name); builder.Append(','); builder.Append(assemblyVersion); builder.Append(','); if (assemblyName.CultureInfo != null) { builder.Append(assemblyName.CultureInfo.ToString()); } builder.Append(','); byte[] token = assemblyName.GetPublicKeyToken(); for (int i = 0; i < token.Length; i++) { builder.Append(token[i].ToString("x2", CultureInfo.InvariantCulture)); } urlAssemblyName = builder.ToString(); } } else { // Otherwise, we can just use a partial name urlAssemblyName = "p" + assemblyName.Name; } url = FormatWebResourceUrl(urlAssemblyName, effectiveResourceName, assemblyDate, htmlEncoded); if (!forSubstitution && (HttpRuntime.AppDomainAppVirtualPathString != null)) { // When this url is being inserted as a substitution in another resource, // it should just be "WebResource.axd?d=..." since the resource is already coming // from the app root (i.e. no need for a full absolute /app/WebResource.axd). url = UrlPath.Combine(HttpRuntime.AppDomainAppVirtualPathString, url); } } _urlCache[urlCacheKey] = url; } return(url); }
public void StripPrefix_ReturnsCorrectValue(string urlPath, string baseUrlPath, string expectedResult) => Assert.AreEqual(expectedResult, UrlPath.StripPrefix(urlPath, baseUrlPath));
public void Split_OnNullUrlPath_ThrowsArgumentNullException() => Assert.Throws <ArgumentNullException>(() => UrlPath.Split(null));
public void StripPrefix_OnInvalidParameter_ThrowsArgumentException(string urlPath, string baseUrlPath) => Assert.Throws <ArgumentException>(() => UrlPath.StripPrefix(urlPath, baseUrlPath));
public void HasPrefix_OnEmptyParameter_ThrowsArgumentException(string urlPath, string baseUrlPath) => Assert.Throws <ArgumentException>(() => UrlPath.HasPrefix(urlPath, baseUrlPath));
public void Normalize_ReturnsCorrectValue(string urlPath, bool isBasePath, string expectedResult) => Assert.AreEqual(expectedResult, UrlPath.Normalize(urlPath, isBasePath));
private static string FileUploadUrl(string fileId, NameValueCollection values) { return(Uri.UriBuilder(Url.UPLOAD, UrlPath.Create(Path.File).Append(fileId).ToString(), values)); }
/// <devdoc> /// Validates that the WebResource.axd handler is registered in config and actually /// points to the correct handler type. /// </devdoc> private static void EnsureHandlerExistenceChecked() { // First we have to check that the handler is registered: // <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" /> if (!_handlerExistenceChecked) { HttpContext context = HttpContext.Current; IIS7WorkerRequest iis7WorkerRequest = (context != null) ? context.WorkerRequest as IIS7WorkerRequest : null; string webResourcePath = UrlPath.Combine(HttpRuntime.AppDomainAppVirtualPathString, _webResourceUrl); if (iis7WorkerRequest != null) { // check the IIS <handlers> section by mapping the handler string handlerTypeString = iis7WorkerRequest.MapHandlerAndGetHandlerTypeString(method: "GET", path: UrlPath.Combine(HttpRuntime.AppDomainAppVirtualPathString, _webResourceUrl), convertNativeStaticFileModule: false, ignoreWildcardMappings: true); if (!String.IsNullOrEmpty(handlerTypeString)) { _handlerExists = (typeof(AssemblyResourceLoader) == BuildManager.GetType(handlerTypeString, true /*throwOnFail*/, false /*ignoreCase*/)); } } else { // check the <httpHandlers> section HttpHandlerAction httpHandler = RuntimeConfig.GetConfig(VirtualPath.Create(webResourcePath)).HttpHandlers.FindMapping("GET", VirtualPath.Create(_webResourceUrl)); _handlerExists = (httpHandler != null) && (httpHandler.TypeInternal == typeof(AssemblyResourceLoader)); } _handlerExistenceChecked = true; } }
public void IsEqualOrSubDirectory_NullDir() { bool test = UrlPath.IsEqualOrSubdirectory(null, "Hello"); Assert.Equal(true, test); }
public void DynamicWidgetsDesignerListSettings_VerifyUsePagingFunctionality() { var dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles(); this.pageOperations = new PagesOperations(); string testName = System.Reflection.MethodInfo.GetCurrentMethod().Name; string pageNamePrefix = testName + "DynamicPage"; string pageTitlePrefix = testName + "Dynamic Page"; string urlNamePrefix = testName + "dynamic-page"; int index = 1; int itemsPerPage = 1; string index2 = "/2"; string index3 = "/3"; string url1 = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index); string url2 = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index + index2); string url3 = UrlPath.ResolveAbsoluteUrl("~/" + urlNamePrefix + index + index3); try { for (int i = 0; i < this.dynamicTitles.Length; i++) { ServerOperationsFeather.DynamicModulePressArticle().CreatePressArticleItem(this.dynamicTitles[i], this.dynamicUrls[i]); } dynamicCollection = ServerOperationsFeather.DynamicModulePressArticle().RetrieveCollectionOfPressArticles(); var mvcProxy = new MvcWidgetProxy(); mvcProxy.ControllerName = typeof(DynamicContentController).FullName; var dynamicController = new DynamicContentController(); dynamicController.Model.ContentType = TypeResolutionService.ResolveType(ResolveType); dynamicController.Model.DisplayMode = ListDisplayMode.Paging; dynamicController.Model.ItemsPerPage = itemsPerPage; mvcProxy.Settings = new ControllerSettings(dynamicController); mvcProxy.WidgetName = WidgetName; this.pageOperations.CreatePageWithControl(mvcProxy, pageNamePrefix, pageTitlePrefix, urlNamePrefix, index); string responseContent1 = PageInvoker.ExecuteWebRequest(url1); string responseContent2 = PageInvoker.ExecuteWebRequest(url2); string responseContent3 = PageInvoker.ExecuteWebRequest(url3); for (int i = 0; i < this.dynamicTitles.Length; i++) { switch (i) { case 0: Assert.IsTrue(responseContent3.Contains(this.dynamicTitles[i]), "The dynamic item with this title was not found!"); Assert.IsFalse(responseContent3.Contains(this.dynamicTitles[i + 1]), "The dynamic item with this title was found!"); Assert.IsFalse(responseContent3.Contains(this.dynamicTitles[i + 2]), "The dynamic item with this title was found!"); break; case 1: Assert.IsTrue(responseContent2.Contains(this.dynamicTitles[i]), "The dynamic item with this title was not found!"); Assert.IsFalse(responseContent2.Contains(this.dynamicTitles[i + 1]), "The dynamic item with this title was found!"); Assert.IsFalse(responseContent2.Contains(this.dynamicTitles[i - 1]), "The dynamic item with this title was found!"); break; case 2: Assert.IsTrue(responseContent1.Contains(this.dynamicTitles[i]), "The dynamic item with this title was not found!"); Assert.IsFalse(responseContent1.Contains(this.dynamicTitles[i - 1]), "The dynamic item with this title was found!"); Assert.IsFalse(responseContent1.Contains(this.dynamicTitles[i - 2]), "The dynamic item with this title was found!"); break; } } } finally { this.pageOperations.DeletePages(); ServerOperationsFeather.DynamicModulePressArticle().DeleteDynamicItems(dynamicCollection); } }
public void IsEqualOrSubDirectory_NotEmptyDir_EmptySubDir() { bool test = UrlPath.IsEqualOrSubdirectory("Hello", ""); Assert.False(test); }
public static VirtualPath Create(string virtualPath, VirtualPathOptions options) { // Trim it first, so that blank strings (e.g. " ") get treated as empty if (virtualPath != null) { virtualPath = virtualPath.Trim(); } // If it's empty, check whether we allow it if (String.IsNullOrEmpty(virtualPath)) { if ((options & VirtualPathOptions.AllowNull) != 0) { return(null); } throw new ArgumentNullException("virtualPath"); } // Dev10 767308: optimize for normal paths, and scan once for // i) invalid chars // ii) slashes // iii) '.' bool slashes = false; bool dot = false; int len = virtualPath.Length; //todo check if i need this code //unsafe { // fixed (char * p = virtualPath) { // for (int i = 0; i < len; i++) { // switch (p[i]) { // // need to fix slashes ? // case '/': // if (i > 0 && p[i-1] == '/') // slashes = true; // break; // case '\\': // slashes = true; // break; // // contains "." or ".." // case '.': // dot = true; // break; // // invalid chars // case '\0': // throw new HttpException("SR.GetString(SR.Invalid_vpath, virtualPath)"); // todo // default: // break; // } // } // } //} if (slashes) { // If we're supposed to fail on malformed path, then throw if ((options & VirtualPathOptions.FailIfMalformed) != 0) { throw new HttpException("SR.GetString(SR.Invalid_vpath, virtualPath)"); // todo } // Flip ----lashes, and remove duplicate slashes virtualPath = UrlPath.FixVirtualPathSlashes(virtualPath); } // Make sure it ends with a trailing slash if requested if ((options & VirtualPathOptions.EnsureTrailingSlash) != 0) { virtualPath = UrlPath.AppendSlashToPathIfNeeded(virtualPath); } VirtualPath virtualPathObject = new VirtualPath(); if (UrlPath.IsAppRelativePath(virtualPath)) { if (dot) { virtualPath = UrlPath.ReduceVirtualPath(virtualPath); } if (virtualPath[0] == UrlPath.appRelativeCharacter) { if ((options & VirtualPathOptions.AllowAppRelativePath) == 0) { throw new ArgumentException("SR.GetString(SR.VirtualPath_AllowAppRelativePath, virtualPath)"); // todo } virtualPathObject._appRelativeVirtualPath = virtualPath; } else { // It's possible for the path to become absolute after calling Reduce, // even though it started with "~/". e.g. if the app is "/app" and the path is // "~/../hello.aspx", it becomes "/hello.aspx", which is absolute if ((options & VirtualPathOptions.AllowAbsolutePath) == 0) { throw new ArgumentException("SR.GetString(SR.VirtualPath_AllowAbsolutePath, virtualPath)"); // todo } virtualPathObject._virtualPath = virtualPath; } } else { if (virtualPath[0] != '/') { if ((options & VirtualPathOptions.AllowRelativePath) == 0) { throw new ArgumentException("SR.GetString(SR.VirtualPath_AllowRelativePath, virtualPath)"); // todo } // Don't Reduce relative paths, since the Reduce method is broken (e.g. "../foo.aspx" --> "/foo.aspx!") // virtualPathObject._virtualPath = virtualPath; } else { if ((options & VirtualPathOptions.AllowAbsolutePath) == 0) { throw new ArgumentException("SR.GetString(SR.VirtualPath_AllowAbsolutePath, virtualPath)"); // todo } if (dot) { virtualPath = UrlPath.ReduceVirtualPath(virtualPath); } virtualPathObject._virtualPath = virtualPath; } } #if DBG virtualPathObject.ValidateState(); #endif return(virtualPathObject); }
public void IsEqualOrSubDirectory_SubDirIsASubDirOfDir_NoTrailingBackslash() { bool test = UrlPath.IsEqualOrSubdirectory("C:\\Directory", "C:\\Directory\\SubDirectory"); Assert.True(test); }
internal FileAttributesData GetFileAttributes(string alias) { DirectoryMonitor directoryMonitor = null; string fullPath; string file = null; FileAttributesData fad = null; if (alias == null) { throw CreateFileMonitoringException(-2147024809, alias); } if (this.IsFCNDisabled) { if ((alias.Length == 0) || !UrlPath.IsAbsolutePhysicalPath(alias)) { throw CreateFileMonitoringException(-2147024809, alias); } fullPath = GetFullPath(alias); FindFileData data = null; if (FindFileData.FindFile(fullPath, out data) == 0) { return(data.FileAttributesData); } return(null); } using (new ApplicationImpersonationContext()) { this._lockDispose.AcquireReaderLock(); try { if (!this._disposed) { FileMonitor monitor = (FileMonitor)this._aliases[alias]; if ((monitor != null) && !monitor.IsDirectory) { directoryMonitor = monitor.DirectoryMonitor; file = monitor.FileNameLong; } else { if ((alias.Length == 0) || !UrlPath.IsAbsolutePhysicalPath(alias)) { throw CreateFileMonitoringException(-2147024809, alias); } fullPath = GetFullPath(alias); string directoryOrRootName = UrlPath.GetDirectoryOrRootName(fullPath); file = Path.GetFileName(fullPath); if ((file != null) || (file.Length > 0)) { directoryMonitor = this.FindDirectoryMonitor(directoryOrRootName, false, false); } } } } finally { this._lockDispose.ReleaseReaderLock(); } if ((directoryMonitor == null) || !directoryMonitor.GetFileAttributes(file, out fad)) { FileAttributesData.GetFileAttributes(alias, out fad); } return(fad); } }
public void GetDirectoryOrRootName_Null() { string test = UrlPath.GetDirectoryOrRootName(null); Assert.Null(null); }
internal DateTime StartMonitoringFile(string alias, FileChangeEventHandler callback) { string fullPath; bool flag = false; if (alias == null) { throw CreateFileMonitoringException(-2147024809, alias); } if (this.IsFCNDisabled) { fullPath = GetFullPath(alias); FindFileData data = null; if (FindFileData.FindFile(fullPath, out data) == 0) { return(data.FileAttributesData.UtcLastWriteTime); } return(DateTime.MinValue); } using (new ApplicationImpersonationContext()) { FileMonitor monitor; string fileNameLong; FileAttributesData data2; this._lockDispose.AcquireReaderLock(); try { DirectoryMonitor directoryMonitor; if (this._disposed) { return(DateTime.MinValue); } monitor = (FileMonitor)this._aliases[alias]; if (monitor != null) { directoryMonitor = monitor.DirectoryMonitor; fileNameLong = monitor.FileNameLong; } else { flag = true; if ((alias.Length == 0) || !UrlPath.IsAbsolutePhysicalPath(alias)) { throw CreateFileMonitoringException(-2147024809, alias); } fullPath = GetFullPath(alias); if (this.IsBeneathAppPathInternal(fullPath)) { directoryMonitor = this._dirMonAppPathInternal; fileNameLong = fullPath.Substring(this._appPathInternal.Length + 1); } else { string directoryOrRootName = UrlPath.GetDirectoryOrRootName(fullPath); fileNameLong = Path.GetFileName(fullPath); if (string.IsNullOrEmpty(fileNameLong)) { throw CreateFileMonitoringException(-2147024809, alias); } directoryMonitor = this.FindDirectoryMonitor(directoryOrRootName, true, true); } } monitor = directoryMonitor.StartMonitoringFileWithAssert(fileNameLong, callback, alias); if (flag) { this._aliases[alias] = monitor; } } finally { this._lockDispose.ReleaseReaderLock(); } monitor.DirectoryMonitor.GetFileAttributes(fileNameLong, out data2); if (data2 != null) { return(data2.UtcLastWriteTime); } return(DateTime.MinValue); } }
public void IsEqualOrSubDirectory_Equal_SecondHasBackslash() { bool test = UrlPath.IsEqualOrSubdirectory("C:\\Directory", "C:\\Directory\\"); Assert.True(test); }
internal DateTime StartMonitoringPath(string alias, FileChangeEventHandler callback, out FileAttributesData fad) { FileMonitor monitor = null; DirectoryMonitor monitor2 = null; string fullPath; string file = null; bool flag = false; fad = null; if (alias == null) { throw new HttpException(System.Web.SR.GetString("Invalid_file_name_for_monitoring", new object[] { string.Empty })); } if (this.IsFCNDisabled) { fullPath = GetFullPath(alias); FindFileData data = null; if (FindFileData.FindFile(fullPath, out data) == 0) { fad = data.FileAttributesData; return(data.FileAttributesData.UtcLastWriteTime); } return(DateTime.MinValue); } using (new ApplicationImpersonationContext()) { this._lockDispose.AcquireReaderLock(); try { if (this._disposed) { return(DateTime.MinValue); } monitor = (FileMonitor)this._aliases[alias]; if (monitor != null) { file = monitor.FileNameLong; monitor = monitor.DirectoryMonitor.StartMonitoringFileWithAssert(file, callback, alias); } else { flag = true; if ((alias.Length == 0) || !UrlPath.IsAbsolutePhysicalPath(alias)) { throw new HttpException(System.Web.SR.GetString("Invalid_file_name_for_monitoring", new object[] { HttpRuntime.GetSafePath(alias) })); } fullPath = GetFullPath(alias); if (this.IsBeneathAppPathInternal(fullPath)) { monitor2 = this._dirMonAppPathInternal; file = fullPath.Substring(this._appPathInternal.Length + 1); monitor = monitor2.StartMonitoringFileWithAssert(file, callback, alias); } else { monitor2 = this.FindDirectoryMonitor(fullPath, false, false); if (monitor2 != null) { monitor = monitor2.StartMonitoringFileWithAssert(null, callback, alias); } else { string directoryOrRootName = UrlPath.GetDirectoryOrRootName(fullPath); file = Path.GetFileName(fullPath); if (!string.IsNullOrEmpty(file)) { monitor2 = this.FindDirectoryMonitor(directoryOrRootName, false, false); if (monitor2 != null) { try { monitor = monitor2.StartMonitoringFileWithAssert(file, callback, alias); } catch { } if (monitor != null) { goto Label_01C7; } } } monitor2 = this.FindDirectoryMonitor(fullPath, true, false); if (monitor2 != null) { file = null; } else { if (string.IsNullOrEmpty(file)) { throw CreateFileMonitoringException(-2147024809, alias); } monitor2 = this.FindDirectoryMonitor(directoryOrRootName, true, true); } monitor = monitor2.StartMonitoringFileWithAssert(file, callback, alias); } } } Label_01C7: if (!monitor.IsDirectory) { monitor.DirectoryMonitor.GetFileAttributes(file, out fad); } if (flag) { this._aliases[alias] = monitor; } } finally { this._lockDispose.ReleaseReaderLock(); } if (fad != null) { return(fad.UtcLastWriteTime); } return(DateTime.MinValue); } }
public void GetDirectoryOrRootName_NotDirectoryOrRoot() { string test = UrlPath.GetDirectoryOrRootName("Hello"); Assert.Equal("", test); }
private static string FileQueryUrl(string fileId, NameValueCollection values = null) { return(Uri.UriBuilder(Url.DRIVE, UrlPath.Create(Path.File).Append(fileId).ToString(), values)); }
public void IsEqualOrSubDirectory_NullDirAndSubDir() { bool test = UrlPath.IsEqualOrSubdirectory(null, null); Assert.True(test); }
public void Normalize_OnEmptyUrlPath_ThrowsArgumentException(bool isBasePath) => Assert.Throws <ArgumentException>(() => UrlPath.Normalize(string.Empty, isBasePath));