From 32740d67a77bb1f415c4ae67b92bd2b01fdff088 Mon Sep 17 00:00:00 2001 From: John Luo Date: Wed, 16 Mar 2016 14:27:27 -0700 Subject: [PATCH] Use NullFileProvider from FileSystem --- .../Internal/NullFileProvider.cs | 82 ------------------- 1 file changed, 82 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Hosting/Internal/NullFileProvider.cs diff --git a/src/Microsoft.AspNetCore.Hosting/Internal/NullFileProvider.cs b/src/Microsoft.AspNetCore.Hosting/Internal/NullFileProvider.cs deleted file mode 100644 index 6e27bba6f8..0000000000 --- a/src/Microsoft.AspNetCore.Hosting/Internal/NullFileProvider.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using Microsoft.Extensions.FileProviders; -using Microsoft.Extensions.Primitives; - -namespace Microsoft.AspNetCore.Hosting.Internal -{ - internal class NullFileProvider : IFileProvider - { - public IDirectoryContents GetDirectoryContents(string subpath) - { - return new NullDirectoryContents(); - } - - public IFileInfo GetFileInfo(string subpath) - { - return new NullFileInfo(subpath); - } - - public IChangeToken Watch(string filter) - { - return new NullChangeToken(); - } - - private class NullDirectoryContents : IDirectoryContents - { - public bool Exists => false; - - public IEnumerator GetEnumerator() - { - yield break; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - } - - internal class NullFileInfo : IFileInfo - { - public NullFileInfo(string name) - { - Name = name; - } - - public bool Exists => false; - - public bool IsDirectory => false; - - public DateTimeOffset LastModified => DateTimeOffset.MinValue; - - public long Length => -1; - - public string Name { get; } - - public string PhysicalPath => null; - - public Stream CreateReadStream() - { - throw new FileNotFoundException(string.Format($"{nameof(NullFileProvider)} does not support reading files.", Name)); - } - } - - private class NullChangeToken : IChangeToken - { - public bool HasChanged => false; - - public bool ActiveChangeCallbacks => false; - - public IDisposable RegisterChangeCallback(Action callback, object state) - { - throw new NotSupportedException($"{nameof(NullFileProvider)} does not support registering change notifications."); - } - } - } -}