Beispiel #1
0
 public EventsViewModel(IDispatcher dispacher, IApplicationEventBus eventBus, INavigator navigator, IPreDisplayEventViewItemStore preDisplayEventViewItemStore)
 {
     if (dispacher == null)
     {
         throw new ArgumentNullException("dispacher");
     }
     if (eventBus == null)
     {
         throw new ArgumentNullException("eventBus");
     }
     if (navigator == null)
     {
         throw new ArgumentNullException("navigator");
     }
     if (preDisplayEventViewItemStore == null)
     {
         throw new ArgumentNullException("preDisplayEventViewItemStore");
     }
     _dispacher  = dispacher;
     _eventBus   = eventBus;
     _navigator  = navigator;
     PauseResume = new RelayCommand(OnPauseResume);
     Clear       = new RelayCommand(OnClear);
     _dispacher.Background(() =>
     {
         _eventBus.Subscribe(this);
         preDisplayEventViewItemStore.Unload(this);
     });
 }
        public ResolveOperationViewModel(
            string resolveOperationId,
            IHistoricalItemStore<ResolveOperation> historicalItemStore,
            IDispatcher dispatcher)
        {
            if (resolveOperationId == null) throw new ArgumentNullException("resolveOperationId");
            if (historicalItemStore == null) throw new ArgumentNullException("historicalItemStore");

            dispatcher.Background(() =>
            {
                ResolveOperation resolveOperation;
                if (historicalItemStore.TryGetItem(resolveOperationId, out resolveOperation))
                {
                    var subOperations = Traverse.PreOrder(resolveOperation, r => r.SubOperations)
                        .Select(o => new SubResolveOperationViewModel(o))
                        .ToList();
                    
                    dispatcher.Foreground(() =>
                    {
                        foreach (var subResolveOperationViewModel in subOperations)
                            _subOperations.Add(subResolveOperationViewModel);
                    });
                }
            });
        }
        public ResolveOperationViewModel(
            string resolveOperationId,
            IHistoricalItemStore <ResolveOperation> historicalItemStore,
            IDispatcher dispatcher)
        {
            if (resolveOperationId == null)
            {
                throw new ArgumentNullException("resolveOperationId");
            }
            if (historicalItemStore == null)
            {
                throw new ArgumentNullException("historicalItemStore");
            }

            dispatcher.Background(() =>
            {
                ResolveOperation resolveOperation;
                if (historicalItemStore.TryGetItem(resolveOperationId, out resolveOperation))
                {
                    var subOperations = Traverse.PreOrder(resolveOperation, r => r.SubOperations)
                                        .Select(o => new SubResolveOperationViewModel(o))
                                        .ToList();

                    dispatcher.Foreground(() =>
                    {
                        foreach (var subResolveOperationViewModel in subOperations)
                        {
                            _subOperations.Add(subResolveOperationViewModel);
                        }
                    });
                }
            });
        }
Beispiel #4
0
        public ComponentsViewModel(
            INavigator navigator,
            IHistoricalItemStore <Component> components,
            IHistoricalItemStore <RegistrationSource> registrationSources,
            IApplicationEventBus applicationEventBus,
            IDispatcher dispatcher)
        {
            _navigator                = navigator;
            _applicationEventBus      = applicationEventBus;
            _dispatcher               = dispatcher;
            _filteredSortedComponents = new ListCollectionView(_components);
            _filteredSortedComponents.SortDescriptions.Add(new SortDescription("Description", ListSortDirection.Ascending));

            dispatcher.Background(() =>
            {
                _applicationEventBus.Subscribe(this);
                var vms = new List <object>();
                vms.AddRange(components.GetItems().Select(CreateViewModel));
                vms.AddRange(registrationSources.GetItems().Select(CreateViewModel));
                dispatcher.Foreground(() =>
                {
                    foreach (var vm in vms)
                    {
                        _components.Add(vm);
                    }
                });
            });
        }
        public ComponentDetailViewModel(string componentId, IDispatcher dispatcher, IActiveItemRepository<Component> components)
        {
            dispatcher.Background(() =>
            {
                Component component;
                if (!components.TryGetItem(componentId, out component))
                    throw new ArgumentException("Unknown component.");

                var description = component.Description;
                var services = component.DescribeServices();
                var metadata = component.Metadata;
                var sharing = component.Sharing;
                var lifetime = component.Lifetime;
                var activator = component.Activator;
                var ownership = component.Ownership;
                var target = component.TargetComponentId;
                var id = component.Id;

                dispatcher.Foreground(() =>
                {
                    Description = description;
                    Metadata = metadata;
                    Services = services;
                    Sharing = sharing.ToString();
                    Lifetime = lifetime.ToString();
                    Activator = activator.ToString();
                    Ownership = ownership.ToString();
                    Target = target;
                    Id = id;
                });
            });
        }
        public ComponentDetailViewModel(string componentId, IDispatcher dispatcher, IActiveItemRepository <Component> components)
        {
            dispatcher.Background(() =>
            {
                Component component;
                if (!components.TryGetItem(componentId, out component))
                {
                    throw new ArgumentException("Unknown component.");
                }

                var description = component.Description;
                var services    = component.DescribeServices();
                var metadata    = component.Metadata;
                var sharing     = component.Sharing;
                var lifetime    = component.Lifetime;
                var activator   = component.Activator;
                var ownership   = component.Ownership;
                var target      = component.TargetComponentId;
                var id          = component.Id;

                dispatcher.Foreground(() =>
                {
                    Description = description;
                    Metadata    = metadata;
                    Services    = services;
                    Sharing     = sharing.ToString();
                    Lifetime    = lifetime.ToString();
                    Activator   = activator.ToString();
                    Ownership   = ownership.ToString();
                    Target      = target;
                    Id          = id;
                });
            });
        }