Esempio n. 1
0
 public MockProxyService()
 {
     this.proxys = new List <ITracingSystemProxy> {
         new FakeProxy()
     };
     this.activeProxy = this.proxys.First();
 }
Esempio n. 2
0
        protected TestClassBase()
        {
            if (File.Exists(SettingDocumentType.FilePath))
            {
                File.Delete(SettingDocumentType.FilePath);
            }

            AggregateCatalog catalog = new AggregateCatalog();

            catalog.Catalogs.Add(new TypeCatalog(
                                     typeof(TFSProxy), typeof(TFSHelper)
                                     ));
            catalog.Catalogs.Add(new TypeCatalog(
                                     typeof(MockMessageService),
                                     typeof(MockTFSSettingView), typeof(MockUriHelpView)
                                     ));
            container = new CompositionContainer(catalog);
            CompositionBatch batch = new CompositionBatch();

            batch.AddExportedValue(container);
            container.Compose(batch);

            ITracingSystemProxy proxy = container.GetExportedValue <ITracingSystemProxy>();

            proxy.Initialize();
        }
Esempio n. 3
0
        public SettingDialogViewModel(ISettingDialogView view, IProxyService proxyService, IMessageService messageService, SettingsViewModel settingsViewModel)
            : base(view)
        {
            this.proxyService      = proxyService;
            this.settingsViewModel = settingsViewModel;
            this.messageService    = messageService;

            this.submitCommand = new DelegateCommand(SubmitSettingCommand, CanSubmitSetting);
            this.cancelCommand = new DelegateCommand(() => Close(false));

            this.views = new ObservableCollection <object>();
            this.views.Add(this.settingsViewModel.View);
            if (this.proxyService.ActiveProxy != null)
            {
                var settingView = this.proxyService.ActiveProxy.InitializeSettingDialog();
                if (settingView != null)
                {
                    this.views.Add(settingView);
                }
            }
            SelectView = this.settingsViewModel.View;

            AddWeakEventListener(this.settingsViewModel, SettingsViewModelPropertyChanged);

            if (!string.IsNullOrWhiteSpace(this.settingsViewModel.ActiveProxy))
            {
                this.settingActiveProxy = this.proxyService.Proxies.First(x => x.ProxyName == settingsViewModel.ActiveProxy);
            }
            if (this.settingActiveProxy != null)
            {
                AddWeakEventListener(this.settingActiveProxy, ActiveProxyPropertyChanged);
                AddWeakEventListener(this.settingActiveProxy.StateValues, StateValuesCollectionChanged);
                StateValuesCollectionChanged(null, null);
            }
        }
Esempio n. 4
0
        private void SettingsViewModelPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            this.SettingDialogStatus = SettingDialogStatus.NotWorking;

            if (e.PropertyName == "ActiveProxy")
            {
                var newActiveProxy = this.proxyService.Proxies.First(x => x.ProxyName == settingsViewModel.ActiveProxy);
                if (newActiveProxy == null)
                {
                    return;
                }

                this.SettingDialogStatus = SettingDialogStatus.InitiatingProxy;
                UpdateCommands();

                var InitializationTask = Task.Factory.StartNew(() =>
                {
                    newActiveProxy.Initialize();
                });

                InitializationTask.ContinueWith(task =>
                {
                    this.SettingDialogStatus = SettingDialogStatus.InitiatingProxyFailed;
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnFaulted, TaskScheduler.FromCurrentSynchronizationContext());

                InitializationTask.ContinueWith(task =>
                {
                    if (this.settingActiveProxy != null)
                    {
                        RemoveWeakEventListener(this.settingActiveProxy, ActiveProxyPropertyChanged);
                        RemoveWeakEventListener(this.settingActiveProxy.StateValues, StateValuesCollectionChanged);

                        var settingView = this.settingActiveProxy.InitializeSettingDialog();
                        if (settingView != null)
                        {
                            this.views.Remove(settingView);
                        }
                    }

                    this.settingActiveProxy = newActiveProxy;
                    StateValuesCollectionChanged(null, null);

                    if (this.settingActiveProxy != null)
                    {
                        AddWeakEventListener(this.settingActiveProxy, ActiveProxyPropertyChanged);
                        AddWeakEventListener(this.settingActiveProxy.StateValues, StateValuesCollectionChanged);
                        var settingView = this.settingActiveProxy.InitializeSettingDialog();
                        if (settingView != null)
                        {
                            this.views.Add(settingView);
                        }
                    }
                    this.SettingDialogStatus = SettingDialogStatus.NotWorking;
                }, CancellationToken.None, TaskContinuationOptions.OnlyOnRanToCompletion, TaskScheduler.FromCurrentSynchronizationContext());
            }

            UpdateCommands();
        }
Esempio n. 5
0
 public MockProxyService()
 {
     this.proxys = new List<ITracingSystemProxy> { new FakeProxy() };
     this.activeProxy = this.proxys.First();
 }