本文整理汇总了C#中FileSystem.ReadTextFile方法的典型用法代码示例。如果您正苦于以下问题:C# FileSystem.ReadTextFile方法的具体用法?C# FileSystem.ReadTextFile怎么用?C# FileSystem.ReadTextFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem.ReadTextFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFromFile
public static FileMatcher ReadFromFile(string file)
{
var system = new FileSystem();
var matcher = new FileMatcher();
system.ReadTextFile(file, text => {
if (text.IsEmpty()) return;
var match = Build(text);
matcher.Add(match);
});
return matcher;
}
示例2: ReadFrom
public static Profile ReadFrom(DeploymentSettings settings, string profileName)
{
var profile = new Profile(profileName);
var profileFile = settings.ProfileFileNameFor(profileName);
var fileSystem = new FileSystem();
if (!fileSystem.FileExists(profileFile))
{
var sb = new StringBuilder();
sb.AppendFormat("Couldn't find the profile '{0}'", profileFile);
sb.AppendLine();
sb.AppendLine("Looked in:");
settings.Directories.Each(d => sb.AppendLine(" {0}".ToFormat(d)));
throw new Exception(sb.ToString());
}
fileSystem.ReadTextFile(profileFile, profile.ReadText);
return profile;
}
示例3: ReadFrom
public static Profile ReadFrom(DeploymentSettings settings, string profileName, string settingsProfileName = null)
{
var profile = new Profile(profileName);
var profileFile = settings.ProfileFileNameFor(profileName);
var fileSystem = new FileSystem();
if (!fileSystem.FileExists(profileFile))
{
var sb = new StringBuilder();
sb.AppendFormat("Couldn't find the profile '{0}'", profileFile);
sb.AppendLine();
sb.AppendLine("Looked in:");
settings.Directories.Each(d => sb.AppendLine(" {0}".ToFormat(d)));
throw new Exception(sb.ToString());
}
// Settings profile goes first
if (settingsProfileName != null)
{
profile.AddProfileDependency(settingsProfileName);
}
fileSystem.ReadTextFile(profileFile, profile.ReadText);
profile._childProfileNames.Each(childName =>
{
var childProfile = ReadFrom(settings, childName);
profile._childProfiles.Add(childProfile);
childProfile.Data.AllKeys.Each(childKey =>
{
// do not override main profile settings from dependencies.
// NOTE: Has(childKey) doesn't work here because SettingsData has a weird inner dictionary with a special key structure
if (profile.Data.AllKeys.Any(k => k == childKey)) return;
profile.Data[childKey] = childProfile.Data[childKey];
});
});
return profile;
}
示例4: ForFile
public static StringPropertyReader ForFile(string file)
{
var fileSystem = new FileSystem();
return new StringPropertyReader(callback => fileSystem.ReadTextFile(file, callback));
}