public Result <IDisposable> AddText(Identity identity, RenderedText text) { if (renderedText.ContainsKey(identity)) { return(Result.FailWith <IDisposable>(State.Forbidden, $"TargetRenderer already contains text {identity.Id}.")); } renderedText.Add(identity, text); TextAdded?.Invoke(this, new RenderedTextEventArgs(identity, text)); return(Result.Ok(Disposable.For(() => { if (renderedText.ContainsKey(identity)) { renderedText.Remove(identity); TextRemoved?.Invoke(this, new RenderedTextEventArgs(identity, text)); } }))); }
public RenderedTextEventArgs(Identity identity, RenderedText text) { Identity = identity; Text = text; }