Example #1
0
        public void Execute(NotificationDelegate notifyThis)
        {
            if (File.Exists(SuccessLastTimeFileName))
                return; // this one worked last time

            foreach (Task t in m_tasks)
            {
                try
                {
                    t.Execute(this);
                }
                catch (Exception e)
                {
                    Message = e.Message;

                    if (e.Message.Length == 0)
                        Message = e.GetType().Name;

                    notifyThis(this);

                    if (ShouldAbort)
                        return;
                }
            }

            if (FailureMode == FailureMode.None)
            {
                using (File.Open(SuccessLastTimeFileName, FileMode.Create))
                {
                }
            }
        }
Example #2
0
 private void onMenuOptionSelect(int i_MenuOptionNumber)
 {
     if (NotificationDelegate != null)
     {
         NotificationDelegate.Invoke(i_MenuOptionNumber);
     }
 }
Example #3
0
 public SyncWindow(ISyncMessageReceiver syncMsgReceiver)
 {
     this.syncMsgReceiver = syncMsgReceiver;
     base.CreateControl();
     this.notificationDelegate       = new NotificationDelegate(this.OnSyncNotification);
     this.routerNotificationDelegate = new RouterNotificationDelegate(this.OnSyncRouterNotification);
 }
Example #4
0
        public ISubscription Subscribe(string name, NotificationDelegate method)
        {
            Subscription subscription = new Subscription(this, name, method);

            _subscriptions.Add(subscription);

            return(subscription);
        }
Example #5
0
        public ISubscription <T> Subscribe <T>(string name, NotificationDelegate <T> method)
        {
            var subscription = new Subscription <T>(this, name, method);

            _subscriptions.Add(subscription);

            return(subscription);
        }
Example #6
0
 ///<summary>
 /// 添加注册事件监听,增加特定的委托
 ///</summary>
 ///<param name = "eventKey" >事件名</param>
 ///<param name = "listener" >委托</param>
 public void AddNotificationListener(uint eventKey, NotificationDelegate listener)
 {
     if (!HasEventListener(eventKey))
     {
         NotificationDelegate del = null;  //定义方法
         eventListeners[eventKey] = del;   // 给委托变量赋值
     }
     eventListeners[eventKey] += listener; //注册接收者的监听
 }
Example #7
0
        public CocoaWindow(WindowConfiguration config, IUiFactory windowFactory)
        {
            if (windowFactory == null)
            {
                throw new ArgumentNullException(nameof(windowFactory));
            }

            this.config = config ?? throw new ArgumentNullException(nameof(config));

            Interlocked.Increment(ref count);

            // need to keep the delegates around or they will get garbage collected
            windowShouldCloseDelegate = WindowShouldCloseCallback;
            windowWillCloseDelegate   = WindowWillCloseCallback;

            Handle = AppKit.Call("NSWindow", "alloc");

            var style = NSWindowStyleMask.Titled | NSWindowStyleMask.Closable | NSWindowStyleMask.Miniaturizable;

            if (config.CanResize)
            {
                style |= NSWindowStyleMask.Resizable;
            }

            ObjC.SendMessage(
                Handle,
                ObjC.RegisterName("initWithContentRect:styleMask:backing:defer:"),
                new CGRect(0, 0, config.Width, config.Height),
                (int)style,
                2,
                0);

            Title = config.Title;

            IntPtr bgColor = NSColor.FromHex(config.BackgroundColor);

            ObjC.Call(Handle, "setBackgroundColor:", bgColor);

            var contentProvider = new EmbeddedFileProvider(config.ContentAssembly, config.ContentFolder);

            bridge  = new WebviewBridge();
            webview = new CocoaWebview(config, contentProvider, bridge);
            ObjC.Call(Handle, "setContentView:", webview.Handle);

            if (config.EnableScriptInterface)
            {
                bridge.Init(this, webview, windowFactory);
            }

            if (config.UseBrowserTitle)
            {
                webview.TitleChanged += Webview_TitleChanged;
                bridge.TitleChanged  += Webview_TitleChanged;
            }

            SetWindowDelegate(Handle);
        }
Example #8
0
 ///<summary>
 ///添加一个监听消息(没有这个消息ID则创建新的,如果有则直接添加)
 ///</summary>
 public void AddListener(uint id, NotificationDelegate listener)
 {
     if (!eventListeners.ContainsKey(id))
     {
         NotificationDelegate noti = null;
         eventListeners[id] = noti;
     }
     eventListeners[id] += listener;
 }
        internal protected void RaiseNotification(NotificationDelegate @delegate, int timeout = 1000)
        {
            if (timeout <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(timeout));
            }

            @delegate(timeout, this.Title, this.Message, (ToolTipIcon)(int)this.Type);
        }
Example #10
0
 /// <summary>
 /// 添加监听
 /// </summary>
 /// <param name="_eventKey"></param>
 /// <param name="_listener"></param>
 public void AddEventListener(NotifEventKey _eventKey, NotificationDelegate listener)
 {
     if (!HasEventListener(_eventKey))
     {
         NotificationDelegate del = null;    //定义方法
         m_EventListener[_eventKey] = del;   // 给委托变量赋值
     }
     m_EventListener[_eventKey] += listener; //注册接收者的监听
 }
        public Task <ApiResponse <Unit> > Handle <TSession, TNotification>(
            NotificationDelegate <TSession, TNotification> next,
            NotificationExecutionContext <TSession, TNotification> context)
            where TSession : IHattemSession
            where TNotification : INotification
        {
            NotificationCapturedContextStorage <TSession, TNotification> .CapturedContext.Add(context);

            return(next(context));
        }
            public AchievementsRefreshInfo(IndieCityManager ic, NotificationDelegate refreshCompleteDelegate, Boolean mustRefreshAchievementValues)
            {
                AchievementsUpdated = false;
                UserAchievementsFetched = false;
                RefreshCompleteDelegate = refreshCompleteDelegate;

                ic.AchievementsManager.GetUserAchievementList(ic.Session.UserId);
                if (mustRefreshAchievementValues)
                    ic.AchievementsManager.AchievementGroup.RefreshAchievementValues();
            }    
 public void RemoveObserver(NotificationDelegate notificationDelegate, string notificationName) {
     if (string.IsNullOrEmpty(notificationName)) {
         throw new ArgumentNullException(@"notificationName");
     }
     if (notificationDelegate == null) {
         throw new ArgumentNullException("notificationDelegate");
     }
     if (_Notifications.ContainsKey(notificationName)) {
         _Notifications[notificationName].Remove(notificationDelegate);
     }
 }
Example #14
0
        public bool UnregisterAll(NotificationDelegate del)
        {
            bool removed = false;

            foreach (KeyValuePair <string, NotificationDelegateList> e in m_registerMap)
            {
                NotificationDelegateList list = e.Value;
                removed |= list.Remove(del);
            }
            return(removed);
        }
Example #15
0
    /// <summary>
    /// 添加监听者
    /// </summary>
    public void AddEventListener(uint eventkey, NotificationDelegate listener)
    {
        //添加一个空位
        if (!HasEventListener(eventkey))
        {
            NotificationDelegate del = null;
            eventListeners[eventkey] = del;
        }

        eventListeners[eventkey] += listener;
    }
Example #16
0
 public void removeEvent(string name, NotificationDelegate delega)
 {
     if (_table.ContainsKey(name))
     {
         List <NotificationDelegate> list = _table [name];
         if (list != null && list.Contains(delega))
         {
             _table [name].Remove(delega);
         }
     }
 }
Example #17
0
        public bool Unregister(string name, NotificationDelegate del)
        {
            NotificationDelegateList list = FindList(name);

            if (list != null)
            {
                return(list.Remove(del));
            }

            return(false);
        }
Example #18
0
 public SyncWindow(ISyncMessageReceiver syncMsgReceiver, ISyncNotificationReceiver syncNoteReceiver)
 {
     this.syncMsgReceiver  = syncMsgReceiver;
     this.syncNoteReceiver = syncNoteReceiver;
     base.CreateControl();
     this.notificationDelegate         = new NotificationDelegate(this.OnSyncNotification);
     this.notificationQueueDelegate    = new NotificationQueueDelegate(this.OnSyncQueueNotification);
     this.routerNotificationDelegate   = new RouterNotificationDelegate(this.OnSyncRouterNotification);
     this.stateChangedDelegate         = new StateChangedDelegate(this.OnAdsStateChanged);
     this.symbolVersionChangedDelegate = new SymbolVersionChangedDelegate(this.OnSymbolVersionChanged);
 }
Example #19
0
 public void AddEventListener(uint eventKey, NotificationDelegate listener)
 {
     if (!HasEventListener(eventKey))
     {
         eventListeners[eventKey] = listener; //注册接收者的监听
     }
     else
     {
         eventListeners[eventKey] += listener; //注册接收者的监听
     }
 }
Example #20
0
 ///<summary>
 /// 移除注册事件监听,取消特定的委托
 ///</summary>
 ///<param name = "eventKey" >事件名</param>
 ///<param name = "listener" >委托</param>
 public void RemoveEventListener(uint eventKey, NotificationDelegate listener)
 {
     if (!HasEventListener(eventKey))
     {
         return;
     }
     eventListeners[eventKey] -= listener; //析构指定接收者的监听
     if (eventListeners[eventKey] == null)
     {
         RemoveEventListener(eventKey);
     }
 }
 public void AddObserver(NotificationDelegate notificationDelegate, string notificationName) {
     if (string.IsNullOrEmpty(notificationName)) {
         throw new ArgumentNullException(@"notificationDelegate");
     }
     if (notificationDelegate == null) {
         throw new ArgumentNullException("notificationDelegate");
     }
     if(!_Notifications.ContainsKey(notificationName)) {
         _Notifications[notificationName] = new List<NotificationDelegate>();
     }
     _Notifications[notificationName].Add(notificationDelegate);
 }
Example #22
0
        public void RequestAchievementDataRefresh(NotificationDelegate refreshCompleteDelegate)
        {
            if (SessionActive)
            {
                if (_achievementsRefreshInfo != null)
                {
                    throw new Exception("Previous achievement refresh request still being processed");
                }

                _achievementsRefreshInfo = new AchievementsRefreshInfo(this, refreshCompleteDelegate, true);
            }
        }
Example #23
0
        public AchievementsRefreshInfo(IndieCityManager ic, NotificationDelegate refreshCompleteDelegate, Boolean mustRefreshAchievementValues)
        {
            AchievementsUpdated     = false;
            UserAchievementsFetched = false;
            RefreshCompleteDelegate = refreshCompleteDelegate;

            ic.AchievementsManager.GetUserAchievementList(ic.Session.UserId);
            if (mustRefreshAchievementValues)
            {
                ic.AchievementsManager.AchievementGroup.RefreshAchievementValues();
            }
        }
Example #24
0
 ///<summary>
 ///删除一个监听消息
 ///</summary>
 public void RemoveListener(uint id, NotificationDelegate listener)
 {
     if (!eventListeners.ContainsKey(id))
     {
         return;
     }
     eventListeners[id] -= listener;
     if (eventListeners[id] == null)
     {
         eventListeners.Remove(id);
     }
 }
Example #25
0
 /// <summary>
 /// 移除监听
 /// </summary>
 /// <param name="_eventKey"></param>
 /// <param name="_listener"></param>
 public void RemoveEventListener(NotifEventKey _eventKey, NotificationDelegate listener)
 {
     if (!HasEventListener(_eventKey))
     {
         return;
     }
     m_EventListener[_eventKey] -= listener;
     if (m_EventListener[_eventKey] == null)
     {
         RemoveEventListener(_eventKey);
     }
 }
Example #26
0
    public void addEvent(string name, NotificationDelegate delega)
    {
        if (!_table.ContainsKey(name))
        {
            _table.Add(name, new List <NotificationDelegate> ());
        }
        List <NotificationDelegate> list = _table [name];        // for sure

        if (!list.Contains(delega))
        {
            list.Add(delega);
        }
    }
Example #27
0
        /// <summary>
        /// Provides a notification message when a match opportunity is present.
        /// </summary>
        /// <param name="iContainer">The containing object.</param>
        public NegotiationService()
        {
            ManualResetEvent dispatcherCreated = new ManualResetEvent(false);

            // The initialization of this service requires a background thread to access the data model.
            FluidTrade.Core.ThreadPoolHelper.QueueUserWorkItem(new WaitCallback(InitializeData));

            this.foreground           = Dispatcher.CurrentDispatcher;
            this.backgroundDispatcher = new Dictionary <String, Dispatcher>();

            this.notificationHandler = this.OnNotification;

            this.notificationPopupTable = new Dictionary <Guid, PopupNotification>();
        }
Example #28
0
        public void RemoveErrObserver(NotificationDelegate notificationDelegate)
        {
            if (notificationDelegate == null)
            {
                throw new ArgumentNullException(@"Null Notification Delegate");
            }

            var delegatesCollection = (List <NotificationDelegate>)m_Hashtable[ERR];

            if (delegatesCollection != null)
            {
                delegatesCollection.Remove(notificationDelegate);
            }
        }
 public void RemoveObserver(NotificationDelegate notificationDelegate, string notificationName)
 {
     if (string.IsNullOrEmpty(notificationName))
     {
         throw new ArgumentNullException(@"notificationName");
     }
     if (notificationDelegate == null)
     {
         throw new ArgumentNullException("notificationDelegate");
     }
     if (_Notifications.ContainsKey(notificationName))
     {
         _Notifications[notificationName].Remove(notificationDelegate);
     }
 }
Example #30
0
        public void Register(String name, NotificationDelegate del)
        {
            Debug.Assert(name != null);
            Debug.Assert(del != null);

            NotificationDelegateList list = FindList(name);

            if (list == null)
            {
                list = new NotificationDelegateList();
                m_registerMap[name] = list;
            }

            list.Add(del);
        }
Example #31
0
 public void Register(string name, object target, NotificationDelegate action)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (target == null)
     {
         throw new ArgumentNullException("target");
     }
     if (target == null)
     {
         throw new ArgumentNullException("action");
     }
     AddValue(name, target, action);
 }
 public void AddObserver(NotificationDelegate notificationDelegate, string notificationName)
 {
     if (string.IsNullOrEmpty(notificationName))
     {
         throw new ArgumentNullException(@"notificationDelegate");
     }
     if (notificationDelegate == null)
     {
         throw new ArgumentNullException("notificationDelegate");
     }
     if (!_Notifications.ContainsKey(notificationName))
     {
         _Notifications[notificationName] = new List <NotificationDelegate>();
     }
     _Notifications[notificationName].Add(notificationDelegate);
 }
Example #33
0
        public void AddErrObserver(NotificationDelegate notificationDelegate)
        {
            if (notificationDelegate == null)
            {
                throw new ArgumentNullException(@"Null Notification Delegate");
            }

            var delegatesCollection = (List <NotificationDelegate>)m_Hashtable[ERR];

            if (delegatesCollection == null)
            {
                delegatesCollection = new List <NotificationDelegate>();
                m_Hashtable.Add(ERR, delegatesCollection);
            }
            delegatesCollection.Add(notificationDelegate);
        }
        /// <summary>
        /// Removes matching entries from the receiver’s dispatch table.
        /// </summary>
        /// <param name="p_notificationDelegate">Delegate  that specifies the message the receiver sends notificationObserver to notify it of the notification posting</param>
        /// <param name="p_notificationName">The name of the notification for which to register the observer; that is, only notifications with this name are delivered to the observer</param>
        public void RemoveObserver(NotificationDelegate p_notificationDelegate, string p_notificationName)
        {
            if (string.IsNullOrEmpty(p_notificationName))
            {
                throw new ArgumentNullException(@"p_notificationName");
            }
            if (p_notificationDelegate == null)
            {
                throw new ArgumentNullException("p_notificationDelegate");
            }
            var delegatesCollection = (List <NotificationDelegate>)m_hashtable[p_notificationName];

            if (delegatesCollection != null)
            {
                delegatesCollection.Remove(p_notificationDelegate);
            }
        }
Example #35
0
        public void RequestAchievementDataRefresh(NotificationDelegate refreshCompleteDelegate)
        {
            if (SessionActive)
            {
                if (_achievementsRefreshInfo != null)
                    throw new Exception("Previous achievement refresh request still being processed");

                _achievementsRefreshInfo = new AchievementsRefreshInfo(this, refreshCompleteDelegate, true);
            }
        }
 protected void RegisterNotification(String name, NotificationDelegate del)
 {
     NotificationCenter().Register(name, del);
 }
Example #37
0
 public void RequestSessionStart(NotificationDelegate startedDelegate)
 {
     _startPhase = SessionStartPhase.RequestSession;
     _startDelegate = startedDelegate;
     Session.RequestStartSession();
 }
Example #38
0
 protected void UnregisterNotifications(NotificationDelegate del)
 {
     NotificationCenter.UnregisterNotifications(del);
 }
Example #39
0
 protected void UnregisterNotification(string name, NotificationDelegate del)
 {
     NotificationCenter.UnregisterNotification(name, del);
 }