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