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


C# IProjectContent.GetClass方法代码示例

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


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

示例1: FindMyFormsClass

		internal static IClass FindMyFormsClass(IProjectContent pc, string myNamespace)
		{
			if (pc != null) {
				return pc.GetClass(myNamespace + ".MyForms", 0);
			}
			return null;
		}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:7,代码来源:CSharpMyNamespaceBuilder.cs

示例2: GetClassIfTypeNameIsNotEmpty

		IClass GetClassIfTypeNameIsNotEmpty(IProjectContent projectContent, string modelTypeName)
		{
			if (!String.IsNullOrEmpty(modelTypeName)) {
				return projectContent.GetClass(modelTypeName, 0);
			}
			return null;
		}
开发者ID:GMRyujin,项目名称:SharpDevelop,代码行数:7,代码来源:RazorCSharpResolver.cs

示例3: Create

		static IReturnType Create(IProjectContent pc, IEntity member, Type type, bool createLazyReturnType, bool forceGenericType)
		{
			if (type.IsByRef) {
				// TODO: Use ByRefRefReturnType
				return Create(pc, member, type.GetElementType(), createLazyReturnType);
			} else if (type.IsPointer) {
				return new PointerReturnType(Create(pc, member, type.GetElementType(), createLazyReturnType));
			} else if (type.IsArray) {
				return new ArrayReturnType(pc, Create(pc, member, type.GetElementType(), createLazyReturnType), type.GetArrayRank());
			} else if (type.IsGenericType && (forceGenericType || !type.IsGenericTypeDefinition)) {
				Type[] args = type.GetGenericArguments();
				List<IReturnType> para = new List<IReturnType>(args.Length);
				for (int i = 0; i < args.Length; ++i) {
					para.Add(Create(pc, member, args[i], createLazyReturnType));
				}
				return new ConstructedReturnType(Create(pc, member, type.GetGenericTypeDefinition(), createLazyReturnType, false), para);
			} else if (type.IsGenericParameter) {
				IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null;
				if (c != null && type.GenericParameterPosition < c.TypeParameters.Count) {
					if (c.TypeParameters[type.GenericParameterPosition].Name == type.Name) {
						return new GenericReturnType(c.TypeParameters[type.GenericParameterPosition]);
					}
				}
				if (type.DeclaringMethod != null) {
					IMethod method = member as IMethod;
					if (method != null) {
						if (type.GenericParameterPosition < method.TypeParameters.Count) {
							return new GenericReturnType(method.TypeParameters[type.GenericParameterPosition]);
						}
						return new GenericReturnType(new DefaultTypeParameter(method, type));
					}
				}
				return new GenericReturnType(new DefaultTypeParameter(c, type));
			} else {
				string name = type.FullName;
				if (name == null)
					throw new ApplicationException("type.FullName returned null. Type: " + type.ToString());
				int typeParameterCount = 0;
				if (name.Length > 2) {
					if (name[name.Length - 2] == '`') {
						typeParameterCount = int.Parse(name[name.Length - 1].ToString());
						name = name.Substring(0, name.Length - 2);
					}
				}
				if (name.IndexOf('+') > 0) {
					name = name.Replace('+', '.');
				}
				if (!createLazyReturnType) {
					IClass c = pc.GetClass(name, typeParameterCount);
					if (c != null)
						return c.DefaultReturnType;
					// example where name is not found: pointers like System.Char*
					// or when the class is in a assembly that is not referenced
				}
				return new GetClassReturnType(pc, name, typeParameterCount);
			}
		}
开发者ID:Adam-Fogle,项目名称:agentralphplugin,代码行数:57,代码来源:ReflectionReturnType.cs

示例4: SearchAllClassesWithName

		static void SearchAllClassesWithName(List<IClass> searchResults, IProjectContent pc, string name, LanguageProperties language)
		{
			foreach (string ns in pc.NamespaceNames) {
				IClass c = pc.GetClass(ns + "." + name, 0, language, GetClassOptions.None);
				if (c != null)
					searchResults.Add(c);
			}
		}
开发者ID:lisiynos,项目名称:pascalabcnet,代码行数:8,代码来源:RefactoringService.cs

示例5: CreateType

        /// <summary>
        /// Create a SharpDevelop return type from a Cecil type reference.
        /// </summary>
        internal static IReturnType CreateType(IProjectContent pc, IEntity member, TypeReference type)
        {
            while (type is TypeSpecification)
            {
                type = (type as TypeSpecification).ElementType;
            }
            if (type == null)
            {
                LoggingService.Warn("CecilReader: Null type for: " + member);
                return new VoidReturnType(pc);
            }
            if (type is ByReferenceType)
            {
                // TODO: Use ByRefRefReturnType
                return CreateType(pc, member, (type as ByReferenceType).ElementType);
            } else if (type is PointerType)
            {
                return new PointerReturnType(CreateType(pc, member, (type as PointerType).ElementType));
            } else if (type is ArrayType)
            {
                return new ArrayReturnType(pc, CreateType(pc, member, (type as ArrayType).ElementType), (type as ArrayType).Rank);
            } else if (type is GenericInstanceType)
            {
                GenericInstanceType gType = (GenericInstanceType)type;
                IReturnType[] para = new IReturnType[gType.GenericArguments.Count];
                for (int i = 0; i < para.Length; ++i)
                {
                    para[i] = CreateType(pc, member, gType.GenericArguments[i]);
                }
                return new ConstructedReturnType(CreateType(pc, member, gType.ElementType), para);
            } else if (type is GenericParameter)
            {
                GenericParameter typeGP = type as GenericParameter;
                if (typeGP.Owner is MethodDefinition)
                {
                    IMethod method = member as IMethod;
                    if (method != null)
                    {
                        if (typeGP.Position < method.TypeParameters.Count)
                        {
                            return new GenericReturnType(method.TypeParameters[typeGP.Position]);
                        }
                    }
                    return new GenericReturnType(new DefaultTypeParameter(method, typeGP.Name, typeGP.Position));
                } else {
                    IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null;
                    if (c != null && typeGP.Position < c.TypeParameters.Count) {
                        if (c.TypeParameters[typeGP.Position].Name == type.Name) {
                            return new GenericReturnType(c.TypeParameters[typeGP.Position]);
                        }
                    }
                    return new GenericReturnType(new DefaultTypeParameter(c, typeGP.Name, typeGP.Position));
                }
            } else {
                string name = type.FullName;
                if (name == null)
                    throw new ApplicationException("type.FullName returned null. Type: " + type.ToString());

                int typeParameterCount;
                if (name.IndexOf('/') > 0) {
                    typeParameterCount = 0;
                    StringBuilder newName = new StringBuilder();
                    foreach (string namepart in name.Split('/')) {
                        if (newName.Length > 0)
                            newName.Append('.');
                        int partTypeParameterCount;
                        newName.Append(ReflectionClass.SplitTypeParameterCountFromReflectionName(namepart, out partTypeParameterCount));
                        typeParameterCount += partTypeParameterCount;
                    }
                    name = newName.ToString();
                } else {
                    name = ReflectionClass.SplitTypeParameterCountFromReflectionName(name, out typeParameterCount);
                }

                IClass c = pc.GetClass(name, typeParameterCount);
                if (c != null) {
                    return c.DefaultReturnType;
                } else {
                    // example where name is not found: pointers like System.Char*
                    // or when the class is in a assembly that is not referenced
                    return new GetClassReturnType(pc, name, typeParameterCount);
                }
            }
        }
开发者ID:SergeTruth,项目名称:OxyChart,代码行数:87,代码来源:CecilReader.cs

示例6: CreateType

		/// <summary>
		/// Create a SharpDevelop return type from a Cecil type reference.
		/// </summary>
		internal static IReturnType CreateType(IProjectContent pc, IDecoration member, TypeReference type)
		{
			while (type is ModType) {
				type = (type as ModType).ElementType;
			}
			if (type == null) {
				LoggingService.Warn("CecilReader: Null type for: " + member);
				return VoidReturnType.Instance;
			}
			if (type is ReferenceType) {
				// TODO: Use ByRefRefReturnType
				return CreateType(pc, member, (type as ReferenceType).ElementType);
			} else if (type is ArrayType) {
				return new ArrayReturnType(pc, CreateType(pc, member, (type as ArrayType).ElementType), (type as ArrayType).Rank);
			} else if (type is GenericInstanceType) {
				GenericInstanceType gType = (GenericInstanceType)type;
				IReturnType[] para = new IReturnType[gType.GenericArguments.Count];
				for (int i = 0; i < para.Length; ++i) {
					para[i] = CreateType(pc, member, gType.GenericArguments[i]);
				}
				return new ConstructedReturnType(CreateType(pc, member, gType.ElementType), para);
			} else if (type is GenericParameter) {
				GenericParameter typeGP = type as GenericParameter;
				if (typeGP.Owner is MethodDefinition) {
					IMethod method = member as IMethod;
					if (method != null) {
						if (typeGP.Position < method.TypeParameters.Count) {
							return new GenericReturnType(method.TypeParameters[typeGP.Position]);
						}
					}
					return new GenericReturnType(new DefaultTypeParameter(method, typeGP.Name, typeGP.Position));
				} else {
					IClass c = (member is IClass) ? (IClass)member : (member is IMember) ? ((IMember)member).DeclaringType : null;
					if (c != null && typeGP.Position < c.TypeParameters.Count) {
						if (c.TypeParameters[typeGP.Position].Name == type.Name) {
							return new GenericReturnType(c.TypeParameters[typeGP.Position]);
						}
					}
					return new GenericReturnType(new DefaultTypeParameter(c, typeGP.Name, typeGP.Position));
				}
			} else {
				string name = type.FullName;
				if (name == null)
					throw new ApplicationException("type.FullName returned null. Type: " + type.ToString());
				
				if (name.IndexOf('/') > 0) {
					name = name.Replace('/', '.');
				}
				int typeParameterCount = 0;
				if (name.Length > 2 && name[name.Length - 2] == '`') {
					typeParameterCount = name[name.Length - 1] - '0';
					name = name.Substring(0, name.Length - 2);
				}
				
				IClass c = pc.GetClass(name, typeParameterCount);
				if (c != null) {
					return c.DefaultReturnType;
				} else {
					// example where name is not found: pointers like System.Char*
					// or when the class is in a assembly that is not referenced
					return new GetClassReturnType(pc, name, typeParameterCount);
				}
			}
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:67,代码来源:CecilReader.cs

示例7: GetPrimitiveClass

		static IClass GetPrimitiveClass(IProjectContent pc, string systemType, string newName)
		{
			IClass c = pc.GetClass(systemType, 0);
			if (c == null) {
				LoggingService.Warn("Could not find " + systemType);
				return null;
			}
			DefaultClass c2 = new DefaultClass(c.CompilationUnit, newName);
			c2.ClassType = c.ClassType;
			c2.Modifiers = c.Modifiers;
			c2.Documentation = c.Documentation;
			c2.BaseTypes.AddRange(c.BaseTypes);
			c2.Methods.AddRange(c.Methods);
			c2.Fields.AddRange(c.Fields);
			c2.Properties.AddRange(c.Properties);
			c2.Events.AddRange(c.Events);
			return c2;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:18,代码来源:BooResolver.cs

示例8: AttributesDataProvider

		public AttributesDataProvider(IProjectContent pc)
			: this(ExpressionContext.TypeDerivingFrom(pc.GetClass("System.Attribute"), true))
		{
		}
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:4,代码来源:AttributesDataProvider.cs

示例9: AllowsHelper

		static bool AllowsHelper(string baseClass, string methodName, IReturnType resolvedType, IProjectContent content)
		{
			IClass extensions = content.GetClass("System.Xml.Linq.Extensions", 0);
			if (extensions == null)
				return false;
			IMethod descendents = extensions.Methods.FirstOrDefault(m => m.Name == methodName);
			if (descendents == null)
				return false;
			IParameter param = descendents.Parameters.FirstOrDefault();
			if (param == null)
				return false;
			IClass resolvedTypeClass = resolvedType.GetUnderlyingClass();
			if (resolvedTypeClass == null)
				return false;
			return MemberLookupHelper.IsApplicable(resolvedType, param, descendents)
				|| resolvedTypeClass.IsTypeInInheritanceTree(content.GetClass(baseClass, 0));
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:17,代码来源:CompletionDataHelper.cs

示例10: 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

示例11: LoadFromXml

		public void LoadFromXml (IXPathNavigable doc, IProjectContent pc)
		{
			if (pc == null) return;
			if (doc == null) return;
			ClearCanvas();
			
			XPathNavigator nav = doc.CreateNavigator();
			XPathNodeIterator ni = nav.Select(@"/ClassDiagram/Class | /ClassDiagram/Struct | /ClassDiagram/Enum | /ClassDiagram/Interface | /ClassDiagram/Delegate");
			while (ni.MoveNext())
			{
				string typeName = ni.Current.GetAttribute("Name", "");
				IClass ct = pc.GetClass(typeName, 0);
				ClassCanvasItem canvasitem = ClassCanvas.CreateItemFromType(ct);
				if (canvasitem != null)
				{
					canvasitem.LoadFromXml (ni.Current);
					AddCanvasItem(canvasitem);
				}
			}
			ni = nav.Select(@"/ClassDiagram/Comment");
			while (ni.MoveNext())
			{
				NoteCanvasItem note = new NoteCanvasItem();
				note.LoadFromXml(ni.Current);
				AddCanvasItem(note);
			}
		}
开发者ID:Erguotou,项目名称:SharpDevelop,代码行数:27,代码来源:ClassCanvas.cs

示例12: FindTypeInAssembly

		static IReturnType FindTypeInAssembly(IProjectContent projectContent, string xmlNamespace, string className)
		{
			foreach (IAttribute att in projectContent.GetAssemblyAttributes()) {
				if (att.PositionalArguments.Count == 2
				    && att.AttributeType.FullyQualifiedName == "System.Windows.Markup.XmlnsDefinitionAttribute") {
					string namespaceName = att.PositionalArguments[1] as string;
					if (xmlNamespace.Equals(att.PositionalArguments[0]) && namespaceName != null) {
						IClass c = projectContent.GetClass(namespaceName + "." + className, 0);
						if (c != null)
							return c.DefaultReturnType;
					}
				}
			}
			return null;
		}
开发者ID:rbrunhuber,项目名称:SharpDevelop,代码行数:15,代码来源:XamlCompilationUnit.cs

示例13: 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

示例14: SearchAttributesWithName

		void SearchAttributesWithName(List<IClass> searchResults, IProjectContent pc, string name)
		{
			if (baseClass == null)
				baseClass = pc.GetClass("System.Attribute", 0);
			
			foreach (IClass c in pc.Classes) {
				if (c.IsTypeInInheritanceTree(baseClass) && (c.Name == name || c.Name == name + "Attribute"))
					searchResults.Add(c);
			}
		}
开发者ID:Rpinski,项目名称:SharpDevelop,代码行数:10,代码来源:ResolveAttribute.cs

示例15: AddUsing

		public static void AddUsing(List<ICompletionEntry> result, IUsing u, IProjectContent projectContent)
		{
			if (u == null) {
				return;
			}
			bool importNamespaces = projectContent.Language.ImportNamespaces;
			bool importClasses = projectContent.Language.CanImportClasses;
			foreach (string name in u.Usings) {
				if (importClasses) {
					IClass c = projectContent.GetClass(name, 0);
					if (c != null) {
						ArrayList members = new ArrayList();
						IReturnType t = c.DefaultReturnType;
						members.AddRange(t.GetMethods());
						members.AddRange(t.GetFields());
						members.AddRange(t.GetEvents());
						members.AddRange(t.GetProperties());
						foreach (IMember m in members) {
							if (m.IsStatic && m.IsPublic) {
								result.Add(m);
							}
						}
						continue;
					}
				}
				if (importNamespaces) {
					string newName = null;
					if (projectContent.DefaultImports != null) {
						newName = projectContent.DefaultImports.SearchNamespace(name);
					}
					projectContent.AddNamespaceContents(result, newName ?? name, projectContent.Language, true);
				} else {
					foreach (ICompletionEntry o in projectContent.GetNamespaceContents(name)) {
						if (!(o is NamespaceEntry))
							result.Add(o);
					}
				}
			}
			if (u.HasAliases) {
				foreach (string alias in u.Aliases.Keys) {
					result.Add(new AliasEntry(alias));
				}
			}
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:44,代码来源:CtrlSpaceResolveHelper.cs


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