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


C# TypeDefinition.Inherits方法代码示例

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


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

示例1: ProcessType

        public override void ProcessType(TypeDefinition type)
        {
            if (!type.Inherits ("Android.App.Application"))
                return;

            ProcessAttributeProvider (type);
        }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:7,代码来源:PreserveApplications.cs

示例2: CheckCallingBaseMethod

		private void CheckCallingBaseMethod (TypeDefinition type, MethodSignature methodSignature)
		{
			MethodDefinition method = type.GetMethod (methodSignature);
			if (method == null)
				return; // Perhaps should report that doesn't exist the method (only with ctor).

			foreach (Instruction instruction in method.Body.Instructions) {
				if (instruction.OpCode.FlowControl == FlowControl.Call) {
					MethodReference operand = (MethodReference) instruction.Operand;
					if (methodSignature.Matches (operand) && type.Inherits (operand.DeclaringType.ToString ()))
						return;
				}
			}

			Runner.Report (method, Severity.High, Confidence.High, String.Format ("The method {0} isn't calling its base method.", method));
		}
开发者ID:TheRealDuckboy,项目名称:mono-soc-2008,代码行数:16,代码来源:CallBaseMethodsOnISerializableTypesRule.cs

示例3: IsImplementor

 static bool IsImplementor(TypeDefinition type)
 {
     return type.Name.EndsWith ("Implementor") && type.Inherits ("Java.Lang.Object");
 }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:4,代码来源:MarkJavaObjects.cs

示例4: IsTypeConverter

 static bool IsTypeConverter(TypeDefinition type)
 {
     return type.Inherits ("System.ComponentModel", "TypeConverter");
 }
开发者ID:yudhitech,项目名称:xamarin-android,代码行数:4,代码来源:PreserveTypeConverters.cs

示例5: IsWebServiceClient

		static bool IsWebServiceClient (TypeDefinition type)
		{
			return type.Inherits ("System.Web.Services.Protocols", "SoapHttpClientProtocol");
		}
开发者ID:Zman0169,项目名称:mono,代码行数:4,代码来源:PreserveSoapHttpClients.cs

示例6: CheckType

        public RuleResult CheckType(TypeDefinition type)
        {
            if (type.IsEnum || type.IsInterface || !type.HasFields)
                return RuleResult.DoesNotApply;

            Log.WriteLine (this);
            Log.WriteLine (this, "----------------------------------");

            bool isWinFormControl = usesWinForms && type.Inherits ("System.Windows.Forms", "Control");

            // All fields start out as always null and unused.
            foreach (FieldDefinition field in type.Fields) {
                if (field.IsPrivate && !field.FieldType.IsValueType)
                    if (!isWinFormControl || field.Name != "components")	// the winforms designer seems to like to leave this null
                        nullFields.Add (field);
            }

            CheckMethods (type);
            if (type.HasNestedTypes) {
                foreach (TypeDefinition nested in type.NestedTypes)
                    CheckMethods (nested);
            }

            // Report a defect if:
            // 1) The field is explicitly set to null and not used (if
            // if is implicitly set to null and not used AvoidUnusedPrivateFieldsRule
            // will catch it).
            setFields.IntersectWith (nullFields);
            setFields.ExceptWith (usedFields);
            if (setFields.Count > 0) {
                foreach (FieldDefinition field in setFields) {
                    Log.WriteLine (this, "{0} is always null", field.Name);
                    Runner.Report (field, Severity.Medium, Confidence.High);
                }
            }

            // 2) The field is always null and used somewhere.
            nullFields.IntersectWith (usedFields);
            if (nullFields.Count > 0) {
                foreach (FieldDefinition field in nullFields) {
                    Log.WriteLine (this, "{0} is always null", field.Name);
                    Runner.Report (field, Severity.Medium, Confidence.High);
                }
            }

            nullFields.Clear ();
            setFields.Clear ();
            usedFields.Clear ();

            return Runner.CurrentRuleResult;
        }
开发者ID:alfredodev,项目名称:mono-tools,代码行数:51,代码来源:AvoidAlwaysNullFieldRule.cs

示例7: CheckType

		public RuleResult CheckType (TypeDefinition type)
		{
			// rule apply only to type that inherits from System.Exception
			if (!type.Inherits (Exception))
				return RuleResult.DoesNotApply;

			// rule applies, only Success or Failure from the point on

			// check if the type implements all the needed exception constructors

			bool empty_ctor = false;		// MyException ()
			bool string_ctor = false;		// MyException (string message)
			bool inner_exception_ctor = false;	// MyException (string message, Exception innerException)
			bool serialization_ctor = false;	// MyException (SerializationInfo info, StreamingContext context)

			foreach (MethodDefinition ctor in type.GetConstructors ()) {
				// skip cctor
				if (ctor.IsStatic)
					continue;

				if (!ctor.HasParameters) {
					// there can be only one so only it's visibility matters
					empty_ctor = ctor.IsPublic;
					continue;
				}

				switch (ctor.Parameters.Count) {
				case 1:
					string_ctor |= CheckForStringConstructor (ctor);
					break;
				case 2:
					if (ctor.IsPublic) {
						if (!inner_exception_ctor) {
							inner_exception_ctor = CheckForInnerExceptionConstructor (ctor);
							if (inner_exception_ctor)
								break;
						}

						string_ctor |= CheckForStringConstructor (ctor);
					} else {
						serialization_ctor |= CheckForSerializationConstructor (ctor);
					}
					break;
				default:
					inner_exception_ctor |= CheckForInnerExceptionConstructor (ctor);
					break;
				}
			}

			if (!empty_ctor) {
				string s = String.Format (MissingConstructor, "public", type.Name, "()");
				Runner.Report (type, Severity.High, Confidence.Total, s);
			}
			if (!string_ctor) {
				string s = String.Format (MissingConstructor, "public", type.Name, "(string message)");
				Runner.Report (type, Severity.High, Confidence.Total, s);
			}
			if (!inner_exception_ctor) {
				string s = String.Format (MissingConstructor, "public", type.Name,
					"(string message, Exception innerException)");
				Runner.Report (type, Severity.High, Confidence.Total, s);
			}
			if (!serialization_ctor) {
				string s = String.Format (MissingConstructor, (type.IsSealed) ? "private" : "protected",
					type.Name, "(SerializationInfo info, StreamingContext context)");
				Runner.Report (type, Severity.High, Confidence.Total, s);
			}

			return Runner.CurrentRuleResult;
		}
开发者ID:nolanlum,项目名称:mono-tools,代码行数:70,代码来源:MissingExceptionConstructorsRule.cs

示例8: CheckType

		public RuleResult CheckType (TypeDefinition type)
		{
			if (!type.IsClass || !type.HasMethods || !type.Inherits ("System.Windows.FrameworkElement"))
				return RuleResult.DoesNotApply;
			var arrangeOverride = type.GetMethod (arrangeSignature);
			var measureOverride = type.GetMethod (measureSignature);
			// The class doesn't have either method.
			if (arrangeOverride == null && measureOverride == null)
				return RuleResult.DoesNotApply;
			// Only ArrangeOverride provided.
			if (arrangeOverride != null && measureOverride == null)
				Runner.Report (arrangeOverride, Severity.High, Confidence.Total);
			// Only MeasureOverride provided.
			if (measureOverride != null && arrangeOverride == null)
				Runner.Report (measureOverride, Severity.High, Confidence.Total);

			return Runner.CurrentRuleResult;
		}
开发者ID:boothead,项目名称:mono-tools,代码行数:18,代码来源:AddMatchingArrangeMeasureOverrideRule.cs


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