本文整理汇总了C#中ICSharpCode.NRefactory.CSharp.Completion.CompletionDataWrapper.AddConstructors方法的典型用法代码示例。如果您正苦于以下问题:C# CompletionDataWrapper.AddConstructors方法的具体用法?C# CompletionDataWrapper.AddConstructors怎么用?C# CompletionDataWrapper.AddConstructors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICSharpCode.NRefactory.CSharp.Completion.CompletionDataWrapper
的用法示例。
在下文中一共展示了CompletionDataWrapper.AddConstructors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddTypesAndNamespaces
void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func<IType, IType> typePred = null, Predicate<IMember> memberPred = null, Action<ICompletionData, IType> callback = null, bool onlyAddConstructors = false)
{
var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);
if (currentType != null) {
for (var ct = ctx.CurrentTypeDefinition; ct != null; ct = ct.DeclaringTypeDefinition) {
foreach (var nestedType in ct.GetNestedTypes ()) {
if (!lookup.IsAccessible(nestedType.GetDefinition(), true))
continue;
if (onlyAddConstructors) {
if (!nestedType.GetConstructors().Any(c => lookup.IsAccessible(c, true)))
continue;
}
if (typePred == null) {
if (onlyAddConstructors)
wrapper.AddConstructors(nestedType, false, IsAttributeContext(node));
else
wrapper.AddType(nestedType, false, IsAttributeContext(node));
continue;
}
var type = typePred(nestedType);
if (type != null) {
var a2 = onlyAddConstructors ? wrapper.AddConstructors(type, false, IsAttributeContext(node)) : wrapper.AddType(type, false, IsAttributeContext(node));
if (a2 != null && callback != null) {
callback(a2, type);
}
}
continue;
}
}
if (this.currentMember != null && !(node is AstType)) {
var def = ctx.CurrentTypeDefinition;
if (def == null && currentType != null)
def = Compilation.MainAssembly.GetTypeDefinition(currentType.FullTypeName);
if (def != null) {
bool isProtectedAllowed = true;
foreach (var member in def.GetMembers (m => currentMember.IsStatic ? m.IsStatic : true)) {
if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") {
continue;
}
if (member.SymbolKind == SymbolKind.Operator) {
continue;
}
if (member.IsExplicitInterfaceImplementation) {
continue;
}
if (!lookup.IsAccessible(member, isProtectedAllowed)) {
continue;
}
if (memberPred == null || memberPred(member)) {
wrapper.AddMember(member);
}
}
var declaring = def.DeclaringTypeDefinition;
while (declaring != null) {
foreach (var member in declaring.GetMembers (m => m.IsStatic)) {
if (memberPred == null || memberPred(member)) {
wrapper.AddMember(member);
}
}
declaring = declaring.DeclaringTypeDefinition;
}
}
}
if (ctx.CurrentTypeDefinition != null) {
foreach (var p in ctx.CurrentTypeDefinition.TypeParameters) {
wrapper.AddTypeParameter(p);
}
}
}
var scope = ctx.CurrentUsingScope;
for (var n = scope; n != null; n = n.Parent) {
foreach (var pair in n.UsingAliases) {
wrapper.AddAlias(pair.Key);
}
foreach (var alias in n.ExternAliases) {
wrapper.AddAlias(alias);
}
foreach (var u in n.Usings) {
foreach (var type in u.Types) {
if (!lookup.IsAccessible(type, false))
continue;
IType addType = typePred != null ? typePred(type) : type;
if (onlyAddConstructors && addType != null) {
if (!addType.GetConstructors().Any(c => lookup.IsAccessible(c, true)))
continue;
}
if (addType != null) {
var a = onlyAddConstructors ? wrapper.AddConstructors(addType, false, IsAttributeContext(node)) : wrapper.AddType(addType, false, IsAttributeContext(node));
if (a != null && callback != null) {
callback(a, type);
}
//.........这里部分代码省略.........
示例2: AddTypesAndNamespaces
void AddTypesAndNamespaces(CompletionDataWrapper wrapper, CSharpResolver state, AstNode node, Func<IType, IType> typePred = null, Predicate<IMember> memberPred = null, Action<ICompletionData, IType> callback = null, bool onlyAddConstructors = false)
{
var lookup = new MemberLookup(ctx.CurrentTypeDefinition, Compilation.MainAssembly);
if (currentType != null) {
for (var ct = ctx.CurrentTypeDefinition; ct != null; ct = ct.DeclaringTypeDefinition) {
foreach (var nestedType in ct.GetNestedTypes ()) {
if (!lookup.IsAccessible (nestedType.GetDefinition (), true))
continue;
if (onlyAddConstructors) {
if (!nestedType.GetConstructors().Any(c => lookup.IsAccessible(c, true)))
continue;
}
if (typePred == null) {
if (onlyAddConstructors)
wrapper.AddConstructors (nestedType, false, IsAttributeContext(node));
else
wrapper.AddType(nestedType, false, IsAttributeContext(node));
continue;
}
var type = typePred(nestedType);
if (type != null) {
var a2 = onlyAddConstructors ? wrapper.AddConstructors(type, false, IsAttributeContext(node)) : wrapper.AddType(type, false, IsAttributeContext(node));
if (a2 != null && callback != null) {
callback(a2, type);
}
}
continue;
}
}
if (this.currentMember != null && !(node is AstType)) {
var def = ctx.CurrentTypeDefinition;
if (def == null && currentType != null)
def = Compilation.MainAssembly.GetTypeDefinition(currentType.FullTypeName);
if (def != null) {
bool isProtectedAllowed = true;
foreach (var member in def.GetMembers (m => currentMember.IsStatic ? m.IsStatic : true)) {
if (member is IMethod && ((IMethod)member).FullName == "System.Object.Finalize") {
continue;
}
if (member.SymbolKind == SymbolKind.Operator) {
continue;
}
if (member.IsExplicitInterfaceImplementation) {
continue;
}
if (!lookup.IsAccessible(member, isProtectedAllowed)) {
continue;
}
if (memberPred == null || memberPred(member)) {
wrapper.AddMember(member);
}
}
var declaring = def.DeclaringTypeDefinition;
while (declaring != null) {
foreach (var member in declaring.GetMembers (m => m.IsStatic)) {
if (memberPred == null || memberPred(member)) {
wrapper.AddMember(member);
}
}
declaring = declaring.DeclaringTypeDefinition;
}
}
}
if (ctx.CurrentTypeDefinition != null) {
foreach (var p in ctx.CurrentTypeDefinition.TypeParameters) {
wrapper.AddTypeParameter(p);
}
}
}
var scope = ctx.CurrentUsingScope;
for (var n = scope; n != null; n = n.Parent) {
foreach (var pair in n.UsingAliases) {
wrapper.AddAlias(pair.Key);
}
foreach (var alias in n.ExternAliases) {
wrapper.AddAlias(alias);
}
foreach (var u in n.Usings) {
foreach (var type in u.Types) {
if (!lookup.IsAccessible(type, false))
continue;
IType addType = typePred != null ? typePred(type) : type;
if (onlyAddConstructors && addType != null) {
if (!addType.GetConstructors().Any(c => lookup.IsAccessible(c, true)))
continue;
}
if (addType != null) {
var a = onlyAddConstructors ? wrapper.AddConstructors(addType, false, IsAttributeContext(node)) : wrapper.AddType(addType, false, IsAttributeContext(node));
if (a != null && callback != null) {
callback(a, type);
}
//.........这里部分代码省略.........