コード例 #1
0
        public override int CompareTo(object obj)
        {
            EventInformation eventInformation = (EventInformation)obj;

            if (this.IsTypeEvent != eventInformation.IsTypeEvent)
            {
                return(!this.IsTypeEvent ? -1 : 1);
            }
            if (this.IsMostDerivedTypeEvent != eventInformation.IsMostDerivedTypeEvent)
            {
                return(!this.IsMostDerivedTypeEvent ? 1 : -1);
            }
            int num = string.Compare(this.GroupBy, eventInformation.GroupBy, StringComparison.OrdinalIgnoreCase);

            if (num != 0)
            {
                return(num);
            }
            return(string.Compare(this.EventName, eventInformation.EventName, StringComparison.OrdinalIgnoreCase));
        }
コード例 #2
0
            private void CacheStateIfNecessary()
            {
                if (this.eventHandlers != null)
                {
                    return;
                }
                this.eventHandlers = (ICollection <EventHandlerModel>) new List <EventHandlerModel>();
                this.solution      = this.designerContext.ProjectManager.CurrentSolution;
                this.project       = ProjectHelper.GetProject(this.designerContext.ProjectManager, this.document.DocumentContext);
                if (this.project == null)
                {
                    return;
                }
                ITypeId typeId = (ITypeId)this.document.XamlDocument.CodeBehindClass;

                if (typeId == null)
                {
                    this.state = EventsModel.State.NoCodeBehind;
                }
                else
                {
                    if (this.node == null)
                    {
                        return;
                    }
                    IProjectItem projectItem = this.project.FindItem(this.document.DocumentReference);
                    if (projectItem == null)
                    {
                        return;
                    }
                    IProjectItem codeBehindItem = projectItem.CodeBehindItem;
                    if (codeBehindItem == null)
                    {
                        this.state = EventsModel.State.NoCodeBehind;
                    }
                    else
                    {
                        ICodeGeneratorHost codeGeneratorHost = codeBehindItem.DocumentType as ICodeGeneratorHost;
                        if (codeGeneratorHost == null)
                        {
                            return;
                        }
                        ITypeDeclaration     typeInFile           = this.designerContext.CodeModelService.FindTypeInFile((object)this.solution, (object)codeBehindItem, (IEnumerable <string>)EventsModel.Model.GetProjectItemPath(codeBehindItem), typeId.FullName);
                        CodeDomProvider      codeDomProvider      = codeGeneratorHost.CodeDomProvider;
                        EventHandlerProvider eventHandlerProvider = new EventHandlerProvider(this.designerContext, this.document, typeInFile);
                        this.state = EventsModel.State.Enabled;
                        IProjectContext           projectContext = this.document.ProjectContext;
                        IType                     type           = this.node.Type;
                        List <EventInformation>   list           = new List <EventInformation>(EventInformation.GetEventsForType((ITypeResolver)projectContext, type, MemberType.LocalEvent));
                        EventDescriptorCollection events         = TypeUtilities.GetEvents(type.RuntimeType);
                        list.Sort(new Comparison <EventInformation>(EventInformation.CompareNames));
                        foreach (EventInformation eventInfo in list)
                        {
                            EventDescriptor     eventDescriptor = events[eventInfo.EventName];
                            AttributeCollection eventAttributes = eventDescriptor != null?TypeUtilities.GetAttributes((MemberDescriptor)eventDescriptor) : (AttributeCollection)null;

                            this.eventHandlers.Add(new EventHandlerModel(eventInfo, this.node, codeDomProvider, (IEventHandlerProvider)eventHandlerProvider, eventAttributes));
                        }
                    }
                }
            }
コード例 #3
0
 private static Type GetEventHandlerReturnType(IType eventHandlerType)
 {
     return(EventInformation.GetInvokeMethod(eventHandlerType).ReturnType);
 }
コード例 #4
0
 public static int CompareNames(EventInformation a, EventInformation b)
 {
     return(string.Compare(a.EventName, b.EventName, StringComparison.OrdinalIgnoreCase));
 }