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


C# TypeDefinition.IsStatic方法代码示例

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


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

示例1: CanInstantiateType

		static bool CanInstantiateType (TypeDefinition type)
		{
			// type is static (>= 2.0)
			if (type.IsStatic ())
				return false;

			if (type.IsSealed && type.HasMethods) {
				foreach (MethodDefinition ctor in type.Methods) {
					if (ctor.IsConstructor && ctor.IsVisible ())
						return true;
				}
				return false;
			}
			return true;
		}
开发者ID:col42dev,项目名称:mono-tools,代码行数:15,代码来源:CentralizePInvokesIntoNativeMethodsTypeRule.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: CheckType

		public RuleResult CheckType (TypeDefinition type)
		{
			// rule applies only if the type isn't: an enum, an interface, a struct, a delegate or compiler generated
			if (type.IsEnum || type.IsInterface || type.IsValueType || type.IsDelegate () || type.IsGeneratedCode ())
				return RuleResult.DoesNotApply;

			// it also does not apply if the type is static (2.0+ only)
			if (type.IsStatic ())
				return RuleResult.DoesNotApply;

			if (!IsAllStatic (type))
				return RuleResult.Success;

			// rule applies!

			foreach (MethodDefinition ctor in type.Methods) {
				if (ctor.IsConstructor && !ctor.IsStatic && ctor.IsVisible ()) {
					Runner.Report (ctor, Severity.Low, Confidence.High);
				}
			}

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

示例4: DoesTypeStealthilyImplementInterface

		private static bool DoesTypeStealthilyImplementInterface (TypeDefinition type, TypeDefinition 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.Methods;
			if (type.Methods.Count < mdc.Count)
				return false;

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

			foreach (MethodDefinition m in mdc) {
				// FIXME: ignore methods with generic constraints
				if (HasConstraints (m))
					return false;

				//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 (!m.CompareSignature (candidate))
					return false;
				// FIXME: ignore methods with generic constraints
				if (HasConstraints (candidate))
					return false;
			}

			if (iface.HasInterfaces) {
				foreach (TypeReference tr in iface.Interfaces) {
					TypeDefinition td = tr.Resolve ();
					if (td == null)
						continue;
					if (!DoesTypeStealthilyImplementInterface (type, td))
						return false;
				}
			}
			return true;
		}
开发者ID:alfredodev,项目名称:mono-tools,代码行数:47,代码来源:ConsiderAddingInterfaceRule.cs

示例5: CheckType

		public RuleResult CheckType (TypeDefinition type)
		{
			// rule applies only if the type isn't: an enum, an interface, a struct, a delegate or compiler generated
			if (type.IsEnum || type.IsInterface || type.IsValueType || !type.HasFields && GetMethodCount (type) == 0
				|| type.IsDelegate () || type.IsGeneratedCode () 
				|| type.BaseType != null && type.BaseType.FullName != "System.Object")
				return RuleResult.DoesNotApply;
			
			// success if the type is already static
			if (type.IsStatic ())
				return RuleResult.Success;
			
			if (IsAllStatic (type)) {
				// no technical reason not to use a static type exists
				Runner.Report (type, Severity.Medium, Confidence.High);
			}
			return Runner.CurrentRuleResult;
		}
开发者ID:boothead,项目名称:mono-tools,代码行数:18,代码来源:ConsiderUsingStaticTypeRule.cs

示例6: CheckType

		public RuleResult CheckType (TypeDefinition type)
		{
			// rule applies only if the type isn't: an enum, an interface, a struct, a delegate or compiler generated
			if (type.IsEnum || type.IsInterface || type.IsValueType || type.IsDelegate () || type.IsGeneratedCode () 
				|| type.BaseType != null && !type.BaseType.IsNamed ("System", "Object"))
				return RuleResult.DoesNotApply;
			
			// success if the type is already static or, before 2.0, is it's sealed
			if ((type.Module.Runtime >= TargetRuntime.Net_2_0) ? type.IsStatic () : type.IsSealed)
				return RuleResult.Success;
			
			if (IsAllStatic (type)) {
				// no technical reason not to use a static type exists
				Runner.Report (type, Severity.Medium, Confidence.High);
			}
			return Runner.CurrentRuleResult;
		}
开发者ID:col42dev,项目名称:mono-tools,代码行数:17,代码来源:ConsiderUsingStaticTypeRule.cs


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