當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。