Example #1
0
 ///// <summary>
 ///// 注册通知操作
 ///// </summary>
 ///// <param name="kcapi">监视的API</param>
 ///// <param name="type">通知类型</param>
 ///// <param name="notifyProvider">return null or "" => 不进行通知</param>
 public static void Register(string kcapi, INotifyType type, Func <Session, string> notifyProvider)
 {
     if (Current != null)
     {
         Current._Register(kcapi, type, notifyProvider);
     }
     else
     {
         InstanceInitialized += () => Current._Register(kcapi, type, notifyProvider);
     }
 }
Example #2
0
        private void _Register(string kcapi, INotifyType type, Func <Session, string> notifyProvider)
        {
            var key = new NotifyTypeKey(kcapi, type);

            Func <Session, string> action;

            if (this._notifyProviders.TryGetValue(key, out action))
            {
                action += notifyProvider;
                this._notifyProviders[key] = action;
            }
            else
            {
                this._notifyProviders.Add(key, notifyProvider);

                KanColleClient.Current.Proxy.ApiSessionSource
                .Where(s => s.Request.PathAndQuery == kcapi)
                .Subscribe(s => Current.Notify(s, key));
            }
        }
Example #3
0
 internal NotifyTypeKey(string uri, INotifyType type)
 {
     this.Uri  = uri;
     this.Type = type;
 }