public Result <IDisposable> AddComponent(Identity identity, RenderedComponent component) { if (renderedComponents.ContainsKey(identity)) { return(Result.FailWith <IDisposable>(State.Forbidden, $"TargetRenderer already contains component {identity.Id}.")); } renderedComponents.Add(identity, component); ComponentAdded?.Invoke(this, new RenderedComponentEventArgs(identity, component)); return(Result.Ok(Disposable.For(() => { if (renderedComponents.ContainsKey(identity)) { renderedComponents.Remove(identity); ComponentRemoved?.Invoke(this, new RenderedComponentEventArgs(identity, component)); } }))); }
public RenderedComponentEventArgs(Identity identity, RenderedComponent component) { Identity = identity; Component = component; }