本文整理汇总了C#中IReturnType.GetMethods方法的典型用法代码示例。如果您正苦于以下问题:C# IReturnType.GetMethods方法的具体用法?C# IReturnType.GetMethods怎么用?C# IReturnType.GetMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IReturnType
的用法示例。
在下文中一共展示了IReturnType.GetMethods方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddMethodsFromBaseType
void AddMethodsFromBaseType(List<IMethod> l, IReturnType baseType)
{
if (baseType != null) {
foreach (IMethod m in baseType.GetMethods()) {
if (m.IsConstructor)
continue;
bool ok = true;
if (m.IsOverridable) {
StringComparer comparer = m.DeclaringType.ProjectContent.Language.NameComparer;
foreach (IMethod oldMethod in c.Methods) {
if (comparer.Equals(oldMethod.Name, m.Name)) {
if (m.IsStatic == oldMethod.IsStatic && object.Equals(m.ReturnType, oldMethod.ReturnType)) {
if (DiffUtility.Compare(oldMethod.Parameters, m.Parameters) == 0) {
ok = false;
break;
}
}
}
}
}
if (ok)
l.Add(m);
}
}
}
示例2: GetDelegateOrExpressionTreeSignature
internal static IMethod GetDelegateOrExpressionTreeSignature(IReturnType rt, bool allowExpressionTree)
{
if (rt == null)
return null;
IClass c = rt.GetUnderlyingClass();
if (allowExpressionTree && c != null && c.FullyQualifiedName == "System.Linq.Expressions.Expression") {
ConstructedReturnType crt = rt.CastToConstructedReturnType();
if (crt != null && crt.TypeArguments.Count == 1) {
// get delegate type from expression type
rt = crt.TypeArguments[0];
c = rt != null ? rt.GetUnderlyingClass() : null;
}
}
if (c != null && c.ClassType == ClassType.Delegate) {
return rt.GetMethods().FirstOrDefault((IMethod m) => m.Name == "Invoke");
}
return null;
}
示例3: ResolveConstructorOverload
internal ResolveResult ResolveConstructorOverload(IReturnType rt, List<Expression> arguments)
{
if (rt == null)
return null;
List<IMethod> methods = rt.GetMethods().Where(m => m.IsConstructor && !m.IsStatic).ToList();
IReturnType[] argumentTypes = arguments.Select<Expression, IReturnType>(ResolveType).ToArray();
bool resultIsAcceptable;
IMethod result = MemberLookupHelper.FindOverload(methods, argumentTypes, out resultIsAcceptable);
ResolveResult rr = CreateMemberResolveResult(result);
if (rr != null)
rr.ResolvedType = rt;
return rr;
}
示例4: GetConstructors
IEnumerable<IMethod> GetConstructors(IReturnType rt)
{
// no need to add default constructor here:
// default constructors should already be present in rt.GetMethods()
if (rt == null)
return Enumerable.Empty<IMethod>();
else
return rt.GetMethods().Where(m => m.IsConstructor && !m.IsStatic);
}
示例5: ResolveMethodInType
void ResolveMethodInType(IReturnType containingType, string methodName, ExpressionCollection arguments)
{
List<IMethod> methods = new List<IMethod>();
bool isClassInInheritanceTree = false;
if (callingClass != null)
isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(containingType.GetUnderlyingClass());
foreach (IMethod m in containingType.GetMethods()) {
if (IsSameName(m.Name, methodName)
&& m.IsAccessible(callingClass, isClassInInheritanceTree)
) {
methods.Add(m);
}
}
if (methods.Count == 0) {
List<IMethodOrProperty> list = new List<IMethodOrProperty>();
ResolveResult.AddExtensions(callingClass.ProjectContent.Language, list.Add, callingClass, containingType);
foreach (IMethodOrProperty mp in list) {
if (IsSameName(mp.Name, methodName) && mp is IMethod) {
IMethod m = (IMethod)mp.CreateSpecializedMember();
m.Parameters.RemoveAt(0);
methods.Add(m);
}
}
}
ResolveInvocation(methods, arguments);
}
示例6: ResolveMember
bool ResolveMember(IReturnType type, string memberName)
{
ClearResult();
if (type == null)
return false;
bool isClassInInheritanceTree = false;
if (callingClass != null)
isClassInInheritanceTree = callingClass.IsTypeInInheritanceTree(type.GetUnderlyingClass());
foreach (IProperty p in type.GetProperties()) {
if (IsSameName(p.Name, memberName)) {
MakeResult(p);
return true;
}
}
foreach (IField f in type.GetFields()) {
if (IsSameName(f.Name, memberName)) {
MakeResult(f);
return true;
}
}
foreach (IEvent e in type.GetEvents()) {
if (IsSameName(e.Name, memberName)) {
MakeResult(e);
return true;
}
}
foreach (IMethod m in type.GetMethods()) {
if (IsSameName(m.Name, memberName)) {
MakeMethodResult(type, memberName);
return true;
}
}
if (callingClass != null) {
List<IMethodOrProperty> list = new List<IMethodOrProperty>();
ResolveResult.AddExtensions(callingClass.ProjectContent.Language, list.Add, callingClass, type);
foreach (IMethodOrProperty mp in list) {
if (IsSameName(mp.Name, memberName)) {
if (mp is IMethod)
MakeMethodResult(type, memberName);
else
MakeResult(mp);
return true;
}
}
}
return false;
}
示例7: ResolvePropertyName
MemberResolveResult ResolvePropertyName(IReturnType resolvedType, string propertyName, bool allowAttached)
{
IMember member = resolvedType.GetProperties().Find(delegate(IProperty p) { return p.Name == propertyName; });
if (member == null) {
member = resolvedType.GetEvents().Find(delegate(IEvent p) { return p.Name == propertyName; });
}
if (member == null && allowAttached) {
IMethod method = resolvedType.GetMethods().Find(
delegate(IMethod p) {
return p.IsStatic && p.Parameters.Count == 1 && p.Name == "Get" + propertyName;
});
member = method;
if (member != null) {
member = new DefaultProperty(resolvedType.GetUnderlyingClass(), propertyName) { ReturnType = method.ReturnType };
} else {
IMethod m = resolvedType.GetMethods().Find(
delegate(IMethod p) {
return p.IsPublic && p.IsStatic && p.Parameters.Count == 2 && (p.Name == "Add" + propertyName + "Handler" || p.Name == "Remove" + propertyName + "Handler");
});
member = m;
if (member != null)
member = new DefaultEvent(resolvedType.GetUnderlyingClass(), propertyName) { ReturnType = m.Parameters[1].ReturnType };
}
}
if (member != null)
return new MemberResolveResult(callingClass, null, member);
return null;
}
示例8: DoPositionalArgsCompletion
/// <remarks>returns true if elements from named args completion should be added afterwards.</remarks>
static bool DoPositionalArgsCompletion(XamlCompletionItemList list, XamlCompletionContext context, MarkupExtensionInfo markup, IReturnType type)
{
switch (type.FullyQualifiedName) {
case "System.Windows.Markup.ArrayExtension":
case "System.Windows.Markup.NullExtension":
// x:Null/x:Array does not need completion, ignore it
break;
case "System.Windows.Markup.StaticExtension":
if (context.AttributeValue.ExtensionValue.PositionalArguments.Count <= 1)
return DoStaticExtensionCompletion(list, context);
break;
case "System.Windows.Markup.TypeExtension":
if (context.AttributeValue.ExtensionValue.PositionalArguments.Count <= 1) {
list.Items.AddRange(GetClassesFromContext(context).FlattenToList());
AttributeValue selItem = Utils.GetMarkupExtensionAtPosition(context.AttributeValue.ExtensionValue, context.ValueStartOffset)
.PositionalArguments.LastOrDefault();
string word = context.Editor.GetWordBeforeCaret().TrimEnd();
if (selItem != null && selItem.IsString && word == selItem.StringValue) {
list.PreselectionLength = selItem.StringValue.Length;
}
}
break;
default:
var ctors = type.GetMethods()
.Where(m => m.IsPublic && m.IsConstructor && m.Parameters.Count >= markup.PositionalArguments.Count + 1);
if (context.Forced)
return true;
if (ctors.Any() || markup.PositionalArguments.Count == 0)
return false;
break;
}
return true;
}