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


C# TypeReference.IsNamed方法代码示例

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


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

示例1: IsGenericType

		static bool IsGenericType (TypeReference type, string nspace, string name)
		{
			if (type.IsNamed (nspace, name))
				return true;

			var type_spec = type as TypeSpecification;
			if (type_spec != null && type_spec.ElementType.IsNamed (nspace, name))
				return true;

			// handle things like ICollection<T>
			GenericInstanceType git = (type as GenericInstanceType);
			if (git == null)
				return false;

			return FindGenericType (git, nspace, name);
		}
开发者ID:remobjects,项目名称:mono-tools,代码行数:16,代码来源:AvoidMethodWithUnusedGenericTypeRule.cs

示例2: IsPrefered

		protected override bool IsPrefered (TypeReference type)
		{
			return type.IsNamed ("System", "StringComparison");
		}
开发者ID:alfredodev,项目名称:mono-tools,代码行数:4,代码来源:PreferStringComparisonOverrideRule.cs

示例3: IsSpecificXmlType

		static bool IsSpecificXmlType (TypeReference type)
		{
			if (type.Namespace == "System.Xml") {
				string name = type.Name;
				return ((name == "XmlDocument") || (name == "XmlNode"));
			}
			return type.IsNamed ("System.Xml.XPath", "XPathDocument");
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:8,代码来源:PreferXmlAbstractionsRule.cs

示例4: AreSameElementTypes

 private static bool AreSameElementTypes(TypeReference a, TypeReference b)
 {
     return a.IsGenericParameter || b.IsGenericParameter || b.IsNamed(a.Namespace, a.Name);
 }
开发者ID:mdabbagh88,项目名称:arrayslice,代码行数:4,代码来源:MethodRocks.cs

示例5: CheckGenericDelegate

		private bool CheckGenericDelegate (TypeReference type)
		{
			if (type.IsNamed ("System", "EventHandler`1"))
				return true;

			Runner.Report (type, Severity.Medium, Confidence.High, "Generic delegates should use EventHandler<TEventArgs>");
			return false;
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:8,代码来源:DeclareEventHandlersCorrectlyRule.cs

示例6: IsIgnoredSuggestionType

 private static bool IsIgnoredSuggestionType(TypeReference type)
 {
     return (type.IsNamed ("System", "Object") || IsFromNonGenericCollectionNamespace (type.Namespace));
 }
开发者ID:alfredodev,项目名称:mono-tools,代码行数:4,代码来源:AvoidUnnecessarySpecializationRule.cs

示例7: IsPrefered

		protected override bool IsPrefered (TypeReference type)
		{
			return (type.IsNamed ("System", "IFormatProvider") || type.IsNamed ("System.Globalization", "CultureInfo"));
		}
开发者ID:FreeBSD-DotNet,项目名称:mono-tools,代码行数:4,代码来源:PreferIFormatProviderOverrideRule.cs

示例8: Match

		private static bool Match (TypeReference type, string nameSpace, string name)
		{
			int np = name.IndexOf ('/');
			if (np == -1) {
				if (type.IsNamed (nameSpace, name))
					return true;
			} else if (type.IsNested) {
				string tname = type.Name;
				TypeReference dt = type.DeclaringType;
				if ((nameSpace == dt.Namespace) &&
					(String.CompareOrdinal (name, 0, dt.Name, 0, np) == 0) &&
					(String.CompareOrdinal (name, np + 1, tname, 0, tname.Length) == 0))
					return true;
			}
			return false;
		}
开发者ID:remobjects,项目名称:mono-tools,代码行数:16,代码来源:TypeRocks.cs

示例9: CheckMethod

		public override RuleResult CheckMethod (MethodDefinition method)
		{
			if (!method.HasBody)
				return RuleResult.DoesNotApply;

			//the rule does not apply to the particular case of ToString()
			//that have its own ToStringShouldNotReturnNullRule
			if (!method.HasParameters && method.Name == "ToString")
				return RuleResult.DoesNotApply;

			//only apply to methods returning string, array, or IEnumerable-impl
			return_type = method.ReturnType;
			string_return_type = return_type.IsNamed ("System", "String");
			array_return_type = return_type.IsArray;
			ienumerable_return_type = return_type.Implements ("System.Collections", "IEnumerable");

			if (!string_return_type && !array_return_type && !ienumerable_return_type)
				return RuleResult.DoesNotApply;

			return base.CheckMethod (method);
		}
开发者ID:col42dev,项目名称:mono-tools,代码行数:21,代码来源:PreferEmptyInstanceOverNullRule.cs


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