本文整理汇总了C#中IFileSystem.Subscribe方法的典型用法代码示例。如果您正苦于以下问题:C# IFileSystem.Subscribe方法的具体用法?C# IFileSystem.Subscribe怎么用?C# IFileSystem.Subscribe使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFileSystem
的用法示例。
在下文中一共展示了IFileSystem.Subscribe方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TerrificTemplateRepository
public TerrificTemplateRepository(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
InitCache();
if (!_fileSystem.SupportsSubscribe)
return;
_fileSystem.Subscribe(GlobPattern.AllWithExtension("html"), files => InitCache());
}
示例2: FromFile
public static Project FromFile(string input, IFileSystem fileSystem)
{
var jObject = JsonConvert.DeserializeObject<Dictionary<string, JToken>>(input);
var project = new Project();
foreach (var entry in jObject)
{
var kindObj = entry.Key;
string[] list;
if (entry.Value is JArray)
list = entry.Value.ToObject<string[]>();
else
list = new[] {entry.Value.ToObject<string>()};
foreach (var item in list)
{
var info = fileSystem.GetFileInfo(PathInfo.Create(item));
if (info == null)
{
var globPattern = GlobPattern.Create(item);
if (!globPattern.IsWildcard)
throw new InvalidProjectFileException($"Could not find file {item}.");
var items = fileSystem.GetFiles(globPattern);
foreach (var file in items)
{
var fileItem = new FileProjectItem(kindObj, file, fileSystem);
ProjectItem existing;
if (!project.TryGetItemById(fileItem.Identifier, out existing))
project.AddItem(fileItem);
}
project.AddSubscription(fileSystem.Subscribe(globPattern, a =>
{
HandleChange(a, project, kindObj, fileSystem);
}));
}
else
{
AddFile(fileSystem, project, kindObj, info, item);
}
}
}
return project;
}
示例3: AddFile
private static void AddFile(IFileSystem fileSystem, Project project, string kindObj, IFileInfo info, string item)
{
project.AddItem(new FileProjectItem(kindObj, info, fileSystem));
project.AddSubscription(fileSystem.Subscribe(GlobPattern.Exact(item),
a => { HandleChange(a, project, kindObj, fileSystem); }));
}