src/Library/NetPro.TypeFinder/NetProFileProvider.cs
(开头部分) 22KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Hosting;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
namespace System.NetPro
{
/// <summary>
/// IO functions using the on-disk file system
/// </summary>
public class NetProFileProvider : PhysicalFileProvider, INetProFileProvider
{
/// <summary>
/// Initializes a new instance of a NetProFileProvider
/// </summary>
/// <param name="hostingEnvironment">Hosting environment</param>
public NetProFileProvider(IHostEnvironment hostingEnvironment)
: base(System.IO.File.Exists(hostingEnvironment.ContentRootPath) ? Path.GetDirectoryName(hostingEnvironment.ContentRootPath) : hostingEnvironment.ContentRootPath)
{
var path = hostingEnvironment.ContentRootPath ?? string.Empty;
if (System.IO.File.Exists(path))
path = Path.GetDirectoryName(path);
BaseDirectory = path;
}
#region Utilities
private static void DeleteDirectoryRecursive(string path)
{
Directory.Delete(path, true);
const int maxIterationToWait = 10;
var curIteration = 0;
//according to the documentation(https://msdn.microsoft.com/ru-ru/library/windows/desktop/aa365488.aspx)
//System.IO.Directory.Delete method ultimately (after removing the files) calls native
//RemoveDirectory function which marks the directory as "deleted". That's why we wait until
//the directory is actually deleted. For more details see https://stackoverflow.com/a/4245121
while (Directory.Exists(path))
{
curIteration += 1;
if (curIteration > maxIterationToWait)
return;
Thread.Sleep(100);
}
}
#endregion
/// <summary>
/// Combines an array of strings into a path
/// </summary>
/// <param name="paths">An array of parts of the path</param>
/// <returns>The combined paths</returns>
public virtual string Combine(params string[] paths)
{
return Path.Combine(paths);
后面还有 491 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。