當前位置: 首頁>>代碼示例>>C#>>正文


C# TypeReference.GetMethods方法代碼示例

本文整理匯總了C#中Mono.Cecil.TypeReference.GetMethods方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeReference.GetMethods方法的具體用法?C# TypeReference.GetMethods怎麽用?C# TypeReference.GetMethods使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.TypeReference的用法示例。


在下文中一共展示了TypeReference.GetMethods方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CompareMethodAgainstTypeMethods

		internal void CompareMethodAgainstTypeMethods (MethodDefinition current, TypeReference targetType)
		{
			if (CheckedTypes.Contains (targetType.Name)) 
				return;
			
			foreach (MethodDefinition target in targetType.GetMethods ()) {
				if (target.IsGeneratedCode ())
					continue;

				Pattern duplicated = GetDuplicatedCode (current, target);
				if (duplicated != null && duplicated.Count > 0)
					rule.Runner.Report (current, duplicated[0], Severity.High, Confidence.Normal, String.Format ("Duplicated code with {0}", target));
			}
		}
開發者ID:nolanlum,項目名稱:mono-tools,代碼行數:14,代碼來源:CodeDuplicatedLocator.cs

示例2: DoesTypeStealthilyImplementInterface

		private static bool DoesTypeStealthilyImplementInterface (TypeDefinition type, TypeReference iface)
		{
			//ignore already uninteresting types below (self, enum, struct, static class)
			if (type == iface || type.IsEnum || type.IsValueType || type.IsStatic ())
				return false;

			//if type has less methods than the interface no need to check further
			if (!type.HasMethods)
				return false;
			IList<MethodDefinition> mdc = iface.GetMethods ().ToList ();
			if (type.Methods.Count < mdc.Count)
				return false;

			//type already publicly says it implements the interface
			if (type.Implements (iface.FullName))
				return false;

			foreach (MethodDefinition m in mdc) {
				//if any candidate fails we can return right away
				//since the interface will never be fully implemented
				MethodDefinition candidate = type.GetMethod (MethodAttributes.Public, m.Name);
				if (null == candidate || !candidate.IsPublic || candidate.IsStatic)
					return false;

				//ok interesting candidate! let's check if it matches the signature
				if (!AreSameElementTypes (m.ReturnType, candidate.ReturnType))
					return false;

				if (!CompareParameters (m, candidate))
					return false;
			}

			return true;
		}
開發者ID:nolanlum,項目名稱:mono-tools,代碼行數:34,代碼來源:ConsiderAddingInterfaceRule.cs

示例3: OnlyContainsExternalMethods

		private static bool OnlyContainsExternalMethods (TypeReference type)
		{
			bool has_methods = false;
			foreach (MethodDefinition method in type.GetMethods ()) {
				has_methods = true;
				if (!method.IsPInvokeImpl)
					return false;
			}
			// all methods are p/invoke
			return has_methods;
		}
開發者ID:nolanlum,項目名稱:mono-tools,代碼行數:11,代碼來源:AvoidLongParameterListsRule.cs

示例4: GetSmallestOverloaded

		//TODO: Perhaps we can perform this action with linq instead of
		//loop + hashtable
		private static IEnumerable<MethodDefinition> GetSmallestOverloaded (TypeReference type)
		{
			IDictionary<string, MethodDefinition> possibleOverloaded = new Dictionary<string, MethodDefinition> ();
			foreach (MethodDefinition method in type.GetMethods ()) {
				if (method.IsPInvokeImpl)
					continue;

				string name = method.Name;
				if (!possibleOverloaded.ContainsKey (name))
					possibleOverloaded.Add (name, method);
				else {
					MethodDefinition candidate = possibleOverloaded [name];
					int ccount = candidate.HasParameters ? candidate.Parameters.Count : 0;
					int mcount = method.HasParameters ? method.Parameters.Count : 0;
					if (ccount > mcount)
						possibleOverloaded [name] = method;
				}
			}
			return possibleOverloaded.Values;
		}
開發者ID:nolanlum,項目名稱:mono-tools,代碼行數:22,代碼來源:AvoidLongParameterListsRule.cs


注:本文中的Mono.Cecil.TypeReference.GetMethods方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。