コード例 #1
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(Command command, object activationScope, IDIContainer serviceProvider)
        {
            return(ResolutionStepResult.WAITING_FOR_SERVICE.Repeat(3).Concat(Helpers.CoroutineEnumerable(instantiate)).GetEnumerator());

            void instantiate()
            {
                var handler = serviceProvider.TryResolveSingle <ICommandHandlerWidget>(command);

                activationScope = handler?.FunctionId?.ActivationScope ?? activationScope;
                var widgetName = handler?.FunctionId?.Name ?? command.GetInfo().CommandName;
                var widget     = new DeviceCommand()
                {
                    Model = new DeviceCommandVM(
                        serviceProvider.ResolveSingle <IRUSDevice>(),
                        command,
                        handler,
                        serviceProvider.ResolveSingle <BusyObject>()),
                    FunctionId = new WidgetIdentity(widgetName,
                                                    serviceProvider.ResolveSingle <string>(),
                                                    activationScope)
                };

                serviceProvider.Register <IWidget>(widget);
            }
        }
コード例 #2
0
        public virtual T TryResolveSingle <T>(object scope = null) where T : class
        {
            throwIfDisposed();

            return(_base.TryResolveSingle <T>(scope));
        }