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


C# IType.GetDefinition方法代码示例

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


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

示例1: GetShortType

		protected string GetShortType (IType type)
		{
			if (builder == null) {
				var ctx = ext.CSharpParsedFile.GetTypeResolveContext (type.GetDefinition () == null ? ext.Document.Compilation : type.GetDefinition ().Compilation, ext.Document.Editor.Caret.Location) as CSharpTypeResolveContext;
				var state = new CSharpResolver (ctx);
				builder = new TypeSystemAstBuilder (state);
				var dt = state.CurrentTypeDefinition;
				var declaring = ctx.CurrentTypeDefinition != null ? ctx.CurrentTypeDefinition.DeclaringTypeDefinition : null;
				if (declaring != null) {
					while (dt != null) {
						if (dt.Equals (declaring)) {
							builder.AlwaysUseShortTypeNames = true;
							break;
						}
						dt = dt.DeclaringTypeDefinition;
					}
				}
			}
			try {
				return GLib.Markup.EscapeText (builder.ConvertType(type).GetText (ext.FormattingPolicy.CreateOptions ()));
			} catch (Exception e) {
				LoggingService.LogError ("Exception while getting short type.", e);
				return "";
			}
		}
开发者ID:vac0,项目名称:monodevelop,代码行数:25,代码来源:AbstractParameterDataProvider.cs

示例2: GetScriptType

		private JsExpression GetScriptType(IType type, TypeContext typeContext, IRuntimeContext context) {
			if (type.Kind == TypeKind.Delegate) {
				return CreateTypeReferenceExpression(KnownTypeReference.Delegate);
			}
			else if (type is ParameterizedType) {
				var pt = (ParameterizedType)type;
				var def = pt.GetDefinition();
				var sem = _metadataImporter.GetTypeSemantics(def);
				if (sem.Type == TypeScriptSemantics.ImplType.NormalType && !sem.IgnoreGenericArguments)
					return JsExpression.Invocation(JsExpression.Member(CreateTypeReferenceExpression(_systemScript), "makeGenericType"), CreateTypeReferenceExpression(type.GetDefinition()), JsExpression.ArrayLiteral(pt.TypeArguments.Select(a => GetScriptType(a, TypeContext.GenericArgument, context))));
				else
					return GetTypeDefinitionScriptType(type.GetDefinition(), typeContext);
			}
			else if (type.TypeParameterCount > 0) {
				// This handles open generic types ( typeof(C<,>) )
				return CreateTypeReferenceExpression(type.GetDefinition());
			}
			else if (type.Kind == TypeKind.Array) {
				return CreateTypeReferenceExpression(KnownTypeReference.Array);
			}
			else if (type is ITypeParameter) {
				return context.ResolveTypeParameter((ITypeParameter)type);
			}
			else if (type is ITypeDefinition) {
				return GetTypeDefinitionScriptType((ITypeDefinition)type, typeContext);
			}
			else if (type.Kind == TypeKind.Anonymous || type.Kind == TypeKind.Null || type.Kind == TypeKind.Dynamic) {
				return CreateTypeReferenceExpression(KnownTypeReference.Object);
			}
			else {
				throw new InvalidOperationException("Could not determine the script type for " + type + ", context " + typeContext);
			}
		}
开发者ID:pdavis68,项目名称:SaltarelleCompiler,代码行数:33,代码来源:RuntimeLibrary.cs

示例3: PreferAttributeTypeWithSuffix

		internal static bool PreferAttributeTypeWithSuffix(IType t1, IType t2, ICompilation compilation)
		{
			if (t2.Kind == TypeKind.Unknown) return false;
			if (t1.Kind == TypeKind.Unknown) return true;
			
			var attrTypeDef = compilation.FindType(KnownTypeCode.Attribute).GetDefinition();
			if (attrTypeDef != null) {
				bool t1IsAttribute = (t1.GetDefinition() != null && t1.GetDefinition().IsDerivedFrom(attrTypeDef));
				bool t2IsAttribute = (t2.GetDefinition() != null && t2.GetDefinition().IsDerivedFrom(attrTypeDef));
				if (t2IsAttribute && !t1IsAttribute)
					return true;
				// If both types exist and are attributes, C# considers that to be an ambiguity, but we are less strict.
			}
			return false;
		}
开发者ID:sphynx79,项目名称:dotfiles,代码行数:15,代码来源:AttributeTypeReference.cs

示例4: InternalIsValid

		internal static bool InternalIsValid (RefactoringOptions options, out IType interfaceType)
		{
			var unit = options.Document.ParsedDocument.GetAst<CompilationUnit> ();
			interfaceType = null;
			if (unit == null)
				return false;
			var loc = options.Document.Editor.Caret.Location;
			var declaration = unit.GetNodeAt<TypeDeclaration> (loc.Line, loc.Column);
			if (declaration == null)
				return false;
			if (!declaration.BaseTypes.Any (bt => bt.Contains (loc.Line, loc.Column)))
				return false;
			if (options.ResolveResult == null)
				return false;
			interfaceType = options.ResolveResult.Type;
			var def = interfaceType.GetDefinition ();
			if (def == null)
				return false;
			if (def.Kind != TypeKind.Interface)
				return false;
			
			var declaringType = options.Document.ParsedDocument.GetInnermostTypeDefinition (loc);
			var type = declaringType.Resolve (options.Document.ParsedDocument.ParsedFile.GetTypeResolveContext (options.Document.Compilation, loc)).GetDefinition ();
			return interfaceType.GetAllBaseTypes ().Any (bt => CodeGenerator.CollectMembersToImplement (type, bt, false).Any ());
		}
开发者ID:head-thrash,项目名称:monodevelop,代码行数:25,代码来源:ImplementExplicit.cs

示例5: GetParsedType

        internal SDType GetParsedType(IType type, bool isProjectStranger = true)
        {
            var parsedType = _repository.GetTypeByIdentifier(type.GetIdentifier());
            if (parsedType == null)
            {
                parsedType = type.GetDefinition() != null ? CreateSDType(type, type.GetDefinition(), isProjectStranger) : CreateSDType(type, isProjectStranger);
                ParseForeignTypeToModel(parsedType, type);
            }

            if (!isProjectStranger)
            {
                ParseTypeToModel(parsedType, type);
            }

            return parsedType;
        }
开发者ID:JoeHosman,项目名称:sharpDox,代码行数:16,代码来源:TypeParser.cs

示例6: GetNestedTypesImpl

		static IEnumerable<IType> GetNestedTypesImpl(IType outerType, IList<IType> nestedTypeArguments, Predicate<ITypeDefinition> filter, GetMemberOptions options)
		{
			ITypeDefinition outerTypeDef = outerType.GetDefinition();
			if (outerTypeDef == null)
				yield break;
			
			int outerTypeParameterCount = outerTypeDef.TypeParameterCount;
			ParameterizedType pt = outerType as ParameterizedType;
			foreach (ITypeDefinition nestedType in outerTypeDef.NestedTypes) {
				int totalTypeParameterCount = nestedType.TypeParameterCount;
				if (nestedTypeArguments != null) {
					if (totalTypeParameterCount - outerTypeParameterCount != nestedTypeArguments.Count)
						continue;
				}
				if (!(filter == null || filter(nestedType)))
					continue;
				
				if (totalTypeParameterCount == 0 || (options & GetMemberOptions.ReturnMemberDefinitions) == GetMemberOptions.ReturnMemberDefinitions) {
					yield return nestedType;
				} else {
					// We need to parameterize the nested type
					IType[] newTypeArguments = new IType[totalTypeParameterCount];
					for (int i = 0; i < outerTypeParameterCount; i++) {
						newTypeArguments[i] = pt != null ? pt.GetTypeArgument(i) : outerTypeDef.TypeParameters[i];
					}
					for (int i = outerTypeParameterCount; i < totalTypeParameterCount; i++) {
						if (nestedTypeArguments != null)
							newTypeArguments[i] = nestedTypeArguments[i - outerTypeParameterCount];
						else
							newTypeArguments[i] = SpecialType.UnboundTypeArgument;
					}
					yield return new ParameterizedType(nestedType, newTypeArguments);
				}
			}
		}
开发者ID:adisik,项目名称:simple-assembly-explorer,代码行数:35,代码来源:GetMembersHelper.cs

示例7: CreateTooltip

		public static FlowDocument CreateTooltip(IType type, bool useFullyQualifiedMemberNames = true)
		{
			var ambience = AmbienceService.GetCurrentAmbience();
			ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.ShowDeclaringType;
			if (useFullyQualifiedMemberNames)
				ambience.ConversionFlags |= ConversionFlags.UseFullyQualifiedMemberNames;
			string header;
			if (type is ITypeDefinition)
				header = ambience.ConvertEntity((ITypeDefinition)type);
			else
				header = ambience.ConvertType(type);
			
			ambience.ConversionFlags = ConversionFlags.ShowTypeParameterList;
			DocumentationUIBuilder b = new DocumentationUIBuilder(ambience);
			b.AddCodeBlock(header, keepLargeMargin: true);
			
			ITypeDefinition entity = type.GetDefinition();
			if (entity != null) {
				var documentation = XmlDocumentationElement.Get(entity);
				if (documentation != null) {
					foreach (var child in documentation.Children) {
						b.AddDocumentationElement(child);
					}
				}
			}
			return b.CreateFlowDocument();
		}
开发者ID:ratoy,项目名称:SharpDevelop,代码行数:27,代码来源:XmlDocFormatter.cs

示例8: TypeCompletionData

		public TypeCompletionData(IType type) : base(type.Name)
		{
			this.type = type;
			ITypeDefinition typeDef = type.GetDefinition();
			if (typeDef != null)
				this.Description = typeDef.Documentation;
			this.Image = ClassBrowserIconService.GetIcon(type);
		}
开发者ID:RHE24,项目名称:SharpDevelop,代码行数:8,代码来源:TypeCompletionData.cs

示例9: Create

		internal static CodeType Create(CodeModelContext context, IType type)
		{
			ITypeDefinition typeDefinition = type.GetDefinition();
			if (typeDefinition != null) {
				return Create(context.WithFilteredFileName(null), typeDefinition, type.TypeArguments.ToArray());
			}
			return null;
		}
开发者ID:fanyjie,项目名称:SharpDevelop,代码行数:8,代码来源:CodeType.cs

示例10: GetIcon

		public static IImage GetIcon(IType t)
		{
			ITypeDefinition def = t.GetDefinition();
			if (def != null)
				return GetIcon(def);
			else
				return null;
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:8,代码来源:ClassBrowserIconService.cs

示例11: ImportCompletionData

 ICompletionData ICompletionDataFactory.CreateImportCompletionData(IType type, bool useFullName)
 {
     ITypeDefinition typeDef = type.GetDefinition();
     if (typeDef != null)
         return new ImportCompletionData(typeDef, contextAtCaret, useFullName);
     else
         throw new InvalidOperationException("Should never happen");
 }
开发者ID:sentientpc,项目名称:SharpSnippetCompiler-v5,代码行数:8,代码来源:CSharpCompletionDataFactory.cs

示例12: ResolveType

 //public List<IMethod> MethodsWithExternalMetadata = new List<IMethod>();
 //public List<IProperty> PropertiesWithExternalMetadata = new List<IProperty>();
 //public Dictionary<IEntity, List<IAttribute>> ExternalMetadata = new Dictionary<IEntity, List<IAttribute>>();
 ITypeDefinition ResolveType(IType ce, string typeName)
 {
     if (ce != null)
         return ce.GetDefinition();
     if (typeName.IsNullOrEmpty())
         return null;
     var type = Project.FindType(typeName);
     return type;
 }
开发者ID:benbon,项目名称:SharpKit,代码行数:12,代码来源:CsExternalMetadata.cs

示例13: ConstructorParameterDataProvider

		public ConstructorParameterDataProvider (int startOffset, CSharpCompletionTextEditorExtension ext, IType type) : base (startOffset, ext)
		{
			this.type = type;
			
			var ctx = ext.CSharpParsedFile.GetTypeResolveContext (ext.Compilation, ext.Document.Editor.Caret.Location) as CSharpTypeResolveContext;

			var lookup = new MemberLookup (ctx.CurrentTypeDefinition, ext.Compilation.MainAssembly);
			bool isProtectedAllowed = ctx.CurrentTypeDefinition != null && type.GetDefinition () != null ? ctx.CurrentTypeDefinition.IsDerivedFrom (type.GetDefinition ()) : false;
						
			foreach (var method in type.GetConstructors ()) {
				Console.WriteLine ("constructor:" + method);
				if (!lookup.IsAccessible (method, isProtectedAllowed)) {
					Console.WriteLine ("skip !!!");
					continue;
				}
				methods.Add (method);
			}
		}
开发者ID:sparek,项目名称:monodevelop,代码行数:18,代码来源:ConstructorParameterDataProvider.cs

示例14: CreateTypeCompletionData

    public ICompletionData CreateTypeCompletionData(IType type, bool fullName, bool isInAttributeContext, bool addForTypeCreation) {
      var typeDef = type.GetDefinition();
      if (typeDef != null) { return new EntityCompletionData(typeDef); }

      string name = fullName ? type.FullName : type.Name;
      if (isInAttributeContext && name.EndsWith("Attribute", StringComparison.Ordinal) && name.Length > "Attribute".Length) {
        name = name.Substring(0, name.Length - "Attribute".Length);
      }
      return new CompletionData(name);
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:10,代码来源:CSharpCodeCompletionDataFactory.cs

示例15: Create

		public static CodeType Create(CodeModelContext context, IType type)
		{
			var typeDef = type.GetDefinition();
			if (typeDef != null) {
				var typeModel = typeDef.GetModel();
				if (typeModel != null)
					return Create(context.WithFilteredFileName(null), typeModel);
			}
			return null;
		}
开发者ID:kristjan84,项目名称:SharpDevelop,代码行数:10,代码来源:CodeType.cs


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