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