Esempio n. 1
0
        protected void Run(IScWidget widget)
        {
            IHandler handler = null;

            try
            {
                if (s_Handler.TryGetValue(widget.GetType(), out handler))
                {
                    handler.Run(Context, widget);
                }
                else
                {
                    FallbackRun(Context, widget);
                }
                foreach (var child in widget.GetChildren())
                {
                    Run(child);
                }
            }
            finally
            {
                if (handler != null)
                {
                    handler.Finish(Context, widget);
                }
                else
                {
                    FallbackFinish(Context, widget);
                }
            }
        }
Esempio n. 2
0
        protected void Prepare(IScWidget widget)
        {
            IHandler handler;

            if (s_Handler.TryGetValue(widget.GetType(), out handler))
            {
                handler.Prepare(Context, widget);
            }
            else
            {
                FallbackPrepare(Context, widget);
            }

            foreach (var child in widget.GetChildren())
            {
                Prepare(child);
            }
        }
Esempio n. 3
0
        void Run <T>(IScWidget widget, Func <TContext, IScWidget, T, IDisposable> func) where T : class
        {
            IHandler _handler;

            s_Handler.TryGetValue(widget.GetType(), out _handler);
            IDisposable disposable = null;

            try
            {
                if (_handler is T hander)
                {
                    disposable = func?.Invoke(Context, widget, hander);
                }
                foreach (var child in widget.GetChildren())
                {
                    Run(child, func);
                }
            }
            finally
            {
                disposable?.Dispose();
            }
        }