bool PipeContext.TryGetPayload <TPayload>(out TPayload context) { if (_payloadCache.TryGetPayload(out context)) { return(true); } return(_connectionContext.TryGetPayload(out context)); }
bool TransformContext.TryGetPayload <TPayload>(out TPayload context) { if (_payloadCache.TryGetPayload(out context)) { return(true); } return(_context.TryGetPayload(out context)); }
public bool TryGetPayload <TPayload>(out TPayload context) where TPayload : class { context = this as TPayload; if (context != null) { return(true); } return(_payloadCache.TryGetPayload(out context)); }
/// <summary> /// Attempts to get the specified payload type /// </summary> /// <param name="payload"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public virtual bool TryGetPayload <T>(out T payload) where T : class { if (this is T context) { payload = context; return(true); } return(PayloadCache.TryGetPayload(out payload)); }
public void BasicTest() { IPayloadCache p = new PayloadCache(); p.GetOrAddPayload(() => new Item("bob")); Item i; Assert.That(p.TryGetPayload(out i), Is.True); var p2 = p.CreateScope(); p.GetOrAddPayload(() => new Item2("bill")); Item2 i2; Assert.That(p2.TryGetPayload(out i2), Is.False); Item i1; Assert.That(p2.TryGetPayload(out i1), Is.True); }
public bool TryGetPayload <TPayload>(out TPayload context) where TPayload : class { return(_payloadCache.TryGetPayload(out context)); }