private static T GetAs <T>(this ISignalREvent @event, ISignalREventHandler handler, string key, T defaultValue) { var theValue = @event.Get(handler, key, defaultValue); if (theValue == null) { return(defaultValue); } return((T)Convert.ChangeType(theValue, typeof(T))); }
//helpers private static void Set(this ISignalREvent @event, ISignalREventHandler handler, string key, object value) { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } var theKey = string.Format("{0}_{1}", key, handler.GetType().FullName); @event.Bags[theKey] = value; }
private static object Get(this ISignalREvent @event, ISignalREventHandler handler, string key, object defaultValue) { if (@event == null) { throw new ArgumentNullException(nameof(@event)); } if (handler == null) { throw new ArgumentNullException(nameof(handler)); } var theKey = string.Format("{0}_{1}", key, handler.GetType().FullName); if ([email protected](theKey)) { return(defaultValue); } return(@event.Bags[theKey]); }
public static bool GetStopSend(this ISignalREvent @event, ISignalREventHandler handler, bool defaultValue) { return(@event.GetAs(handler, ShouldStopSend, defaultValue)); }
public static void SetStopSend(this ISignalREvent @event, ISignalREventHandler handler, bool shouldStop) { @event.Set(handler, ShouldStopSend, shouldStop); }
public static void SetShouldThrowWhenException(this ISignalREvent @event, ISignalREventHandler handler, bool shouldThrow) { @event.Set(handler, ShouldThrowWhenException, shouldThrow); }
public static bool GetShouldThrowWhenException(this ISignalREvent @event, ISignalREventHandler handler, bool defaultValue) { return(@event.GetAs(handler, ShouldThrowWhenException, defaultValue)); }
public static void SetShouldWaitComplete(this ISignalREvent @event, ISignalREventHandler handler, bool shouldWait) { @event.Set(handler, ShouldWaitComplete, shouldWait); }
public static bool GetShouldWaitComplete(this ISignalREvent @event, ISignalREventHandler handler, bool defaultValue) { return(@event.GetAs(handler, ShouldWaitComplete, defaultValue)); }
public SignalREventHandlerDecorator(ISignalREventHandler signalREventHandler) { _signalREventHandler = signalREventHandler; }