Exemplo n.º 1
0
        public MetaBootstrapper(IRemoteCommandService remoteCommandService = null, ServiceIDType remoteCommandServiceID = ServiceIDType.SystemGlobal)
        {
#if DEBUG
            Catel.Logging.LogManager.AddDebugListener(false);//note: could called multimes. if debug listener already registed,it do nothing.
#endif
            if (remoteCommandService != null)
            {
                remoteCommandServiceServer = remoteCommandService;
                var serviceLocator = ServiceLocator.Default;
                serviceLocator.RegisterInstance <IRemoteCommandService>(remoteCommandServiceServer);
                var serviceController = new RemoteCommandServiceController(remoteCommandServiceServer);
                serviceController.Start(remoteCommandServiceID);
            }
            //
            // Application Themes
            //
            Log.Debug("Loading Application  Themes");
            //var ribbonType = typeof(Fluent.Ribbon);
            //Log.Debug("Loaded ribbon type '{0}'", ribbonType.Name);
            var application = Application.Current;
            application.Resources.MergedDictionaries.Add(new ResourceDictionary {
                Source = new Uri("pack://application:,,,/Fluent;component/Themes/Office2013/Generic.xaml")
            });
            //application.Resources.MergedDictionaries.Add(new ResourceDictionary
            //{
            //    Source = new Uri("pack://application:,,,/Fluent;Component/Themes/Generic.xaml", UriKind.RelativeOrAbsolute)
            //});
            //application.Resources.MergedDictionaries.Add(new ResourceDictionary
            //{
            //    Source = new Uri("pack://application:,,,/Fluent;Component/Themes/Office2010/Silver.xaml", UriKind.RelativeOrAbsolute)
            //});
            //application.Resources.MergedDictionaries.Add(new ResourceDictionary
            //{
            //    Source = new Uri("pack://application:,,,/Xceed.Wpf.AvalonDock.Themes.Aero;component/Theme.xaml", UriKind.RelativeOrAbsolute)
            //});
            application.Resources.MergedDictionaries.Add(new ResourceDictionary
            {
                Source = new Uri("pack://application:,,,/Metaseed.ShellBase;component/Themes/Generic/generic.xaml", UriKind.RelativeOrAbsolute)
            });
            AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;

            string modulesDirectory = ModulesDirectory;
            if (!Directory.Exists(modulesDirectory))
            {
                Log.Warning("Modules path '{0}' is missing, new one created", modulesDirectory);
                Directory.CreateDirectory(modulesDirectory);
            }

            CreatedShell += (sender, e) =>
            {
                //var statusBarService = ServiceLocator.Default.ResolveType<IStatusBarService>();
                //statusBarService.UpdateStatus("Ready");
            };
        }
Exemplo n.º 2
0
        public void TestRemoteCommandManager_Register_Excute_CommandPara()
        {
            var remoteCommandServiceServer = new FakeRemoteCommandServer();
            var serviceController          = new RemoteCommandServiceController(remoteCommandServiceServer);

            serviceController.Start();
            var remoteCommandService = new RemoteCommandService();

            try
            {
                remoteCommandService.Open();
                Debug.WriteLine("\n register command");
                var clientCommand = new MyClientCommand(remoteCommandService, "id", "Button",
                                                        new CommandUIData()
                {
                    Header = "text", IconURI = "icon"
                }.Serialize());
                remoteCommandService.Register(clientCommand);
                ((UI)(remoteCommandServiceServer.UIBuilder)).TestExecute();
                bool r = clientCommand.event_Exec.WaitOne(8000);
                Assert.IsTrue(r);
                clientCommand.RaiseCanExecuteChanged(null, null);
                clientCommand.RaiseCanExecuteChanged(null, null);
                var c = clientCommand.event_CanExec.WaitOne(8000);
                Assert.IsTrue(c);
                remoteCommandService.Close();
            }
            catch (TimeoutException e)
            {
                Debug.WriteLine("The service operation timed out. " + e.Message);
                remoteCommandService.Abort();
                Assert.IsTrue(false);
            }
            catch (FaultException <RemoteCommandFault> e)
            {
                Debug.WriteLine("Message: {0}, Description: {1}", e.Detail.Message, e.Detail.Description);
                remoteCommandService.Abort();
                Assert.IsTrue(false);
            }
            catch (FaultException e)
            {
                Debug.WriteLine(e.Message);
                remoteCommandService.Abort();
                Assert.IsTrue(false);
            }
            catch (CommunicationException e)
            {
                Debug.WriteLine("There was a communication problem. " + e.Message + e.StackTrace);
                remoteCommandService.Abort();
                Assert.IsTrue(false);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message + e.StackTrace);

                remoteCommandService.Abort();
                Assert.IsTrue(false);
            }
            finally
            {
                serviceController.Stop();
            }
        }