当前位置: 首页>>代码示例>>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;未经允许,请勿转载。