Beispiel #1
0
        private void SetWorkflows(IEnumerable <IGuidanceExtension> extensions)
        {
            // Match the untouched ViewModels
            var inmutedWorkflows = this.Workflows.Where(w => extensions.Any(f => f.GuidanceWorkflow == w.Model));

            // Remove all extension removed
            foreach (var workflow in this.Workflows.Except(inmutedWorkflows).ToArray())
            {
                workflow.CurrentNodeChanged -= this.OnCurrentNodeChanged;
                this.Workflows.Remove(workflow);
            }

            // Add all extensions added
            var addedExtensions = extensions.Where(f => !this.Workflows.Any(w => w.Model == f.GuidanceWorkflow));

            foreach (var extension in addedExtensions)
            {
                if (extension.GuidanceWorkflow != null)
                {
                    var workflow = new GuidanceWorkflowViewModel(new GuidanceWorkflowContext
                    {
                        GuidanceManager    = this.context.GuidanceManager,
                        Extension          = extension,
                        UserMessageService = this.context.UserMessageService,
                    }, this.serviceProvider);
                    this.Workflows.Add(workflow);
                    workflow.CurrentNodeChanged += this.OnCurrentNodeChanged;
                }
            }

            if (this.CurrentWorkflow != null && !extensions.Any(f => f.GuidanceWorkflow == this.CurrentWorkflow.Model))
            {
                this.CurrentWorkflow = null;
            }
        }
        public GuidanceWorkflowViewModel(GuidanceWorkflowContext context, IServiceProvider serviceProvider)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => serviceProvider, serviceProvider);

            this.context         = context;
            this.serviceProvider = serviceProvider;
            this.Extension       = context.Extension;
            Current = this;
        }
        public GuidanceWorkflowViewModel(GuidanceWorkflowContext context, IServiceProvider serviceProvider)
        {
            Guard.NotNull(() => context, context);
            Guard.NotNull(() => serviceProvider, serviceProvider);

            this.context = context;
            this.serviceProvider = serviceProvider;
            this.Extension = context.Extension;
            Current = this;
        }
        private void SetWorkflows(IEnumerable<IGuidanceExtension> extensions)
        {
            // Match the untouched ViewModels
            var inmutedWorkflows = this.Workflows.Where(w => extensions.Any(f => f.GuidanceWorkflow == w.Model));

            // Remove all extension removed
            foreach (var workflow in this.Workflows.Except(inmutedWorkflows).ToArray())
            {
                workflow.CurrentNodeChanged -= this.OnCurrentNodeChanged;
                this.Workflows.Remove(workflow);
            }

            // Add all extensions added
            var addedExtensions = extensions.Where(f => !this.Workflows.Any(w => w.Model == f.GuidanceWorkflow));
            foreach (var extension in addedExtensions)
            {
                if (extension.GuidanceWorkflow != null)
                {
                    var workflow = new GuidanceWorkflowViewModel(new GuidanceWorkflowContext
                        {
                            GuidanceManager = this.context.GuidanceManager,
                            Extension = extension,
                            UserMessageService = this.context.UserMessageService,
                        }, this.serviceProvider);
                    this.Workflows.Add(workflow);
                    workflow.CurrentNodeChanged += this.OnCurrentNodeChanged;
                }
            }

            if (this.CurrentWorkflow != null && !extensions.Any(f => f.GuidanceWorkflow == this.CurrentWorkflow.Model))
            {
                this.CurrentWorkflow = null;
            }
        }