public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(object activationScope, IDIContainer container) { // Hack to allow IDataProvider to resolve on time // (we allow other widgets to be resolved and register the dependency required, while this one is in waiting state) return(ResolutionStepResult.WAITING_FOR_SERVICE .Repeat(1) // skip specified amount of steps .Concat(Helpers.CoroutineEnumerable(instantiate)) .GetEnumerator()); void instantiate() { var dr = new DeviceDataRequestVM( container.ResolveSingle <IRUSDevice>(), container.ResolveSingle <BusyObject>(), #warning will not return all providers if at the time of resolving not all of them were registered container.TryResolveAll <IDataProvider>()?.ToArray() ?? new IDataProvider[0]); var widget = new DataRequest() { Model = new DataRequestVM(container.ResolveSingle <IRUSDevice>(), dr, new DeviceDataAutorequestVM(dr.GetDataRequest, container.ResolveSingle <BusyObject>())), FunctionId = new WidgetIdentity("Опрос", container.ResolveSingle <string>(), activationScope) }; container.Register <IWidget>(widget); container.Register <IDeviceHandler>(widget.Model); container.Register <IDataStorageVM>(widget.Model.RequestVM.DeviceDataVM, activationScope); container.Register <IPointsStorageProvider>(widget.Model.RequestVM.DeviceDataVM, activationScope); } }
public DataRequestVM(IRUSDevice device, DeviceDataRequestVM requestVM, DeviceDataAutorequestVM autorequestVM) { _device = device; RequestVM = requestVM ?? throw new ArgumentNullException(nameof(requestVM)); AutorequestVM = autorequestVM ?? throw new ArgumentNullException(nameof(autorequestVM)); }