本文整理汇总了C#中IProjectContent.GetFile方法的典型用法代码示例。如果您正苦于以下问题:C# IProjectContent.GetFile方法的具体用法?C# IProjectContent.GetFile怎么用?C# IProjectContent.GetFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProjectContent
的用法示例。
在下文中一共展示了IProjectContent.GetFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindReferences
public override IEnumerable<MemberReference> FindReferences (Project project, IProjectContent content, IEnumerable<FilePath> possibleFiles, IEnumerable<object> members)
{
if (project == null)
throw new ArgumentNullException ("project", "Project not set.");
if (content == null)
throw new ArgumentNullException ("content", "Project content not set.");
SetPossibleFiles (possibleFiles);
SetSearchedMembers (members);
var scopes = searchedMembers.Select (e => refFinder.GetSearchScopes (e as IEntity));
var compilation = TypeSystemService.GetCompilation (project);
List<MemberReference> refs = new List<MemberReference> ();
foreach (var opendoc in openDocuments) {
foreach (var newRef in FindInDocument (opendoc.Item2)) {
if (newRef == null || refs.Any (r => r.FileName == newRef.FileName && r.Region == newRef.Region))
continue;
refs.Add (newRef);
}
}
foreach (var file in files) {
string text = Mono.TextEditor.Utils.TextFileUtility.ReadAllText (file);
if (memberName != null && text.IndexOf (memberName, StringComparison.Ordinal) < 0 &&
(keywordName == null || text.IndexOf (keywordName, StringComparison.Ordinal) < 0))
continue;
using (var editor = TextEditorData.CreateImmutable (text)) {
editor.Document.FileName = file;
var unit = new CSharpParser ().Parse (editor);
if (unit == null)
continue;
var storedFile = content.GetFile (file);
var parsedFile = storedFile as CSharpParsedFile;
if (parsedFile == null && storedFile is ParsedDocumentDecorator) {
parsedFile = ((ParsedDocumentDecorator)storedFile).ParsedFile as CSharpParsedFile;
}
if (parsedFile == null) {
// for fallback purposes - should never happen.
parsedFile = unit.ToTypeSystem ();
content = content.UpdateProjectContent (content.GetFile (file), parsedFile);
compilation = content.CreateCompilation ();
}
foreach (var scope in scopes) {
refFinder.FindReferencesInFile (
scope,
parsedFile,
unit,
compilation,
(astNode, result) => {
var newRef = GetReference (result, astNode, file, editor);
if (newRef == null || refs.Any (r => r.FileName == newRef.FileName && r.Region == newRef.Region))
return;
refs.Add (newRef);
},
CancellationToken.None
);
}
}
}
return refs;
}
示例2: GetSpecialComments
static IEnumerable<Tag> GetSpecialComments (IProjectContent ctx, string name)
{
var doc = ctx.GetFile (name) as ParsedDocument;
if (doc == null)
return Enumerable.Empty<Tag> ();
return (IEnumerable<Tag>)doc.TagComments;
}