Ejemplo n.º 1
0
        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));
                }
            })));
        }
Ejemplo n.º 2
0
 public RenderedTextEventArgs(Identity identity, RenderedText text)
 {
     Identity = identity;
     Text     = text;
 }