本文整理汇总了C#中ICompilation.Import方法的典型用法代码示例。如果您正苦于以下问题:C# ICompilation.Import方法的具体用法?C# ICompilation.Import怎么用?C# ICompilation.Import使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICompilation
的用法示例。
在下文中一共展示了ICompilation.Import方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapToNestedCompilation
CSharpTypeResolveContext MapToNestedCompilation(CSharpTypeResolveContext context, ICompilation nestedCompilation)
{
var nestedContext = new CSharpTypeResolveContext(nestedCompilation.MainAssembly);
if (context.CurrentUsingScope != null) {
nestedContext = nestedContext.WithUsingScope(context.CurrentUsingScope.UnresolvedUsingScope.Resolve(nestedCompilation));
}
if (context.CurrentTypeDefinition != null) {
nestedContext = nestedContext.WithCurrentTypeDefinition(nestedCompilation.Import(context.CurrentTypeDefinition));
}
return nestedContext;
}
示例2: XamlSymbolSearch
public XamlSymbolSearch(IProject project, ISymbol entity)
{
compilation = SD.ParserService.GetCompilation(project);
if (entity is IEntity)
this.entity = compilation.Import((IEntity)entity);
interestingFileNames = new List<FileName>();
if (this.entity == null)
return;
foreach (var item in project.Items.OfType<FileProjectItem>().Where(i => i.FileName.HasExtension(".xaml")))
interestingFileNames.Add(item.FileName);
workAmount = interestingFileNames.Count;
workAmountInverse = 1.0 / workAmount;
}
示例3: GetInterestingFiles
/// <summary>
/// Gets the file names that possibly contain references to the element being searched for.
/// </summary>
public IEnumerable<CSharpUnresolvedFile> GetInterestingFiles(IFindReferenceSearchScope searchScope, ICompilation compilation)
{
if (searchScope == null)
throw new ArgumentNullException("searchScope");
if (compilation == null)
throw new ArgumentNullException("compilation");
var pc = compilation.MainAssembly.UnresolvedAssembly as IProjectContent;
if (pc == null)
throw new ArgumentException("Main assembly is not a project content");
if (searchScope.TopLevelTypeDefinition != null) {
ITypeDefinition topLevelTypeDef = compilation.Import(searchScope.TopLevelTypeDefinition);
if (topLevelTypeDef == null) {
// This compilation cannot have references to the target entity.
return EmptyList<CSharpUnresolvedFile>.Instance;
}
switch (searchScope.Accessibility) {
case Accessibility.None:
case Accessibility.Private:
if (topLevelTypeDef.ParentAssembly == compilation.MainAssembly)
return topLevelTypeDef.Parts.Select(p => p.UnresolvedFile).OfType<CSharpUnresolvedFile>().Distinct();
else
return EmptyList<CSharpUnresolvedFile>.Instance;
case Accessibility.Protected:
return GetInterestingFilesProtected(topLevelTypeDef);
case Accessibility.Internal:
if (topLevelTypeDef.ParentAssembly.InternalsVisibleTo(compilation.MainAssembly))
return pc.Files.OfType<CSharpUnresolvedFile>();
else
return EmptyList<CSharpUnresolvedFile>.Instance;
case Accessibility.ProtectedAndInternal:
if (topLevelTypeDef.ParentAssembly.InternalsVisibleTo(compilation.MainAssembly))
return GetInterestingFilesProtected(topLevelTypeDef);
else
return EmptyList<CSharpUnresolvedFile>.Instance;
case Accessibility.ProtectedOrInternal:
if (topLevelTypeDef.ParentAssembly.InternalsVisibleTo(compilation.MainAssembly))
return pc.Files.OfType<CSharpUnresolvedFile>();
else
return GetInterestingFilesProtected(topLevelTypeDef);
default:
return pc.Files.OfType<CSharpUnresolvedFile>();
}
} else {
return pc.Files.OfType<CSharpUnresolvedFile>();
}
}
示例4: Import
static IEnumerable<ITypeDefinition> Import (ICompilation compilation, IEnumerable<ITypeDefinition> types)
{
return types.Select (t => compilation.Import (t));
}
示例5: SearchCompilation
static void SearchCompilation (ISearchProgressMonitor monitor, ICompilation comp, ITypeDefinition cls, IMember member)
{
var importedType = comp.Import (cls);
if (importedType == null) {
return;
}
IMember impMember = null;
if (member != null) {
impMember = comp.Import (member);
if (impMember == null) {
return;
}
}
foreach (var derivedType in comp.MainAssembly.GetAllTypeDefinitions ()) {
if (!derivedType.IsDerivedFrom (importedType))
continue;
IEntity result;
if (member != null) {
result = FindDerivedMember (impMember, derivedType);
if (result == null)
continue;
}
else {
result = derivedType;
}
ReportResult (monitor, result);
}
}
示例6: Equals
public static bool Equals(ICompilation comp, IList<IParameter> x, IList<IParameter> y)
{
if (x == y)
return true;
if (x == null || y == null || x.Count != y.Count)
return false;
for (int i = 0; i < x.Count; i++) {
var a = x[i];
var b = y[i];
if (a == null && b == null)
continue;
if (a == null || b == null)
return false;
// We want to consider the parameter lists "Method<T>(T a)" and "Method<S>(S b)" as equal.
// However, the parameter types are not considered equal, as T is a different type parameter than S.
// In order to compare the method signatures, we will normalize all method type parameters.
IType aType = a.Type.AcceptVisitor(normalizationVisitor);
IType bType = b.Type.AcceptVisitor(normalizationVisitor);
bType = comp.Import (bType);
if (!aType.Equals(bType))
return false;
}
return true;
}