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


C# ITypeResolveContext.GetClass方法代码示例

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


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

示例1: 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.GetClass(nameSpace, name, typeParameterCount, StringComparer.Ordinal) ?? SharedTypes.UnknownType;
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:43,代码来源:GetClassTypeReference.cs

示例2: 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.GetClass("System", "Nullable", 1, StringComparer.Ordinal);
			if (nullable != null)
				return new ParameterizedType(nullable, new [] { elementType });
			else
				return SharedTypes.UnknownType;
		}
开发者ID:JustasB,项目名称:cudafy,代码行数:16,代码来源:NullableType.cs

示例3: GetBaseTypes

		public IEnumerable<IType> GetBaseTypes(ITypeResolveContext context)
		{
			IType defaultBaseType = context.GetClass("System", HasValueTypeConstraint ? "ValueType" : "Object", 0, StringComparer.Ordinal);
			if (defaultBaseType != null)
				yield return defaultBaseType;
			
			foreach (ITypeReference constraint in this.Constraints) {
				yield return constraint.Resolve(context);
			}
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:10,代码来源:DefaultTypeParameter.cs

示例4: GetMethods

		public IEnumerable<IMethod> GetMethods(ITypeResolveContext context, Predicate<IMethod> filter = null)
		{
			// TODO: get methods from constraints
			IType objectType = context.GetClass("System", "Object", 0, StringComparer.Ordinal);
			IEnumerable<IMethod> objectMethods;
			if (objectType != null)
				objectMethods = objectType.GetMethods(context, filter);
			else
				objectMethods = EmptyList<IMethod>.Instance;
			
			// don't return static methods (those cannot be called from type parameter)
			return objectMethods.Where(m => !m.IsStatic);
		}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:13,代码来源:DefaultTypeParameter.cs


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