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


C# IReturnType.ToInvariantString方法代码示例

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


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

示例1: GetSharedReturnType

		internal IReturnType GetSharedReturnType (IReturnType rt)
		{
			string id = rt.ToInvariantString ();
			IReturnType s;
			if (!returnTypeCache.TryGetValue (id, out s)) {
				s = DomReturnType.GetSharedReturnType (rt, true);
				if (s == null) {
					s = rt;
					returnTypeCache [id] = rt;
				}
			}
			return s;
		}
开发者ID:kmarecki,项目名称:monodevelop,代码行数:13,代码来源:ProjectDom.cs

示例2: CreateTypeCompletionData

		CompletionDataList CreateTypeCompletionData (DomLocation location, IType callingType, ExpressionContext context, IReturnType returnType, IReturnType returnTypeUnresolved)
		{
			CompletionDataList result = new ProjectDomCompletionDataList ();
			// "var o = new " needs special treatment.
			if (returnType == null && returnTypeUnresolved != null && returnTypeUnresolved.FullName == "var")
				returnType = returnTypeUnresolved = DomReturnType.Object;

			//	ExpressionContext.TypeExpressionContext tce = context as ExpressionContext.TypeExpressionContext;

			CompletionDataCollector col = new CompletionDataCollector (dom, result, Document.CompilationUnit, callingType, location);
			IType type = null;
			if (returnType != null)
				type = dom.GetType (returnType);
			if (type == null)
				type = dom.SearchType (Document.CompilationUnit, (MonoDevelop.Projects.Dom.INode)Document.CompilationUnit ?? callingType, returnTypeUnresolved);
			
			// special handling for nullable types: Bug 674516 - new completion for nullables should not include "Nullable"
			if (type is InstantiatedType && ((InstantiatedType)type).UninstantiatedType.FullName == "System.Nullable" && ((InstantiatedType)type).GenericParameters.Count == 1) {
				var genericParameter = ((InstantiatedType)type).GenericParameters[0];
				returnType = returnTypeUnresolved = Document.CompilationUnit.ShortenTypeName (genericParameter, location);
				type = dom.SearchType (Document.CompilationUnit, (MonoDevelop.Projects.Dom.INode)Document.CompilationUnit ?? callingType, genericParameter);
			}
			
			if (type == null || !(type.IsAbstract || type.ClassType == ClassType.Interface)) {
				if (type == null || type.ConstructorCount == 0 || type.Methods.Any (c => c.IsConstructor && c.IsAccessibleFrom (dom, callingType, type, callingType != null && dom.GetInheritanceTree (callingType).Any (x => x.FullName == type.FullName)))) {
					if (returnTypeUnresolved != null) {
						col.FullyQualify = true;
						CompletionData unresovedCompletionData = col.Add (returnTypeUnresolved);
						col.FullyQualify = false;
						// don't set default completion string for arrays, since it interferes with: 
						// string[] arr = new string[] vs new { "a"}
						if (returnTypeUnresolved.ArrayDimensions == 0)
							result.DefaultCompletionString = StripGenerics (unresovedCompletionData.CompletionText);
					} else {
						CompletionData unresovedCompletionData = col.Add (returnType);
						if (returnType.ArrayDimensions == 0)
							result.DefaultCompletionString = StripGenerics (unresovedCompletionData.CompletionText);
					}
				}
			}
			
			//				if (tce != null && tce.Type != null) {
			//					result.DefaultCompletionString = StripGenerics (col.AddCompletionData (result, tce.Type).CompletionString);
			//				} 
			//			else {
			//			}
			if (type == null)
				return result;
			HashSet<string> usedNamespaces = new HashSet<string> (GetUsedNamespaces ());
			if (type.FullName == DomReturnType.Object.FullName) 
				AddPrimitiveTypes (col);
			
			foreach (IType curType in dom.GetSubclasses (type)) {
				if (context != null && context.FilterEntry (curType))
					continue;
				if ((curType.TypeModifier & TypeModifier.HasOnlyHiddenConstructors) == TypeModifier.HasOnlyHiddenConstructors)
					continue;
				if (usedNamespaces.Contains (curType.Namespace)) {
					if (curType.ConstructorCount > 0) {
						if (!(curType.Methods.Any (c => c.IsConstructor && c.IsAccessibleFrom (dom, curType, callingType, callingType != null && dom.GetInheritanceTree (callingType).Any (x => x.FullName == curType.FullName)))))
							continue;
					}
					col.Add (curType);
				} else {
					string nsName = curType.Namespace;
					int idx = nsName.IndexOf ('.');
					if (idx >= 0)
						nsName = nsName.Substring (0, idx);
					col.Add (new Namespace (nsName));
				}
			}
			
			// add aliases
			if (returnType != null) {
				foreach (IUsing u in Document.CompilationUnit.Usings) {
					foreach (KeyValuePair<string, IReturnType> alias in u.Aliases) {
						if (alias.Value.ToInvariantString () == returnType.ToInvariantString ())
							result.Add (alias.Key, "md-class");
					}
				}
			}
			return result;
		}
开发者ID:famousthom,项目名称:monodevelop,代码行数:83,代码来源:CSharpTextEditorCompletion.cs

示例3: CreateTypeCompletionData

        CompletionDataList CreateTypeCompletionData(DomLocation location, IType callingType, ExpressionContext context, IReturnType returnType, IReturnType returnTypeUnresolved)
        {
            CompletionDataList result = new ProjectDomCompletionDataList ();
            // "var o = new " needs special treatment.
            if (returnType == null && returnTypeUnresolved != null && returnTypeUnresolved.FullName == "var")
                returnType = returnTypeUnresolved = DomReturnType.Object;

            //	ExpressionContext.TypeExpressionContext tce = context as ExpressionContext.TypeExpressionContext;

            CompletionDataCollector col = new CompletionDataCollector (result, Document.CompilationUnit, location);
            IType type = null;
            if (returnType != null)
                type = dom.GetType (returnType);
            if (type == null)
                type = dom.SearchType (new SearchTypeRequest (Document.CompilationUnit, returnTypeUnresolved, null));

            if (type == null || !(type.IsAbstract || type.ClassType == ClassType.Interface)) {
                if (type == null || type.ConstructorCount == 0 || type.Methods.Any (c => c.IsConstructor && c.IsAccessibleFrom (dom, callingType, type, callingType != null && dom.GetInheritanceTree (callingType).Any (x => x.FullName == type.FullName)))) {
                    if (returnTypeUnresolved != null) {
                        col.FullyQualify = true;
                        ICompletionData unresovedCompletionData = col.Add (returnTypeUnresolved);
                        col.FullyQualify = false;
                        result.DefaultCompletionString = StripGenerics (unresovedCompletionData.CompletionText);
                    } else {
                        ICompletionData unresovedCompletionData = col.Add (returnType);
                        result.DefaultCompletionString = StripGenerics (unresovedCompletionData.CompletionText);
                    }
                }
            }
            //				if (tce != null && tce.Type != null) {
            //					result.DefaultCompletionString = StripGenerics (col.AddCompletionData (result, tce.Type).CompletionString);
            //				}
            //			else {
            //			}

            if (type == null)
                return result;
            HashSet<string> usedNamespaces = new HashSet<string> (GetUsedNamespaces ());
            if (type.FullName == DomReturnType.Object.FullName)
                AddPrimitiveTypes (col);
            foreach (IType curType in dom.GetSubclasses (type)) {
                if (context != null && context.FilterEntry (curType))
                    continue;
                if ((curType.TypeModifier & TypeModifier.HasOnlyHiddenConstructors) == TypeModifier.HasOnlyHiddenConstructors)
                    continue;
                if (usedNamespaces.Contains (curType.Namespace)) {
                    if (curType.ConstructorCount > 0) {
                        if (!(curType.Methods.Any (c => c.IsConstructor && c.IsAccessibleFrom (dom, curType, callingType, callingType != null && dom.GetInheritanceTree (callingType).Any (x => x.FullName == curType.FullName)))))
                            continue;
                    }
                    col.Add (curType);
                } else {
                    string nsName = curType.Namespace;
                    int idx = nsName.IndexOf ('.');
                    if (idx >= 0)
                        nsName = nsName.Substring (0, idx);
                    col.Add (new Namespace (nsName));
                }
            }

            // add aliases
            if (returnType != null) {
                foreach (IUsing u in Document.CompilationUnit.Usings) {
                    foreach (KeyValuePair<string, IReturnType> alias in u.Aliases) {
                        if (alias.Value.ToInvariantString () == returnType.ToInvariantString ())
                            result.Add (alias.Key, "md-class");
                    }
                }
            }
            return result;
        }
开发者ID:vasili,项目名称:FSharpBinding,代码行数:71,代码来源:FSharpTextEditorCompletion.cs

示例4: IsCompatible

		public bool IsCompatible (IReturnType baseType, IReturnType type)
		{
			if (baseType.ToInvariantString () == type.ToInvariantString ())
				return true;
			ProjectDom dom = null;
			if (CallingType == null) 
				return false;
			dom = CallingType.SourceProjectDom;
			IType b = dom.SearchType (CallingType.CompilationUnit, CallingType, CallingType.Location, baseType);
			IType t = dom.SearchType (CallingType.CompilationUnit, CallingType, CallingType.Location, type);
			if (b == null || t == null)
				return false;
			return dom.GetInheritanceTree (t).Any (tBase => tBase.DecoratedFullName == b.DecoratedFullName);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:14,代码来源:ResolveResult.cs

示例5: GetSharedReturnType

		internal IReturnType GetSharedReturnType (IReturnType rt)
		{
			string id = rt.ToInvariantString ();
			IReturnType s;
			if (returnTypeCache.TryGetValue (id, out s))
				return s;

			s = DomReturnType.GetSharedReturnType (rt);
			if (object.ReferenceEquals (s, rt))
				returnTypeCache [id] = rt;
			return s;
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:12,代码来源:ProjectDom.cs


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