Beispiel #1
0
        internal void RegisterMenuEvent(MenuEventAttribute menuEventAttribute)
        {
            List<MenuEventAttribute> events;
            Logger.Debug(DebugString.Format(Messages.RegisteringMenuEvent, menuEventAttribute.UniqueUID, menuEventAttribute.OriginalType));
            menuEvents.TryGetValue(menuEventAttribute.UniqueUID, out events);
            if (events == null)
            {
                events = new List<MenuEventAttribute>();
                menuEvents.Add(menuEventAttribute.UniqueUID, events);
            }

            if (!events.Contains(menuEventAttribute))
                events.Add(menuEventAttribute);
        }
Beispiel #2
0
        private void DispatchForm(MenuEventAttribute menuEvent, ref MenuEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;

            // Prevent event from running twice.
            if (!pVal.BeforeAction)
                return;

            try
            {
                var obj = ContainerManager.Container.Resolve(menuEvent.OriginalType);
                if (obj is FormBase || obj is DoverFormBase)
                {
                    Logger.Debug(DebugString.Format(Messages.MenuDispatchInfo, pVal.MenuUID, menuEvent.OriginalType));
                    var method = menuEvent.OriginalType.GetMethod("Show");
                    method.Invoke(obj, null);
                }
                else if (menuEvent.OriginalMethod != null
                    && menuEvent.OriginalMethod.GetGenericArguments().Count() == 0)
                {
                    Logger.Debug(DebugString.Format(Messages.MenuDispatchInfo, pVal.MenuUID, menuEvent.OriginalMethod));
                    menuEvent.OriginalMethod.Invoke(obj, null);
                }
                else
                {
                    Logger.Debug(DebugString.Format(Messages.FileMissing, menuEvent.OriginalType, "?"));
                }
            }
            catch (Exception e)
            {
                Logger.Error(String.Format(Messages.MenuDispatchError, pVal.MenuUID, e.Message), e);
            }
        }