当前位置: 首页>>代码示例>>C#>>正文


C# TypeReference.GetMethod方法代码示例

本文整理汇总了C#中Mono.Cecil.TypeReference.GetMethod方法的典型用法代码示例。如果您正苦于以下问题:C# TypeReference.GetMethod方法的具体用法?C# TypeReference.GetMethod怎么用?C# TypeReference.GetMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mono.Cecil.TypeReference的用法示例。


在下文中一共展示了TypeReference.GetMethod方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckDelegate

		private bool CheckDelegate (TypeReference type)
		{
			MethodReference invoke = type.GetMethod (MethodSignatures.Invoke);
			if (invoke == null)
				return false;

			// we cannot short-circuit since we would miss reporting some defects
			bool valid = CheckReturnVoid (type, invoke);
			valid &= CheckAmountOfParameters (type, invoke);
			valid &= CheckParameterTypes (type, invoke);

			IList<ParameterDefinition> pdc = invoke.Parameters;
			if (pdc.Count > 0) {
				valid &= CheckParameterName (type, pdc [0], "sender");
				if (pdc.Count > 1)
					valid &= CheckParameterName (type, pdc [1], "e");
			}
			return valid;
		}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:19,代码来源:DeclareEventHandlersCorrectlyRule.cs

示例2: CheckCallingBaseMethod

        private void CheckCallingBaseMethod(TypeReference type, MethodSignature methodSignature)
        {
            MethodDefinition method = type.GetMethod (methodSignature);
            if (method == null)
                return; // Perhaps should report that doesn't exist the method (only with ctor).

            // is there any Call or Callvirt instructions in the method
            if (OpCodeBitmask.Calls.Intersect (OpCodeEngine.GetBitmask (method))) {
                // in this case we check further
                foreach (Instruction instruction in method.Body.Instructions) {
                    if (instruction.OpCode.FlowControl != FlowControl.Call)
                        continue;

                    MethodReference operand = (MethodReference) instruction.Operand;
                    TypeReference tr = operand.DeclaringType;
                    if (methodSignature.Matches (operand) && type.Inherits (tr.Namespace, tr.Name))
                        return;
                }
            }

            Runner.Report (method, Severity.High, Confidence.High);
        }
开发者ID:alfredodev,项目名称:mono-tools,代码行数:22,代码来源:CallBaseMethodsOnISerializableTypesRule.cs

示例3: DoesAllSignaturesMatchType

		private static bool DoesAllSignaturesMatchType (TypeReference type, IEnumerable<MethodSignature> signatures)
		{
			bool match = true;
			foreach (MethodSignature signature in signatures) {
				match &= (null != type.GetMethod (signature));
			}
			return match;
		}
开发者ID:boothead,项目名称:mono-tools,代码行数:8,代码来源:AvoidUnnecessarySpecializationRule.cs

示例4: GetMethods

		private void GetMethods (TypeReference type)	
		{
			string full_name = type.GetFullName ();
			args1 [0] = full_name;
			AddMethod (type.GetMethod (MethodSignatures.Equals));
			AddMethod (type.GetMethod ("Equals", "System.Boolean", args1));

			AddMethod (type.GetMethod ("CompareTo", "System.Int32", args1));	// generic version
			AddMethod (type.GetMethod (CompareTo));								// non-generic version

			// Note that we don't want to use MethodSignatures for these 
			// because we don't want any weird overloads.
			args2 [0] = full_name;
			args2 [1] = full_name;
			AddMethod (type.GetMethod ("op_Equality", "System.Boolean", args2));	
			AddMethod (type.GetMethod ("op_Inequality", "System.Boolean", args2));

			AddMethod (type.GetMethod ("op_LessThan", "System.Boolean", args2));
			AddMethod (type.GetMethod ("op_LessThanOrEqual", "System.Boolean", args2));
			AddMethod (type.GetMethod ("op_GreaterThan", "System.Boolean", args2));
			AddMethod (type.GetMethod ("op_GreaterThanOrEqual", "System.Boolean", args2));
			
			clone.Method = type.GetMethod (MethodSignatures.Clone);
			hash.Method = type.GetMethod (MethodSignatures.GetHashCode);
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:25,代码来源:ReviewInconsistentIdentityRule.cs

示例5: CheckDelegate

		private RuleResult CheckDelegate (TypeReference type)
		{
			MethodDefinition method = type.GetMethod ("Invoke");
			// MulticastDelegate inherits from Delegate without overriding Invoke
			if ((method != null) && HasMoreParametersThanAllowed (method))
				Runner.Report (type, Severity.Medium, Confidence.Normal, "This delegate contains a long parameter list.");
			return Runner.CurrentRuleResult;
		}
开发者ID:boothead,项目名称:mono-tools,代码行数:8,代码来源:AvoidLongParameterListsRule.cs

示例6: CheckOperatorPair

		private void CheckOperatorPair (KeyValuePair<MethodSignature, MethodSignature> pair, 
			TypeReference type, Severity severity)
		{
			MethodDefinition op = type.GetMethod (pair.Key);
			if (op == null) { //first one not defined
				pair = new KeyValuePair<MethodSignature, MethodSignature> (pair.Value, pair.Key); //reverse
				op = type.GetMethod (pair.Key);
				if (op == null)
					return; //neither one is defined
			} else {
				if (type.HasMethod (pair.Value))
					return; //both are defined
			}

			string s = string.Format (CultureInfo.InvariantCulture, Message, pair.Key.Name, pair.Value.Name);
			Runner.Report (op, severity, Confidence.Total, s);
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:17,代码来源:EnsureSymmetryForOverloadedOperatorsRule.cs

示例7: GetNonAbstractMethod

		private static MethodDefinition GetNonAbstractMethod (TypeReference type, MethodSignature signature)
		{
			MethodDefinition method = type.GetMethod (signature);
			if ((method == null) || method.IsAbstract)
				return null;
			return method;
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:7,代码来源:DisposableFieldsShouldBeDisposedRule.cs


注:本文中的Mono.Cecil.TypeReference.GetMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。