public static IInterception Create( PropertyChangedInterceptor propertyChangedInterceptor, IInvocation invocation, NotifyMode fireOption) { switch (invocation) { case { } inv when inv.IsPropertyChangedAdd(): return(new PropertyChangedAddInterception(propertyChangedInterceptor, inv)); case { } inv when inv.IsPropertyChangedRemove(): return(new PropertyChangedRemoveInterception(propertyChangedInterceptor, inv)); case { } inv when inv.IsPropertySetter() && NotifyMode.OnlyOnChange == fireOption: return(new OnlyOnChangePropertySetterInterception(propertyChangedInterceptor, invocation) .WrapWith(new PropertyIsINotifyInterception(propertyChangedInterceptor, invocation))); case { } inv when inv.IsPropertySetter(): return(new PropertySetterInterception(propertyChangedInterceptor, invocation) .WrapWith(new PropertyIsINotifyInterception(propertyChangedInterceptor, invocation))); default: return(new InvocationInterception(invocation)); } }
internal SubscriberWeakLink(Type entityClass, SingleEntityChangeEventMethod handler) { targetReference = new WeakReference(handler.Target); method = handler.Method; mode = NotifyMode.Single; EntityTypes = new[] { entityClass }; }
public void ShowBaloon(string text, string userName, NotifyMode mode) { if (!ConfigManager.Config.Notification) { return; } string title = string.Empty; switch (mode) { case NotifyMode.Reply: title = string.Format("You got a reply from {0}.", userName); break; case NotifyMode.Rt: title = string.Format("Retweeted by {0}.", userName); break; case NotifyMode.Qt: title = string.Format("Quoted by {0}.", userName); break; case NotifyMode.Fav: title = string.Format("Favorited by {0}.", userName); break; case NotifyMode.Dm: title = string.Format("You got a direct-message by {0}.", userName); break; case NotifyMode.Follow: title = string.Format("You followed by {0}.", userName); break; default: title = "Notification."; break; } this.taskIcon.BalloonTipTitle = title; this.taskIcon.BalloonTipText = text; this.taskIcon.ShowBalloonTip(5); }
public AlipayWapNotify(NameValueCollection parameters, NotifyMode notifyMode) { this._parameters = parameters; this._notifyMode = notifyMode; if (_notifyMode == NotifyMode.Notify) { try { //通知模式 XML解析notify_data数据到参数集合中 XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(parameters["notify_data"]); foreach (XmlNode item in xmlDoc.SelectSingleNode("/notify")) { this._parameters[item.Name] = item.InnerText; } } catch { } } }
public static NotifyQuery Instance(string notifyType, NameValueCollection parameters, NotifyMode mode = NotifyMode.None) { if (string.IsNullOrEmpty(notifyType)) { return(null); } object[] args = mode == NotifyMode.None ? new object[] { parameters } : //回调和通知均使用同一种模式 new object[] { parameters, mode }; //DONE: 使用差异通知模式 BEN NEW MODE 20131016 Type type = Type.GetType(notifyType); if (type == null) { if (HttpContext.Current.IsDebuggingEnabled) { HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Write(string.Format("[ERROR]YSWL.Payment.Core.NotifyQuery:支付网关[{0}]不存在!", notifyType)); HttpContext.Current.Response.End(); } return(null); } return(Activator.CreateInstance(type, args) as NotifyQuery); }
static public async Task <R> RunSafe <R>(this Task <R> task, NotifyMode notifyMode = NotifyMode.Toast, string errorMessage = null, [CallerMemberName] string caller = null, [CallerLineNumber] long line = 0, [CallerFilePath] string path = null) { await((Task)task).RunProtected(notifyMode, errorMessage, caller, line, path); return(task.Result); }
static public async Task RunProtected(this Task task, NotifyMode notifyMode = NotifyMode.Toast, string errorMessage = null, [CallerMemberName] string caller = null, [CallerLineNumber] long line = 0, [CallerFilePath] string path = null) { Exception exception = null; try { if (!CrossConnectivity.Current.IsConnected) { //No connection Hud.Instance.ShowToast(Constants.NoConnectionMessage); return; } await Task.Run(() => { task.Start(); task.Wait(); }); } catch (TaskCanceledException) { Log.Instance.WriteLine("Task Cancelled"); return; } catch (Exception e) { exception = e; } if (exception != null) { var inner = exception.InnerException; while (inner.InnerException != null) { inner = inner.InnerException; } exception = inner; var serverDown = exception is WebException || exception.Message.Contains("403") || exception.Message.Contains("503"); if (serverDown) { errorMessage = "The server appears to be down"; } if (exception is DocumentVersionConclictException) { throw exception; } var msg = errorMessage ?? exception.Message; Log.Instance.WriteLine($"Handled exception:\n{exception.ToString()}"); switch (notifyMode) { case NotifyMode.None: break; case NotifyMode.Toast: Hud.Instance.ShowToast(msg); break; case NotifyMode.Throw: throw exception; } } }
private void ParseHandler(BatchEntityChangeHandler handler) { targetReference = new WeakReference(handler.Target); method = handler.Method; mode = NotifyMode.Batch; }
public T Make <T>(NotifyMode mode = NotifyMode.OnlyOnChange, params object[] ctorArgs) where T : class => typeof(T) switch {