static void AddAttachedEvents(ITypeDefinition td, List<ICompletionItem> result)
		{
			var attachedEvents = td.Fields.Where(f => f.IsAttached(false, true));
			var unresolvedType = td.Parts.First();
			var resolveContext = new SimpleTypeResolveContext(td);

			result.AddRange(
				attachedEvents.Select(
					field => {
						string eventName = GetEventNameFromField(field);
						IUnresolvedEvent item = new DefaultUnresolvedEvent(unresolvedType, eventName);
						IMember entity = item.CreateResolved(resolveContext);
						return new XamlCompletionItem(eventName, entity);
					}
				)
			);
		}
예제 #2
0
        public IUnresolvedEvent ReadEvent(EventInfo ev, IUnresolvedTypeDefinition parentType)
        {
            if (ev == null)
                throw new ArgumentNullException("ev");
            if (parentType == null)
                throw new ArgumentNullException("parentType");

            DefaultUnresolvedEvent e = new DefaultUnresolvedEvent(parentType, ev.Name);
            TranslateModifiers(ev.AddMethod, e);
            e.ReturnType = ReadTypeReference(ev.EventHandlerType, typeAttributes: ev.CustomAttributes);

            e.AddAccessor    = ReadMethod(ev.AddMethod,    parentType, EntityType.Accessor, e);
            e.RemoveAccessor = ReadMethod(ev.RemoveMethod, parentType, EntityType.Accessor, e);
            e.InvokeAccessor = ReadMethod(ev.RaiseMethod, parentType, EntityType.Accessor, e);

            AddAttributes(ev, e);

            var accessor = e.AddAccessor ?? e.RemoveAccessor ?? e.InvokeAccessor;
            if (accessor != null && accessor.IsExplicitInterfaceImplementation) {
                e.Name = ev.Name.Substring(ev.Name.LastIndexOf('.') + 1);
                e.IsExplicitInterfaceImplementation = true;
                foreach (var mr in accessor.ExplicitInterfaceImplementations) {
                    e.ExplicitInterfaceImplementations.Add(new AccessorOwnerMemberReference(mr));
                }
            }

            FinishReadMember(e, ev);

            return e;
        }