本文整理汇总了C#中Loader.LoadFromReader方法的典型用法代码示例。如果您正苦于以下问题:C# Loader.LoadFromReader方法的具体用法?C# Loader.LoadFromReader怎么用?C# Loader.LoadFromReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Loader
的用法示例。
在下文中一共展示了Loader.LoadFromReader方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _performPreflight
private async Task<PreflightResult> _performPreflight(RefSpec refSpec, CancellationToken token)
// requires refSpec.Source != null
// ensures result != null
{
if (refSpec.ErrorMessage != null)
return new PreflightResult { ErrorMessage = refSpec.ErrorMessage };
token.ThrowIfCancellationRequested();
_trace.TraceEvent(TraceEventType.Information, 0, "Preflight parsing of {0} requested.", refSpec);
// Make sure refSpec has a re-usable source (will have to support both preflight and actual compilation)
var source = refSpec.Source;
if (source == null)
throw new ArgumentException(Resources.SelfAssemblingPlan_RefSpecMustHaveSource, "refSpec");
var reportedPath = _getPath(source);
if (source.IsSingleUse)
source = await source.CacheInMemoryAsync();
token.ThrowIfCancellationRequested();
// Perform preflight parse
var eng = new Engine { ExecutionProhibited = true };
var app = new Application();
var ldr =
new Loader(new LoaderOptions(eng, app)
{
// Important: Have preflight flag set
PreflightModeEnabled = true,
ReconstructSymbols = false,
RegisterCommands = false,
StoreSourceInformation = false,
});
TextReader sourceReader;
if (!source.TryOpen(out sourceReader))
{
var errorResult = new PreflightResult
{
ErrorMessage =
"Failed to open " + refSpec + " for preflight parsing."
};
return errorResult;
}
ldr.LoadFromReader(sourceReader, refSpec.ResolvedPath != null ? refSpec.ResolvedPath.ToString() : null);
// Extract preflight information
ModuleName theModuleName;
if (!ModuleName.TryParse(app.Meta[Module.NameKey], out theModuleName))
theModuleName = app.Module.Name;
MetaEntry noStdLibEntry;
var result = new PreflightResult
{
ModuleName = theModuleName,
SuppressStandardLibrary =
app.Meta.TryGetValue(Module.NoStandardLibraryKey, out noStdLibEntry) && noStdLibEntry.Switch,
Path = reportedPath
};
result.References.AddRange(
app.Meta[Module.ReferencesKey].List.Where(entry => !entry.Equals(new MetaEntry("")))
.Select(_parseRefSpec));
_trace.TraceEvent(TraceEventType.Verbose, 0, "Preflight parsing of {0} finished.", refSpec);
return result;
}