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


C# ITypeDefinition.GetMembers方法代码示例

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


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

示例1: GetMembers

		static IEnumerable<IMember> GetMembers (ITypeDefinition type, string name, bool ignoreInherited,
												Func<IMember, bool> filter)
		{
			var options = ignoreInherited ? GetMemberOptions.IgnoreInheritedMembers : GetMemberOptions.None;
			var members = type.GetMembers (m => m.Name == name, options);
			if (filter != null)
				members = members.Where (filter);
			return members;
		}
开发者ID:rajeshpillai,项目名称:monodevelop,代码行数:9,代码来源:MemberCollector.cs

示例2: GetMembers

		static IEnumerable<IMember> GetMembers (ITypeDefinition type, IMember member, bool ignoreInherited,
												Func<IMember, bool> filter)
		{
			var options = ignoreInherited ? GetMemberOptions.IgnoreInheritedMembers : GetMemberOptions.None;
			var members = type.GetMembers (m => m.Name == member.Name, options);

/*			// Filter out shadowed members.
			// class A { public string Foo { get; set; } } class B : A { public string Foo { get; set; } }
			if (member.SymbolKind == SymbolKind.Property || !(member is IParameterizedMember)) {
				members = members.Where (m => m == member || m.DeclaringType.Kind == TypeKind.Interface);
			}*/

			if (filter != null)
				members = members.Where (filter);
			return members;
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:16,代码来源:MemberCollector.cs

示例3: CollectMembersToImplement

		public static List<IMember> CollectMembersToImplement(ITypeDefinition implementingType, IType abstractType)
		{
			var toImplement = new List<IMember>();
			bool alreadyImplemented;
			foreach (var member in abstractType.GetMembers (d => !d.IsSynthetic  && d.IsAbstract)) {
				alreadyImplemented = false;
				var allBaseTypes = member.DeclaringType.GetAllBaseTypes().ToList ();
				foreach (var cmet in implementingType.GetMembers (d => d.SymbolKind == member.SymbolKind && d.Name == member.Name)) {
					if (allBaseTypes.Contains(cmet.DeclaringType))
						continue;
					if (ImplementInterfaceAction.CompareMembers(member, cmet)) {
						alreadyImplemented = true;
						break;
					}
				}
				if (!alreadyImplemented) 
					toImplement.Add(member);
			}
			return toImplement;
		}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:20,代码来源:ImplementAbstractMembersAction.cs

示例4: AddTreeClassContents

		static void AddTreeClassContents (TreeStore store, TreeIter parent, ParsedDocument parsedDocument, ITypeDefinition cls, IUnresolvedTypeDefinition part)
		{
			List<object> items = new List<object> ();
			if (cls.Kind != TypeKind.Delegate) {
				foreach (var o in cls.GetMembers (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
					items.Add (o);
				}
				foreach (var o in cls.GetNestedTypes (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
					if (o.DeclaringType == cls)
						items.Add (o);
				}
				foreach (var o in cls.GetConstructors (m => part.Region.FileName == m.Region.FileName && part.Region.IsInside (m.Region.Begin))) {
					if (o.IsSynthetic)
						continue;
					items.Add (o);
				}
			}
			items.Sort (ClassOutlineNodeComparer.CompareRegion);
			List<FoldingRegion> regions = new List<FoldingRegion> ();
			foreach (FoldingRegion fr in parsedDocument.UserRegions)
				//check regions inside class
				if (cls.BodyRegion.IsInside (fr.Region.Begin) && cls.BodyRegion.IsInside (fr.Region.End))
					regions.Add (fr);
			regions.Sort (delegate(FoldingRegion x, FoldingRegion y) { return x.Region.Begin.CompareTo (y.Region.Begin); });
			 
			IEnumerator<FoldingRegion> regionEnumerator = regions.GetEnumerator ();
			if (!regionEnumerator.MoveNext ())
				regionEnumerator = null;
			
			FoldingRegion currentRegion = null;
			TreeIter currentParent = parent;
			foreach (object item in items) {

				//no regions left; quick exit
				if (regionEnumerator != null) {
					DomRegion itemRegion = ClassOutlineNodeComparer.GetRegion (item);

					//advance to a region that could potentially contain this member
					while (regionEnumerator != null && !OuterEndsAfterInner (regionEnumerator.Current.Region, itemRegion))
						if (!regionEnumerator.MoveNext ())
							regionEnumerator = null;

					//if member is within region, make sure it's the current parent.
					//If not, move target iter back to class parent
					if (regionEnumerator != null && regionEnumerator.Current.Region.IsInside (itemRegion.Begin)) {
						if (currentRegion != regionEnumerator.Current) {
							currentParent = store.AppendValues (parent, regionEnumerator.Current);
							currentRegion = regionEnumerator.Current;
						}
					} else {
						currentParent = parent;
					}
				}
				
				TreeIter childIter = store.AppendValues (currentParent, item);
				if (item is ITypeDefinition)
					AddTreeClassContents (store, childIter, parsedDocument, (ITypeDefinition)item, part);
					
			} 
		}
开发者ID:telebovich,项目名称:monodevelop,代码行数:60,代码来源:ClassOutlineTextEditorExtension.cs

示例5: CheckTypes

        void CheckTypes(ITypeDefinition oType, ITypeDefinition nType, ref AbiCompatibility compatibility)
        {
            int oldMemberCount = 0;
            Predicate<IUnresolvedMember> pred = null;
            if (oType.Kind == TypeKind.Class || oType.Kind == TypeKind.Struct)
                pred = m => (m.IsPublic || m.IsProtected) && !m.IsOverride && !m.IsSynthetic;

            for (int i = 0; i < oType.TypeParameterCount; i++) {
                CheckContstraints (oType, oType.TypeParameters[i], nType.TypeParameters[i], ref compatibility);
                if (compatibility == AbiCompatibility.Incompatible && StopOnIncompatibility)
                    return;
            }

            foreach (var member in oType.GetMembers (pred, GetMemberOptions.IgnoreInheritedMembers)) {
                var newMember = nType.GetMembers (m => member.UnresolvedMember.Name == m.Name && m.IsPublic == member.IsPublic && m.IsProtected == member.IsProtected);
                var equalMember = newMember.FirstOrDefault (m => SignatureComparer.Ordinal.Equals (member, m));
                if (equalMember == null) {
                    compatibility = AbiCompatibility.Incompatible;
                    if (StopOnIncompatibility)
                        return;
                    continue;
                }
                var om = member as IMethod;
                if (om != null) {
                    for (int i = 0; i < om.TypeParameters.Count; i++) {
                        CheckContstraints (om, om.TypeParameters[i], ((IMethod)equalMember).TypeParameters[i], ref compatibility);
                        if (compatibility == AbiCompatibility.Incompatible && StopOnIncompatibility)
                            return;
                    }
                }

                oldMemberCount++;
            }
            if (compatibility == AbiCompatibility.Bigger && oType.Kind != TypeKind.Interface)
                return;
            if (oldMemberCount != nType.GetMembers (pred, GetMemberOptions.IgnoreInheritedMembers).Count ()) {
                if (oType.Kind == TypeKind.Interface) {
                    OnIncompatibilityFound (new AbiEventArgs (string.Format (TranslateString ("Interafce {0} has changed."), oType.FullName)));
                    compatibility = AbiCompatibility.Incompatible;
                } else {
                    if (compatibility == AbiCompatibility.Equal)
                        compatibility = AbiCompatibility.Bigger;
                }
            }
        }
开发者ID:segaman,项目名称:NRefactory,代码行数:45,代码来源:AbiComparer.cs

示例6: GetMember

		static IMember GetMember(ITypeDefinition type, string memberName)
		{
			string fullName = type.ReflectionName + "." + memberName;
			return type.GetMembers(m => m.ReflectionName == fullName).FirstOrDefault();
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:5,代码来源:SuppressMessageCommand.cs

示例7: ProcessTypeMembers

		private void ProcessTypeMembers(ITypeDefinition typeDefinition) {
			if (typeDefinition.Kind == TypeKind.Delegate)
				return;

			var baseMembersByType = typeDefinition.GetAllBaseTypeDefinitions().Where(x => x != typeDefinition).Select(t => new { Type = t, MemberNames = GetInstanceMemberNames(t) }).ToList();
			for (int i = 0; i < baseMembersByType.Count; i++) {
				var b = baseMembersByType[i];
				for (int j = i + 1; j < baseMembersByType.Count; j++) {
					var b2 = baseMembersByType[j];
					if (!b.Type.GetAllBaseTypeDefinitions().Contains(b2.Type) && !b2.Type.GetAllBaseTypeDefinitions().Contains(b.Type)) {
						foreach (var dup in b.MemberNames.Where(b2.MemberNames.Contains)) {
							Message(Messages._7018, typeDefinition, b.Type.FullName, b2.Type.FullName, dup);
						}
					}
				}
			}

			var instanceMembers = baseMembersByType.SelectMany(m => m.MemberNames).Distinct().ToDictionary(m => m, m => false);
			if (_instanceMemberNamesByType.ContainsKey(typeDefinition))
				_instanceMemberNamesByType[typeDefinition].ForEach(s => instanceMembers[s] = true);
			_unusableInstanceFieldNames.ForEach(n => instanceMembers[n] = false);

			var staticMembers = _unusableStaticFieldNames.ToDictionary(n => n, n => false);
			if (_staticMemberNamesByType.ContainsKey(typeDefinition))
				_staticMemberNamesByType[typeDefinition].ForEach(s => staticMembers[s] = true);

			var membersByName =   from m in typeDefinition.GetMembers(options: GetMemberOptions.IgnoreInheritedMembers)
			                     where !_ignoredMembers.Contains(m)
			                       let name = DeterminePreferredMemberName(m)
			                     group new { m, name } by name.Item1 into g
			                    select new { Name = g.Key, Members = g.Select(x => new { Member = x.m, NameSpecified = x.name.Item2 }).ToList() };

			bool isSerializable = GetTypeSemanticsInternal(typeDefinition).IsSerializable;
			foreach (var current in membersByName) {
				foreach (var m in current.Members.OrderByDescending(x => x.NameSpecified).ThenBy(x => x.Member, MemberOrderer.Instance)) {
					if (m.Member is IMethod) {
						var method = (IMethod)m.Member;

						if (method.IsConstructor) {
							ProcessConstructor(method, current.Name, m.NameSpecified, staticMembers);
						}
						else {
							ProcessMethod(method, current.Name, m.NameSpecified, m.Member.IsStatic || isSerializable ? staticMembers : instanceMembers);
						}
					}
					else if (m.Member is IProperty) {
						var p = (IProperty)m.Member;
						ProcessProperty(p, current.Name, m.NameSpecified, m.Member.IsStatic ? staticMembers : instanceMembers);
						var ps = GetPropertySemantics(p);
						if (p.CanGet)
							_methodSemantics[p.Getter] = ps.Type == PropertyScriptSemantics.ImplType.GetAndSetMethods ? ps.GetMethod : MethodScriptSemantics.NotUsableFromScript();
						if (p.CanSet)
							_methodSemantics[p.Setter] = ps.Type == PropertyScriptSemantics.ImplType.GetAndSetMethods ? ps.SetMethod : MethodScriptSemantics.NotUsableFromScript();
					}
					else if (m.Member is IField) {
						ProcessField((IField)m.Member, current.Name, m.NameSpecified, m.Member.IsStatic ? staticMembers : instanceMembers);
					}
					else if (m.Member is IEvent) {
						var e = (IEvent)m.Member;
						ProcessEvent((IEvent)m.Member, current.Name, m.NameSpecified, m.Member.IsStatic ? staticMembers : instanceMembers);
						var es = GetEventSemantics(e);
						_methodSemantics[e.AddAccessor]    = es.Type == EventScriptSemantics.ImplType.AddAndRemoveMethods ? es.AddMethod    : MethodScriptSemantics.NotUsableFromScript();
						_methodSemantics[e.RemoveAccessor] = es.Type == EventScriptSemantics.ImplType.AddAndRemoveMethods ? es.RemoveMethod : MethodScriptSemantics.NotUsableFromScript();
					}
				}
			}

			_instanceMemberNamesByType[typeDefinition] = new HashSet<string>(instanceMembers.Where(kvp => kvp.Value).Select(kvp => kvp.Key));
			_staticMemberNamesByType[typeDefinition] = new HashSet<string>(staticMembers.Where(kvp => kvp.Value).Select(kvp => kvp.Key));
		}
开发者ID:chenxustu1,项目名称:SaltarelleCompiler,代码行数:70,代码来源:MetadataImporter.cs

示例8: CollectMembersToImplement

		public static List<Tuple<IMember, bool>> CollectMembersToImplement(ITypeDefinition implementingType, IType interfaceType, bool explicitly, out bool interfaceMissing)
		{
			//var def = interfaceType.GetDefinition();
			List<Tuple<IMember, bool>> toImplement = new List<Tuple<IMember, bool>>();
			bool alreadyImplemented;
			interfaceMissing = true;
			// Stub out non-implemented events defined by @iface
			foreach (var evGroup in interfaceType.GetEvents (e => !e.IsSynthetic).GroupBy (m => m.DeclaringType).Reverse ())
				foreach (var ev in evGroup) {
					if (ev.DeclaringType.Kind != TypeKind.Interface)
						continue;

					bool needsExplicitly = explicitly;
					alreadyImplemented = implementingType.GetMembers().Any(m => m.ImplementedInterfaceMembers.Any(im => IsImplementation (im, ev)));
				
					if (!alreadyImplemented) {
						toImplement.Add(new Tuple<IMember, bool>(ev, needsExplicitly));
					} else {
						interfaceMissing = false;
					}
				}
			
			// Stub out non-implemented methods defined by @iface
			foreach (var methodGroup in interfaceType.GetMethods (d => !d.IsSynthetic).GroupBy (m => m.DeclaringType).Reverse ())
				foreach (var method in methodGroup) {
					if (method.DeclaringType.Kind != TypeKind.Interface)
						continue;
					bool needsExplicitly = explicitly;
					alreadyImplemented = false;

					foreach (var cmet in implementingType.GetMethods ()) {
						alreadyImplemented |= cmet.ImplementedInterfaceMembers.Any(m => IsImplementation (m, method));

						if (CompareMembers(method, cmet)) {
							if (!needsExplicitly && !cmet.ReturnType.Equals(method.ReturnType))
								needsExplicitly = true;
							else
								alreadyImplemented |= !needsExplicitly /*|| cmet.InterfaceImplementations.Any (impl => impl.InterfaceType.Equals (interfaceType))*/;
						}
					}
					if (toImplement.Where(t => t.Item1 is IMethod).Any(t => CompareMembers(method, (IMethod)t.Item1)))
						needsExplicitly = true;
					if (!alreadyImplemented) {
						toImplement.Add(new Tuple<IMember, bool>(method, needsExplicitly));
					} else {
						interfaceMissing = false;
					}
				}
			
			// Stub out non-implemented properties defined by @iface
			foreach (var propGroup in interfaceType.GetProperties (p => !p.IsSynthetic).GroupBy (m => m.DeclaringType).Reverse ())
				foreach (var prop in propGroup) {
					if (prop.DeclaringType.Kind != TypeKind.Interface)
						continue;

					bool needsExplicitly = explicitly;
					alreadyImplemented = implementingType.GetMembers().Any(m => m.ImplementedInterfaceMembers.Any(im => IsImplementation (im, prop)));

					foreach (var t in implementingType.GetAllBaseTypeDefinitions ()) {
						if (t.Kind == TypeKind.Interface) {
							foreach (var cprop in t.Properties) {
								if (cprop.Name == prop.Name && cprop.IsShadowing) {
									if (!needsExplicitly && !cprop.ReturnType.Equals(prop.ReturnType))
										needsExplicitly = true;
								}
							}
							continue;
						}
						foreach (var cprop in t.Properties) {
							if (cprop.Name == prop.Name) {
								if (!needsExplicitly && !cprop.ReturnType.Equals(prop.ReturnType))
									needsExplicitly = true;
								else
									alreadyImplemented |= !needsExplicitly/* || cprop.InterfaceImplementations.Any (impl => impl.InterfaceType.Resolve (ctx).Equals (interfaceType))*/;
							}
						}
					}
					if (!alreadyImplemented) {
						toImplement.Add(new Tuple<IMember, bool>(prop, needsExplicitly));
					} else {
						interfaceMissing = false;
					}
				}
			return toImplement;
		}
开发者ID:sphynx79,项目名称:dotfiles,代码行数:85,代码来源:ImplementInterfaceAction.cs

示例9: FindDerivedMember

		static IMember FindDerivedMember (IMember importedMember, ITypeDefinition derivedType)
		{
			IMember derivedMember;
			if (importedMember.DeclaringTypeDefinition.Kind == TypeKind.Interface) {
				derivedMember = derivedType.GetMembers (null, GetMemberOptions.IgnoreInheritedMembers)
					.FirstOrDefault (m => m.ImplementedInterfaceMembers.Any (im => im.Region == importedMember.Region));
			}
			else {
				derivedMember = InheritanceHelper.GetDerivedMember (importedMember, derivedType);
			}
			return derivedMember;
		}
开发者ID:riverans,项目名称:monodevelop,代码行数:12,代码来源:FindDerivedClassesHandler.cs


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