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 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)); } }))); }
private IDisposable EnableLoadingStatus() { this.IsLoading = true; return(Disposable.For(() => this.IsLoading = false)); }