本文整理汇总了C#中IProjectContent.GetNamespaceContents方法的典型用法代码示例。如果您正苦于以下问题:C# IProjectContent.GetNamespaceContents方法的具体用法?C# IProjectContent.GetNamespaceContents怎么用?C# IProjectContent.GetNamespaceContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProjectContent
的用法示例。
在下文中一共展示了IProjectContent.GetNamespaceContents方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddUsing
public static void AddUsing(List<ICompletionEntry> result, IUsing u, IProjectContent projectContent)
{
if (u == null) {
return;
}
bool importNamespaces = projectContent.Language.ImportNamespaces;
bool importClasses = projectContent.Language.CanImportClasses;
foreach (string name in u.Usings) {
if (importClasses) {
IClass c = projectContent.GetClass(name, 0);
if (c != null) {
ArrayList members = new ArrayList();
IReturnType t = c.DefaultReturnType;
members.AddRange(t.GetMethods());
members.AddRange(t.GetFields());
members.AddRange(t.GetEvents());
members.AddRange(t.GetProperties());
foreach (IMember m in members) {
if (m.IsStatic && m.IsPublic) {
result.Add(m);
}
}
continue;
}
}
if (importNamespaces) {
string newName = null;
if (projectContent.DefaultImports != null) {
newName = projectContent.DefaultImports.SearchNamespace(name);
}
projectContent.AddNamespaceContents(result, newName ?? name, projectContent.Language, true);
} else {
foreach (ICompletionEntry o in projectContent.GetNamespaceContents(name)) {
if (!(o is NamespaceEntry))
result.Add(o);
}
}
}
if (u.HasAliases) {
foreach (string alias in u.Aliases.Keys) {
result.Add(new AliasEntry(alias));
}
}
}
示例2: GetNamespaceMembers
public static IEnumerable<IClass> GetNamespaceMembers(IProjectContent pc, string xmlNamespace)
{
if (pc == null)
throw new ArgumentNullException("pc");
if (!string.IsNullOrEmpty(xmlNamespace)) {
if (xmlNamespace.StartsWith("clr-namespace:", StringComparison.OrdinalIgnoreCase))
return pc.GetNamespaceContents(GetNamespaceNameFromClrNamespace(xmlNamespace)).OfType<IClass>();
else {
var list = new List<ICompletionEntry>();
AddNamespaceMembersInAssembly(pc, xmlNamespace, list);
foreach (IProjectContent p in pc.ThreadSafeGetReferencedContents()) {
AddNamespaceMembersInAssembly(p, xmlNamespace, list);
}
return list.OfType<IClass>();
}
}
return Enumerable.Empty<IClass>();
}
示例3: AddContentsFromCallingClass
static void AddContentsFromCallingClass(List<ICompletionEntry> result, IProjectContent projectContent, IClass callingClass)
{
if (callingClass == null) {
return;
}
// use HashSet so that Contains lookups are possible in O(1).
HashSet<ICompletionEntry> existingResults = new HashSet<ICompletionEntry>(result);
string[] namespaceParts = callingClass.Namespace.Split('.');
for (int i = 1; i <= namespaceParts.Length; i++) {
foreach (ICompletionEntry member in projectContent.GetNamespaceContents(string.Join(".", namespaceParts, 0, i))) {
if (!existingResults.Contains(member))
result.Add(member);
}
}
IClass currentClass = callingClass;
do {
foreach (IClass innerClass in currentClass.GetCompoundClass().GetAccessibleTypes(currentClass)) {
if (!existingResults.Contains(innerClass))
result.Add(innerClass);
}
currentClass = currentClass.DeclaringType;
} while (currentClass != null);
}
示例4: GetCompletionData
public override ArrayList GetCompletionData(IProjectContent projectContent)
{
return projectContent.GetNamespaceContents(name);
}