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


C# ProjectDom.GetType方法代码示例

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


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

示例1: GetProjectInfo

		public static NSObjectProjectInfo GetProjectInfo (ProjectDom dom)
		{
			NSObjectProjectInfo info;
			
			lock (infos) {
				if (infos.TryGetValue (dom, out info))
					return info;
				
				//only include DOMs that can resolve NSObject
				var nso = dom.GetType (nsobjectType);
				if (nso == null) {
					infos[dom] = null;
					return null;
				}
				
				info = new NSObjectProjectInfo (dom);
				infos[dom] = info;
				dom.Unloaded += HandleDomUnloaded;
				dom.ReferencesUpdated += HandleDomReferencesUpdated;
			}
			return info;
		}
开发者ID:thild,项目名称:monodevelop,代码行数:22,代码来源:NSObjectInfoService.cs

示例2: FindOverridables

		void FindOverridables (ProjectDom pctx, IType motherClass, IType cls, List<IMember> classMembers, List<IMember> interfaceMembers, List<IType> visited, bool includeOverridenClassMembers, bool includeOverridenInterfaceMembers)
		{
			if (visited.Contains (cls))
				return;
			
			visited.Add (cls);
			
			foreach (IReturnType rt in cls.BaseTypes)
			{
				IType baseCls = pctx.GetType (rt);
				
				if (baseCls == null)
					continue;

				if (visited.Contains (baseCls))
					continue;

				bool isInterface = baseCls.ClassType == ClassType.Interface;
				if (isInterface && interfaceMembers == null)
					continue;
				List<IMember> list = isInterface ? interfaceMembers : classMembers;
				bool includeOverriden = isInterface ? includeOverridenInterfaceMembers : includeOverridenClassMembers;

				foreach (IMethod m in baseCls.Methods) {
					if (m.IsInternal && motherClass.SourceProject != null && motherClass.SourceProject != m.DeclaringType.SourceProject)
						continue;
					if ((isInterface || m.IsVirtual || m.IsAbstract) && !m.IsSpecialName && !m.IsSealed && (includeOverriden || !IsOverridenMethod (motherClass, m)))
						list.Add (m);
				}
				foreach (IProperty m in baseCls.Properties) {
					if (m.IsIndexer)
						continue;
					if (m.IsInternal && motherClass.SourceProject != null && motherClass.SourceProject != m.DeclaringType.SourceProject)
						continue;
					if ((isInterface || m.IsVirtual || m.IsAbstract) && !m.IsSpecialName && !m.IsSealed && (includeOverriden || !IsOverridenProperty (motherClass, m)))
						list.Add (m);
				}
				foreach (IProperty m in baseCls.Properties) {
					if (!m.IsIndexer)
						continue;
					if (m.IsInternal && motherClass.SourceProject != null && motherClass.SourceProject != m.DeclaringType.SourceProject)
						continue;
					if ((isInterface || m.IsVirtual || m.IsAbstract) && !m.IsSpecialName && !m.IsSealed && (includeOverriden || !IsOverridenIndexer (motherClass, m)))
						list.Add (m);
				}
				foreach (IEvent m in baseCls.Events) {
					if (m.IsInternal && motherClass.SourceProject != null && motherClass.SourceProject != m.DeclaringType.SourceProject)
						continue;
					if ((isInterface || m.IsVirtual || m.IsAbstract) && !m.IsSpecialName && !m.IsSealed)
						list.Add (m);
				}

				FindOverridables (pctx, motherClass, baseCls, classMembers, isInterface ? interfaceMembers : null, visited,
				                  includeOverridenClassMembers, includeOverridenInterfaceMembers);
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:56,代码来源:CodeRefactorer.cs

示例3: Deserialize

        public virtual void Deserialize(XElement xml, ProjectDom dom)
        {
            var typeName = xml.Attribute ("Name");
            if (typeName == null) {
                throw new DeserializationException (xml.Name + " element with no \"Name\" attribute");
            }

            var domType = dom.GetType (DeserializeTypeName(typeName.Value));
            if (domType == null) {
                // TODO: Handle orphaned figures here..
                throw new NotImplementedException ();
            } else {
                Rebuild (domType);
                var members = xml.Element ("Members");
                if (members != null) {
                    foreach (var memberElem in members.Elements ()) {
                        var memberName = memberElem.Attribute ("Name");
                        if (memberName == null) {
                            throw new DeserializationException ("Member element with no name in " + domType.DecoratedFullName);
                        }

                        var member = domType.SearchMember (memberName.Value, true).SingleOrDefault ();
                        if (member != null) {
                            foreach (var c in Children) {
                                var memberFigure = c.Children
                                    .OfType<MemberFigure> ()
                                    .Where (f => f.Name == member.Name)
                                    .SingleOrDefault ();

                                if (memberFigure != null) {
                                    memberFigure.Visible = false;
                                }
                            }
                        }
                    }

                    var compartmentsElem = xml.Element ("Compartments");
                    if (compartmentsElem != null) {
                        foreach (var compartmentElem in compartmentsElem.Elements ("Compartment")) {
                            var name = compartmentElem.Attribute ("Name");
                            if (name == null)
                                continue;

                            var compartment = Children
                                .OfType<CompartmentFigure> ()
                                .Where (c => c.Name == name.Value)
                                .SingleOrDefault ();

                            if (compartment == null)
                                continue;

                            var compartmentCollapsed = compartmentElem.Attribute ("Collapsed");
                            compartment.Collapsed = compartmentCollapsed != null
                                    && Boolean.Parse (compartmentCollapsed.Value);
                        }
                    }
                }
            }

            var collapsed = xml.Attribute ("Collapsed");
            Collapsed = collapsed != null && Boolean.Parse (collapsed.Value);

            var position = xml.Element ("Position");
            this.DeserializePosition (position);
        }
开发者ID:erbriones,项目名称:monodevelop-classdesigner,代码行数:65,代码来源:TypeFigure.cs

示例4: GetLanguageItem

		public MonoDevelop.Projects.Dom.ResolveResult GetLanguageItem (ProjectDom dom, Mono.TextEditor.TextEditorData data, int offset)
		{
			if (offset < 0)
				return null;
			string fileName = data.Document.FileName;
			IParser parser = ProjectDomService.GetParser (fileName, data.Document.MimeType);
			if (parser == null)
				return null;
			
			MonoDevelop.Ide.Gui.Document doc = IdeApp.Workbench.ActiveDocument;
			if (doc == null)
				return null;
			
			IResolver         resolver = parser.CreateResolver (dom, doc, fileName);
			IExpressionFinder expressionFinder = parser.CreateExpressionFinder (dom);
			if (resolver == null || expressionFinder == null) 
				return null;
			
			string txt = data.Document.Text;
			int wordEnd = offset;
			while (wordEnd < txt.Length && (Char.IsLetterOrDigit (txt[wordEnd]) || txt[wordEnd] == '_'))
				wordEnd++;
			
			while (wordEnd < txt.Length - 1 && Char.IsWhiteSpace (txt[wordEnd]))
				wordEnd++;
			
			if (wordEnd < txt.Length && txt[wordEnd] == '<') {
				bool wasMethodCall = false;
				int saveEnd = wordEnd;
				int matchingBracket = data.Document.GetMatchingBracketOffset (wordEnd);
				if (matchingBracket > 0)
					wordEnd = matchingBracket;
				while (wordEnd < txt.Length - 1 && Char.IsWhiteSpace (txt[wordEnd]))
					wordEnd++;
				if (txt[wordEnd] == '(') {
					matchingBracket = data.Document.GetMatchingBracketOffset (wordEnd);
					if (matchingBracket > 0) {
						wordEnd = matchingBracket;
						wasMethodCall = true;
					}
				}
				if (!wasMethodCall)
					wordEnd = saveEnd;
			}

			ExpressionResult expressionResult = expressionFinder.FindExpression (txt, wordEnd);
			if (expressionResult == null)
				return null;
			ResolveResult resolveResult;
			DocumentLocation loc = data.Document.OffsetToLocation (offset);
			string savedExpression = null;
			
			// special handling for 'var' "keyword"
			if (expressionResult.ExpressionContext == ExpressionContext.IdentifierExpected && expressionResult.Expression != null && expressionResult.Expression.Trim () == "var") {
				int endOffset = data.Document.LocationToOffset (expressionResult.Region.End.Line - 1, expressionResult.Region.End.Column - 1);
				StringBuilder identifer = new StringBuilder ();
				for (int i = endOffset; i >= 0 && i < data.Document.Length; i++) {
					char ch = data.Document.GetCharAt (i);
					if (Char.IsWhiteSpace (ch))
						continue;
					if (ch == '=')
						break;
					if (Char.IsLetterOrDigit (ch) || ch =='_') {
						identifer.Append (ch);
						continue;
					}
					identifer.Length = 0;
					break;
				}
				if (identifer.Length > 0) {
					expressionResult.Expression = identifer.ToString ();
					resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
					if (resolveResult != null) {
						resolveResult = new MemberResolveResult (dom.GetType (resolveResult.ResolvedType));
						return resolveResult;
					}
				}
			}
			
			if (expressionResult.ExpressionContext == ExpressionContext.Attribute) {
				savedExpression = expressionResult.Expression;
				expressionResult.Expression += "Attribute";
				expressionResult.ExpressionContext = ExpressionContext.ObjectCreation;
			} 
			resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
			
			if (savedExpression != null && resolveResult == null) {
				expressionResult.Expression = savedExpression;
				resolveResult = resolver.Resolve (expressionResult, new DomLocation (loc.Line + 1, loc.Column + 1));
			}
			// Search for possible generic parameters.
//			if (this.resolveResult == null || this.resolveResult.ResolvedType == null || String.IsNullOrEmpty (this.resolveResult.ResolvedType.Name)) {
			if (!expressionResult.Region.IsEmpty) {
				int j = data.Document.LocationToOffset (expressionResult.Region.End.Line - 1, expressionResult.Region.End.Column - 1);
				int bracket = 0;
				for (int i = j; i >= 0 && i < data.Document.Length; i++) {
					char ch = data.Document.GetCharAt (i);
					if (Char.IsWhiteSpace (ch))
						continue;
					if (ch == '<') {
//.........这里部分代码省略.........
开发者ID:natosha,项目名称:monodevelop,代码行数:101,代码来源:TextEditorResolverProvider.cs

示例5: AddType

		internal static void AddType (ProjectDom dom, List<object> result, IReturnType returnType, IMember callingMember, bool showStatic)
		{
			if (returnType == null || returnType.FullName == "System.Void")
				return;
			if (returnType.ArrayDimensions > 0) {
				DomReturnType elementType = new DomReturnType (returnType.FullName);
				elementType.ArrayDimensions = returnType.ArrayDimensions - 1;
				for (int i = 0; i < elementType.ArrayDimensions; i++) {
					elementType.SetDimension (i, returnType.ArrayDimensions - 1);
				}
				elementType.PointerNestingLevel = returnType.PointerNestingLevel;
				
				AddType (dom, result, dom.GetArrayType (elementType), callingMember, showStatic);
				return;
			}
			IType type = dom.GetType (returnType);
			
			AddType (dom, result, type, callingMember, showStatic);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:19,代码来源:ResolveResult.cs

示例6: GetItem

		public static void GetItem (ProjectDom ctx, Document doc, ITextBuffer editor, out ResolveResult resolveResult, out INode item)
		{
			resolveResult = GetResolveResult (doc, editor);
			if (resolveResult is AggregatedResolveResult)
				resolveResult = ((AggregatedResolveResult)resolveResult).PrimaryResult;
			
			item = null;
			if (resolveResult is ParameterResolveResult) {
				item = ((ParameterResolveResult)resolveResult).Parameter;
			} else if (resolveResult is LocalVariableResolveResult) {
				item = ((LocalVariableResolveResult)resolveResult).LocalVariable;
				//s.Append (ambience.GetString (((LocalVariableResolveResult)result).ResolvedType, WindowConversionFlags));
			} else if (resolveResult is MemberResolveResult) {
				item = ((MemberResolveResult)resolveResult).ResolvedMember;
				if (item == null && ((MemberResolveResult)resolveResult).ResolvedType != null) {
					item = ctx.GetType (((MemberResolveResult)resolveResult).ResolvedType);
				}
			} else if (resolveResult is MethodResolveResult) {
				item = ((MethodResolveResult)resolveResult).MostLikelyMethod;
				if (item == null && ((MethodResolveResult)resolveResult).ResolvedType != null) {
					item = ctx.GetType (((MethodResolveResult)resolveResult).ResolvedType);
				}
			} else if (resolveResult is BaseResolveResult) {
				item = ctx.GetType (((BaseResolveResult)resolveResult).ResolvedType);
			} else if (resolveResult is ThisResolveResult) {
				item = ctx.GetType (((ThisResolveResult)resolveResult).ResolvedType);
			}
		}
开发者ID:stewartwhaley,项目名称:monodevelop,代码行数:28,代码来源:RefactoryCommands.cs

示例7: GetMethodSignature

		public static IMethod GetMethodSignature (ProjectDom context, IEvent ev)
		{
			if (ev.ReturnType == null)
				return null;
			IType cls = context.GetType (ev.ReturnType);
			if (cls == null)
				return null;
			foreach (IMethod m in cls.Methods)
				if (m.Name == "Invoke")
					return m;
			return null;
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:12,代码来源:BindingService.cs

示例8: IsValidClass

		static bool IsValidClass (ProjectDom ctx, IType cls, Stetic.Component obj)
		{
			if (cls.BaseTypes != null) {
				string typeName = obj.Type.ClassName;
				
				foreach (IReturnType bt in cls.BaseTypes) {
					System.Console.WriteLine("tn:" + typeName + " bt:" + bt.FullName);
					if (bt.FullName == typeName)
						return true;
					
					IType baseCls = ctx.GetType (bt);
					if (baseCls != null && IsValidClass (ctx, baseCls, obj))
						return true;
				}
			}
			return false;
		}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:17,代码来源:CodeBinder.cs

示例9: EnsureClassExists

		static IType EnsureClassExists (ProjectDom ctx, string className, DomRegion location)
		{
			IType cls = ctx.GetType (className);
			if (cls == null)
				throw new TypeNotFoundException (className, location, null);
			return cls;
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:7,代码来源:BindingService.cs

示例10: GetCompatibleMethodsInClass

		//TODO: check accessibility
		public static IEnumerable<IMethod> GetCompatibleMethodsInClass (ProjectDom ctx, IType cls, IMethod matchMeth)
		{
			IList<IType>[] pars = new IList<IType>[matchMeth.Parameters.Count];
			for (int i = 0; i < matchMeth.Parameters.Count; i++) {
				IType t = ctx.GetType (matchMeth.Parameters[i].ReturnType);
				if (t != null)
					pars[i] = new List<IType> (ctx.GetInheritanceTree (t));
				else
					pars[i] = new IType[0];
			}
			
			foreach (IType type in ctx.GetInheritanceTree (cls)) {
				if (type.ClassType != ClassType.Class)
					continue;
				
				foreach (IMethod method in type.Methods) {
					if (method.IsPrivate || method.Parameters.Count != pars.Length || method.ReturnType.FullName != matchMeth.ReturnType.FullName
					    
					    || method.IsInternal)
						continue;
					
					bool allCompatible = true;
					
					//compare each parameter
					for (int i = 0; i < pars.Length; i++) {
						bool parCompatible = false;
						foreach (IType t in pars[i]) {
							if (t.FullName == method.Parameters[i].ReturnType.FullName) {
								parCompatible = true;
								break;
							}
						}
						
						if (!parCompatible) {
							allCompatible = false;
							break;
						}
					}
					
					if (allCompatible)
						yield return method;
				}
			}
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:45,代码来源:BindingService.cs

示例11: ResolveTypes

		void ResolveTypes (ProjectDom dom, NSObjectTypeInfo type)
		{
			NSObjectTypeInfo resolved;
			
			if (type.BaseObjCType == null && type.BaseCliType != null) {
				if (cliTypes.TryGetValue (type.BaseCliType, out resolved)) {
					if (resolved.IsModel)
						type.BaseIsModel = true;
					type.BaseObjCType = resolved.ObjCName;
					if (resolved.IsUserType)
						type.UserTypeReferences.Add (resolved.ObjCName);
				} else {
					//managed classes many have implicitly registered base classes with a name not
					//expressible in obj-c. In this case, the best we can do is walk down the 
					//hierarchy until we find a valid base class
					foreach (var bt in dom.GetInheritanceTree (dom.GetType (type.BaseCliType))) { 
						if (cliTypes.TryGetValue (bt.FullName, out resolved)) {
							if (resolved.IsModel)
								type.BaseIsModel = true;
							type.BaseObjCType = resolved.ObjCName;
							if (resolved.IsUserType)
								type.UserTypeReferences.Add (resolved.ObjCName);
							break;
						}
					}
					if (type.BaseObjCType == null)
						Console.WriteLine ("Could not resolve CLI type '{0}'", type.BaseCliType);
				}
			}
			
			if (type.BaseCliType == null && type.BaseObjCType != null) {
				if (objcTypes.TryGetValue (type.BaseObjCType, out resolved))
					type.BaseCliType = resolved.CliName;
			}
			
			foreach (var outlet in type.Outlets) {
				if (outlet.ObjCType == null) {
					if (cliTypes.TryGetValue (outlet.CliType, out resolved)) {
						outlet.ObjCType = resolved.ObjCName;
						if (resolved.IsUserType)
							type.UserTypeReferences.Add (resolved.ObjCName);
					}
				}
				if (outlet.CliType == null) {
					if (objcTypes.TryGetValue (outlet.ObjCType, out resolved))
						outlet.CliType = resolved.CliName;
				}
			}
			
			foreach (var action in type.Actions) {
				foreach (var param in action.Parameters) {
					if (param.ObjCType == null) {
						if (cliTypes.TryGetValue (param.CliType, out resolved)) {
							param.ObjCType = resolved.ObjCName;
							if (resolved.IsUserType)
								type.UserTypeReferences.Add (resolved.ObjCName);
						}
					}
					if (param.CliType == null) {
						if (objcTypes.TryGetValue (param.ObjCType, out resolved))
							param.CliType = resolved.CliName;
					}
				}
			}
		}
开发者ID:poke,项目名称:monodevelop,代码行数:65,代码来源:NSObjectInfoTracker.cs

示例12: AssemblyTypeLookup

		public static IType AssemblyTypeLookup (ProjectDom assemblyDatabase, string namespac, string tagName)
		{
			return (assemblyDatabase == null)
				? null
				: assemblyDatabase.GetType (namespac + "." + tagName, false, false);
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:6,代码来源:WebTypeManager.cs

示例13: ListControlClasses

		public static IEnumerable<IType> ListControlClasses (IType baseType, ProjectDom database, string namespac)
		{
			if (database == null)
				yield break;
			
			//return classes if they derive from system.web.ui.control
			foreach (IType type in database.GetSubclasses (baseType, false, new string [] {namespac}))
				if (!type.IsAbstract && type.IsPublic)
					yield return type;
			
			if (!baseType.IsAbstract && baseType.IsPublic && baseType.Namespace == namespac) {
				IType t = database.GetType (baseType.FullName);
				if (t != null)
					yield return baseType;
			}
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:16,代码来源:WebTypeManager.cs

示例14: IsSubclass

		bool IsSubclass (ProjectDom ctx, IType baseClass, IType subclass)
		{
			foreach (IReturnType clsName in subclass.BaseTypes)
				if (clsName.FullName == baseClass.FullName)
					return true;

			foreach (IReturnType clsName in subclass.BaseTypes) {
				IType cls = ctx.GetType (clsName);
				if (cls != null && IsSubclass (ctx, baseClass, cls))
					return true;
			}
			return false;
		}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:13,代码来源:CodeRefactorer.cs

示例15: GetCompatibleMemberInClass

		public static IMember GetCompatibleMemberInClass (ProjectDom ctx, IType cls, CodeTypeMember member)
		{
			//check for identical property names
			foreach (IProperty prop in cls.Properties) {
				if (string.Compare (prop.Name, member.Name, StringComparison.OrdinalIgnoreCase) == 0) {
					EnsureClassExists (ctx, prop.ReturnType.FullName, GetValidRegion (prop));
					CodeMemberProperty memProp = member as CodeMemberProperty;
					if (memProp == null || !IsTypeCompatible (ctx, prop.ReturnType.FullName, memProp.Type.BaseType))
						throw new MemberExistsException (cls.FullName, MemberType.Property, member, GetValidRegion (prop), cls.CompilationUnit.FileName);
					return prop;
				}
			}
				
			//check for identical method names
			foreach (IMethod meth in cls.Methods) {
				if (string.Compare (meth.Name, member.Name, StringComparison.OrdinalIgnoreCase) == 0) {
					EnsureClassExists (ctx, meth.ReturnType.FullName, GetValidRegion (meth));
					CodeMemberMethod memMeth = member as CodeMemberMethod;
					if (memMeth == null || !IsTypeCompatible (ctx, meth.ReturnType.FullName, memMeth.ReturnType.BaseType))
						throw new MemberExistsException (cls.FullName, MemberType.Method, member, GetValidRegion (meth), cls.CompilationUnit.FileName);
					return meth;
				}
			}
			
			//check for identical event names
			foreach (IEvent ev in cls.Events) {
				if (string.Compare (ev.Name, member.Name, StringComparison.OrdinalIgnoreCase) == 0) {
					EnsureClassExists (ctx, ev.ReturnType.FullName, GetValidRegion (ev));
					CodeMemberEvent memEv = member as CodeMemberEvent;
					if (memEv == null || !IsTypeCompatible (ctx, ev.ReturnType.FullName, memEv.Type.BaseType))
						throw new MemberExistsException (cls.FullName, MemberType.Event, member, GetValidRegion (ev), cls.CompilationUnit.FileName);
					return ev;
				}
			}
				
			//check for identical field names
			foreach (IField field in cls.Fields) {
				if (string.Compare (field.Name, member.Name, StringComparison.OrdinalIgnoreCase) == 0) {
					EnsureClassExists (ctx, field.ReturnType.FullName, GetValidRegion (field));
					CodeMemberField memField = member as CodeMemberField;
					if (memField == null || !IsTypeCompatible (ctx, field.ReturnType.FullName, memField.Type.BaseType))
						throw new MemberExistsException (cls.FullName, MemberType.Field, member, GetValidRegion (field), cls.CompilationUnit.FileName);
					return field;
				}
			}
			
			//walk down into base classes, if any
			foreach (IReturnType baseType in cls.BaseTypes) {
				IType c = ctx.GetType (baseType);
				if (c == null)
					throw new TypeNotFoundException (baseType.FullName, cls.BodyRegion, cls.CompilationUnit.FileName);
				IMember mem = GetCompatibleMemberInClass (ctx, c, member);
				if (mem != null)
					return mem;
			}
			
			//return null if no match
			return null;
		}
开发者ID:okrmartin,项目名称:monodevelop,代码行数:59,代码来源:BindingService.cs


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