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


C# IProjectContent.SearchType方法代码示例

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


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

示例1: CreateReturnType

        public static IReturnType CreateReturnType(TypeReference reference, IClass callingClass,
		                                           IMember callingMember, int caretLine, int caretColumn,
		                                           IProjectContent projectContent,
		                                           ReturnTypeOptions options)
        {
            if (reference == null) return null;
            if (reference.IsNull) return null;
            if (reference is InnerClassTypeReference) {
                reference = ((InnerClassTypeReference)reference).CombineToNormalTypeReference();
            }

            bool useLazyReturnType = (options & ReturnTypeOptions.Lazy) == ReturnTypeOptions.Lazy;
            bool isBaseTypeReference = (options & ReturnTypeOptions.BaseTypeReference) == ReturnTypeOptions.BaseTypeReference;

            LanguageProperties languageProperties = projectContent.Language;
            IReturnType t = null;
            if (callingClass != null && !reference.IsGlobal) {
                foreach (ITypeParameter tp in callingClass.TypeParameters) {
                    if (languageProperties.NameComparer.Equals(tp.Name, reference.Type)) {
                        t = new GenericReturnType(tp);
                        break;
                    }
                }
                IMethod callingMethod = callingMember as IMethod;
                if (t == null && callingMethod != null) {
                    foreach (ITypeParameter tp in callingMethod.TypeParameters) {
                        if (languageProperties.NameComparer.Equals(tp.Name, reference.Type)) {
                            t = new GenericReturnType(tp);
                            break;
                        }
                    }
                }
            }
            if (t == null) {
                int typeParameterCount = reference.GenericTypes.Count;
                if (reference.IsKeyword) {
                    // keyword-type like void, int, string etc.
                    IClass c = projectContent.GetClass(reference.Type, typeParameterCount);
                    if (c != null)
                        t = c.DefaultReturnType;
                    else
                        t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
                } else {
                    if (useLazyReturnType || isBaseTypeReference) {
                        if (reference.IsGlobal) {
                            t = new GetClassReturnType(projectContent, reference.Type, typeParameterCount);
                        } else if (callingClass != null) {
                            SearchClassReturnType scrt = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.Type, typeParameterCount);
                            if (isBaseTypeReference)
                                scrt.LookForInnerClassesInDeclaringClass = false;
                            t = scrt;
                        }
                    } else {
                        IClass c;
                        if (reference.IsGlobal) {
                            c = projectContent.GetClass(reference.Type, typeParameterCount);
                            t = (c != null) ? c.DefaultReturnType : null;
                        } else if (callingClass != null) {
                            t = projectContent.SearchType(new SearchTypeRequest(reference.Type, typeParameterCount, callingClass, caretLine, caretColumn)).Result;
                        }
                        if (t == null) {
                            return null;
                        }
                    }
                }
            }
            if (reference.GenericTypes.Count > 0) {
                IReturnType[] para = new IReturnType[reference.GenericTypes.Count];
                for (int i = 0; i < reference.GenericTypes.Count; ++i) {
                    para[i] = CreateReturnType(reference.GenericTypes[i], callingClass, callingMember, caretLine, caretColumn, projectContent, options);
                }
                t = new ConstructedReturnType(t, para);
            }
            for (int i = 0; i < reference.PointerNestingLevel; i++) {
                t = new PointerReturnType(t);
            }
            return WrapArray(projectContent, t, reference);
        }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:78,代码来源:TypeVisitor.cs

示例2: CreateReturnType

		public static IReturnType CreateReturnType(TypeReference reference, IClass callingClass,
		                                           IMember callingMember, int caretLine, int caretColumn,
		                                           IProjectContent projectContent,
		                                           bool useLazyReturnType)
		{
			if (reference == null) return null;
			if (reference.IsNull) return null;
			if (reference is InnerClassTypeReference) {
				reference = ((InnerClassTypeReference)reference).CombineToNormalTypeReference();
			}
			LanguageProperties languageProperties = projectContent.Language;
			IReturnType t = null;
			if (callingClass != null && !reference.IsGlobal) {
				foreach (ITypeParameter tp in callingClass.TypeParameters) {
					if (languageProperties.NameComparer.Equals(tp.Name, reference.SystemType)) {
						t = new GenericReturnType(tp);
						break;
					}
				}
				if (t == null && callingMember is IMethod && (callingMember as IMethod).TypeParameters != null) {
					foreach (ITypeParameter tp in (callingMember as IMethod).TypeParameters) {
						if (languageProperties.NameComparer.Equals(tp.Name, reference.SystemType)) {
							t = new GenericReturnType(tp);
							break;
						}
					}
				}
			}
			if (t == null) {
				if (reference.Type != reference.SystemType) {
					// keyword-type like void, int, string etc.
					IClass c = projectContent.GetClass(reference.SystemType);
					if (c != null)
						t = c.DefaultReturnType;
					else
						t = new GetClassReturnType(projectContent, reference.SystemType, 0);
				} else {
					int typeParameterCount = reference.GenericTypes.Count;
					if (useLazyReturnType) {
						if (reference.IsGlobal)
							t = new GetClassReturnType(projectContent, reference.SystemType, typeParameterCount);
						else if (callingClass != null)
							t = new SearchClassReturnType(projectContent, callingClass, caretLine, caretColumn, reference.SystemType, typeParameterCount);
					} else {
						IClass c;
						if (reference.IsGlobal) {
							c = projectContent.GetClass(reference.SystemType, typeParameterCount);
							t = (c != null) ? c.DefaultReturnType : null;
						} else if (callingClass != null) {
							t = projectContent.SearchType(new SearchTypeRequest(reference.SystemType, typeParameterCount, callingClass, caretLine, caretColumn)).Result;
						}
						if (t == null) {
							if (reference.GenericTypes.Count == 0 && !reference.IsArrayType) {
								// reference to namespace is possible
								if (reference.IsGlobal) {
									if (projectContent.NamespaceExists(reference.Type))
										return new NamespaceReturnType(reference.Type);
								} else {
									string name = projectContent.SearchNamespace(reference.Type, callingClass, (callingClass == null) ? null : callingClass.CompilationUnit, caretLine, caretColumn);
									if (name != null)
										return new NamespaceReturnType(name);
								}
							}
							return null;
						}
					}
				}
			}
			if (reference.GenericTypes.Count > 0) {
				List<IReturnType> para = new List<IReturnType>(reference.GenericTypes.Count);
				for (int i = 0; i < reference.GenericTypes.Count; ++i) {
					para.Add(CreateReturnType(reference.GenericTypes[i], callingClass, callingMember, caretLine, caretColumn, projectContent, useLazyReturnType));
				}
				t = new ConstructedReturnType(t, para);
			}
			return WrapArray(projectContent, t, reference);
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:77,代码来源:TypeVisitor.cs


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