Exemplo n.º 1
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(bool isStaticData, object activationScope, IDIContainer container)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new DataViewSettings()
                {
                    Model = new DataViewSetingVM(
                        container.ResolveSingle <IDataStorageVM>(activationScope),
                        container.ResolveSingle <IGraphicViewSetingVM>(activationScope),
                        #warning same issue here
                        container.ResolveAll <ICurvesExporterVM>(activationScope).ToArray()),
                    FunctionId = new WidgetIdentity("Отображение",
                                                    container.ResolveSingle <string>(),
                                                    activationScope)
                };

                if (isStaticData)
                {
                    widget.Model.ViewSetingVM.IsAutoscrollEnabled   = false;
                    widget.Model.ViewSetingVM.IsAutoscrollSupported = false; // because data from flash are static
                    widget.Model.ViewSetingVM.IsClearSupported      = false;
                }

                container.Register <IWidget>(widget);
            }
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        static IEnumerator <ResolutionStepResult> injectExporters(IDIContainer container, object scope)
        {
            while (true)
            {
                var exporters = CommonUtils.TryOrNull <ICurvesExporterVM[], ServiceIsNotYetAwailableException>(() => instantiate().ToArray());
                if (exporters == null)
                {
                    yield return(ResolutionStepResult.WAITING_FOR_SERVICE);
                }
                else
                {
                    foreach (var exporter in exporters)
                    {
                        container.Register <ICurvesExporterVM>(exporter, scope);
                    }

                    yield return(ResolutionStepResult.RESOLVED);
                }
            }

            IEnumerable <ICurvesExporterVM> instantiate()
            {
                var storage = container.ResolveSingle <IPointsStorageProvider>(scope);

                yield return(new LasCurvesExporterVM(storage));
            }
        }
Exemplo n.º 5
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(object activationScope, IDIContainer container)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new DeviceStatus()
                {
                    Model = new DeviceStatusVM(
                        container.ResolveSingle <IRUSDevice>(),
                        container.ResolveSingle <BusyObject>()),
                    FunctionId = new WidgetIdentity("Статус",
                                                    container.ResolveSingle <string>(),
                                                    activationScope)
                };

                container.Register <IWidget>(widget);
            }
        }
Exemplo n.º 6
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(string name, object activationScope, IDIContainer container)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new DataView()
                {
                    Model = new DataViewVM(
                        container.ResolveSingle <IDataStorageVM>(activationScope)),
                    FunctionId = new WidgetIdentity(name,
                                                    container.ResolveSingle <string>(),
                                                    activationScope)
                };

                container.Register <IGraphicViewSetingVM>(widget.Model.GraphicVM.Settings, activationScope);
                container.Register <IWidget>(widget);
            }
        }
Exemplo n.º 7
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(object activationScope, IDIContainer serviceProvider)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new RUSModuleSetDirection()
                {
                    Model = new RUSModuleSetDirectionVM(
                        serviceProvider.ResolveSingle <IRUSDevice>(),
                        serviceProvider.ResolveSingle <BusyObject>()),
                    FunctionId = new WidgetIdentity("Настройки бурения",
                                                    serviceProvider.ResolveSingle <string>(),
                                                    activationScope)
                };

                serviceProvider.Register <IWidget>(widget);
            }
        }
Exemplo n.º 8
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(object activationScope, IDIContainer container)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new RUSTelemetryStreamSender()
                {
                    Model = new RUSTelemetryStreamSenderVM(
                        container.ResolveSingle <IRUSDevice>(),
                        container.ResolveSingle <BusyObject>()),
                    FunctionId = new WidgetIdentity("Отправка кривой давления",
                                                    container.ResolveSingle <string>(),
                                                    activationScope)
                };

                container.Register <IDataProvider>(widget.Model);
                container.Register <IWidget>(widget);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Inspired by coroutines from Unity3D
        /// </summary>
        /// <param name="calibrator"></param>
        /// <param name="container"></param>
        /// <returns></returns>
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(ICalibrator calibrator, object activationScope, IDIContainer container)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new DeviceCalibration()
                {
                    Model = new DeviceCalibrationVM(calibrator,
                                                    container.ResolveSingle <IDeviceInitializationVM>(),
                                                    container.ResolveSingle <BusyObject>()),
                    FunctionId = new WidgetIdentity(calibrator.Model.CalibrationName,
                                                    container.ResolveSingle <string>(),
                                                    activationScope)
                };

                widget.View.Visibility = Visibility.Collapsed;

                container.Register <IWidget>(widget);
                container.Register <IDataProvider>(calibrator.Model.DataProvider);
            }
        }
Exemplo n.º 10
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(object activationScope, IDIContainer serviceProvider)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new DeviceInitialization()
                {
                    Model = new DeviceInitializationVM(
                        serviceProvider.ResolveSingle <IRUSDevice>(),
                        serviceProvider.ResolveSingle <BusyObject>(),
                        new WriteFilesByDefaultVM(
                            serviceProvider.ResolveSingle <IRUSDevice>(),
                            serviceProvider.ResolveSingle <BusyObject>())),
                    FunctionId = new WidgetIdentity("Инициализация устройства",
                                                    serviceProvider.ResolveSingle <string>(),
                                                    activationScope)
                };

                widget.Visibility = Visibility.Collapsed;
                serviceProvider.Register <IDeviceInitializationVM>(widget.Model);
                serviceProvider.Register <IWidget>(widget);
            }
        }
Exemplo n.º 11
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(object activationScope, IDIContainer container)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new FlashDumpLoad()
                {
                    Model = new FlashDumpLoadVM(
                        container.ResolveSingle <IRUSDevice>().Id,
                        container.ResolveSingle <BusyObject>()),
                    FunctionId = new WidgetIdentity("Загрузка дампа Flash",
                                                    container.ResolveSingle <string>(),
                                                    activationScope)
                };

                container.Register <IWidget>(widget);
                container.Register <IFlashDumpLoader>(widget.Model);
                container.Register <IFlashDumpDataParserFactory>(FlashDumpDataParserFactory.Instance);
                container.Register <IFlashDumpSaver>(FlashDumpSaverFactory.Instance);
                container.Register <IDataStorageVM>(widget.Model.DataStorageVM, activationScope);
                container.Register <IPointsStorageProvider>(widget.Model, activationScope);
            }
        }
Exemplo n.º 12
0
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(object activationScope, IDIContainer serviceProvider)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new FlashUploadCommand()
                {
                    Model = new FlashUploadCommandVM(
                        serviceProvider.ResolveSingle <IRUSDevice>(),
                        serviceProvider.ResolveSingle <IFlashDumpDataParserFactory>(),
                        serviceProvider.ResolveSingle <IFlashDumpSaver>(),
                        serviceProvider.ResolveSingle <IFlashDumpLoader>(),
                        serviceProvider.ResolveSingle <BusyObject>()),
                    FunctionId = new WidgetIdentity("Чтение дампа Flash",
                                                    serviceProvider.ResolveSingle <string>(),
                                                    activationScope)
                };

                //serviceProvider.Register<IWidget>(widget);
                serviceProvider.Register <ICommandHandlerWidget>(widget, Command.DOWNLOAD_FLASH);
            }
        }
Exemplo n.º 13
0
        public virtual T ResolveSingle <T>(object scope = null) where T : class
        {
            throwIfDisposed();

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