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


C# ITypeResolveContext.GetTypeDefinition方法代码示例

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


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

示例1: Create

		/// <summary>
		/// Creates a nullable type.
		/// </summary>
		public static IType Create(IType elementType, ITypeResolveContext context)
		{
			if (elementType == null)
				throw new ArgumentNullException("elementType");
			if (context == null)
				throw new ArgumentNullException("context");
			
			ITypeDefinition nullable = context.GetTypeDefinition("System", "Nullable", 1, StringComparer.Ordinal);
			if (nullable != null)
				return new ParameterizedType(nullable, new [] { elementType });
			else
				return SharedTypes.UnknownType;
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:16,代码来源:NullableType.cs

示例2: Resolve

		public IType Resolve(ITypeResolveContext context)
		{
			// If both types exist, C# considers that to be an ambiguity, but we are less strict.
			IType type = withoutSuffix.Resolve(context);
			var attrType = context.GetTypeDefinition (typeof(System.Attribute));
			if (attrType == null)
				return SharedTypes.UnknownType;
			
			if (type == SharedTypes.UnknownType || !(type.GetDefinition () != null && type.GetDefinition ().IsDerivedFrom (attrType, context)))
				type =  withSuffix.Resolve(context);
			
			return type;
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:13,代码来源:CSharpAttribute.cs

示例3: CachedResult

		/*
		sealed class CachedResult
		{
			public readonly CacheManager CacheManager;
			public readonly IType Result;
			
			public CachedResult(CacheManager cacheManager, IType result)
			{
				this.CacheManager = cacheManager;
				this.Result = result;
			}
		}
		 */
		
		public IType Resolve(ITypeResolveContext context)
		{
			if (context == null)
				throw new ArgumentNullException("context");
			
			/*  TODO PERF: caching disabled until we measure how much of an advantage it is
			 * (and whether other approaches like caching only the last N resolve calls in a thread-static cache would work better)
			 * Maybe even make a distinction between the really common type references (e.g. primitiveTypeReferences) and
			 * normal GetClassTypeReferences?
			CacheManager cacheManager = context.CacheManager;
			if (cacheManager != null) {
				CachedResult result = this.v_cachedResult;
				if (result != null && result.CacheManager == cacheManager)
					return result.Result;
				IType newResult = DoResolve(context);
				this.v_cachedResult = new CachedResult(cacheManager, newResult);
				cacheManager.Disposed += delegate { v_cachedResult = null; }; // maybe optimize this to use interface call instead of delegate?
				return newResult;
			} else {
				return DoResolve(context);
			}
			
		}
		
		IType DoResolve(ITypeResolveContext context)
		{
			 */
			return context.GetTypeDefinition(nameSpace, name, typeParameterCount, StringComparer.Ordinal) ?? SharedTypes.UnknownType;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:43,代码来源:GetClassTypeReference.cs

示例4: CachedResult

		/*
		sealed class CachedResult
		{
			public readonly CacheManager CacheManager;
			public readonly IType Result;
			
			public CachedResult(CacheManager cacheManager, IType result)
			{
				this.CacheManager = cacheManager;
				this.Result = result;
			}
		}
		 */
		
		public IType Resolve(ITypeResolveContext context)
		{
			if (context == null)
				throw new ArgumentNullException("context");
			
//			CacheManager cache = context.CacheManager;
//			if (cache != null) {
//				IType cachedType = cache.GetShared(this) as IType;
//				if (cachedType != null)
//					return cachedType;
//			}
			
			IType type = context.GetTypeDefinition(nameSpace, name, typeParameterCount, StringComparer.Ordinal) ?? SharedTypes.UnknownType;
//			if (cache != null)
//				cache.SetShared(this, type);
			return type;
		}
开发者ID:sbeparey,项目名称:ILSpy,代码行数:31,代码来源:GetClassTypeReference.cs

示例5: GetBaseTypes

		public IEnumerable<IType> GetBaseTypes(ITypeResolveContext context)
		{
			bool hasNonInterfaceConstraint = false;
			foreach (ITypeReference constraint in this.Constraints) {
				IType c = constraint.Resolve(context);
				yield return c;
				ITypeDefinition cdef = c.GetDefinition();
				if (!(cdef != null && cdef.ClassType == ClassType.Interface))
					hasNonInterfaceConstraint = true;
			}
			// Do not add the 'System.Object' constraint if there is another constraint with a base class.
			if (HasValueTypeConstraint || !hasNonInterfaceConstraint) {
				IType defaultBaseType = context.GetTypeDefinition("System", HasValueTypeConstraint ? "ValueType" : "Object", 0, StringComparer.Ordinal);
				if (defaultBaseType != null)
					yield return defaultBaseType;
			}
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:17,代码来源:DefaultTypeParameter.cs

示例6: GetNonCircularBaseTypes

		// Problem with type parameter resolving - circular declarations
		//   void Example<S, T> (S s, T t) where S : T where T : S
		IEnumerable<IType> GetNonCircularBaseTypes(ITypeResolveContext context)
		{
			var result = this.GetBaseTypes(context).Where(bt => !IsCircular (context, bt));
			if (result.Any ())
				return result;
			
			// result may be empty, GetBaseTypes doesn't return object/struct when there are only constraints (even circular) as base types are available,
			// but even when there are only circular references the default base type should be included.
			IType defaultBaseType = context.GetTypeDefinition("System", HasValueTypeConstraint ? "ValueType" : "Object", 0, StringComparer.Ordinal);
			if (defaultBaseType != null)
				return new [] { defaultBaseType };
			return Enumerable.Empty<IType> ();
		}
开发者ID:95ulisse,项目名称:ILEdit,代码行数:15,代码来源:DefaultTypeParameter.cs


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