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); } }
public virtual T TryResolveSingle <T>(object scope = null) where T : class { throwIfDisposed(); return(_base.TryResolveSingle <T>(scope)); }