Пример #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");
            };
        }
Пример #2
0
        public RemoteCommandService(ServiceIDType serviceIDType, RemoteCommandServiceCallback callback)
            : base(new InstanceContext(callback), new ServiceEndpoint(ContractDescription.GetContract(typeof(IRemoteCommandService)),
                                                                      new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/" + GenerateServiceID(serviceIDType) + "/IRemoteCommandService")))
        {
            commandManager = new RemoteCommandManager(this);
            callback.RemoteCommandService = this;
            var timeout = TimeSpan.MaxValue;//new TimeSpan(0,10,0);

            this.Endpoint.Binding.SendTimeout    = timeout;
            this.Endpoint.Binding.ReceiveTimeout = timeout;
            this.Endpoint.Binding.OpenTimeout    = timeout;
            this.Endpoint.Binding.ReceiveTimeout = timeout;
        }
Пример #3
0
        static string GenerateServiceID(ServiceIDType serviceIDType)
        {
            var args = Environment.GetCommandLineArgs();
            var pre  = "-remoteCommandServiceID=";

            foreach (var arg in args)
            {
                if (arg.Contains(pre))
                {
                    var start            = arg.IndexOf(pre) + pre.Length;
                    var commandServiceID = arg.Substring(start);
                    return(commandServiceID);
                }
            }
            if (serviceIDType != ServiceIDType.SystemGlobal)
            {
                var processName = System.IO.Path.GetFileName(System.Windows.Forms.Application.ExecutablePath);
                MessageBox.Show("Could not find -remoteCommandServiceID process argument in process: " + processName, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return("default");
        }
        public IRemoteCommandService Start(ServiceIDType serviceType = ServiceIDType.SystemGlobal)
        {
            string serviceID;

            switch (serviceType)
            {
            case ServiceIDType.SingleAppInstance:
                serviceID = System.IO.Path.GetFileName(System.Windows.Forms.Application.ExecutablePath);
                break;

            case ServiceIDType.MultiAppInstance:
                serviceID = System.IO.Path.GetFileName(System.Windows.Forms.Application.ExecutablePath) + "/" + Guid.NewGuid().ToString();
                break;

            case ServiceIDType.SystemGlobal:
            default:
                serviceID = "default";
                break;
            }
            serviceID = serviceID.Trim();
            RemoteCommandService_Server.ServiceID = serviceID;
            serviceHost = new ServiceHost(_commandServiceSingleton, new Uri[] { new Uri("net.pipe://localhost/" + serviceID + "/IRemoteCommandService") });
            var timeout = TimeSpan.MaxValue;/*new TimeSpan(0,10,0)*/

            serviceHost.AddServiceEndpoint(typeof(IRemoteCommandService), new NetNamedPipeBinding()
            {
                SendTimeout    = timeout,
                ReceiveTimeout = timeout,
                OpenTimeout    = timeout,
                CloseTimeout   = timeout
            }, "");
            serviceHost.Open();
            foreach (var serviceEndpoint in serviceHost.Description.Endpoints)
            {
                Debug.WriteLine(serviceEndpoint.ListenUri.AbsoluteUri);
            }
            return(_commandServiceSingleton);
        }
Пример #5
0
 public RemoteCommandService(ServiceIDType serviceIDType = ServiceIDType.SystemGlobal)
     : this(serviceIDType, new RemoteCommandServiceCallback())
 {
 }
Пример #6
0
 public MetaBootstrapper(IRemoteCommandUIBuilder uiBuilder    = null,
                         ServiceIDType remoteCommandServiceID = ServiceIDType.SystemGlobal) : this(new RibbonRemoteCommandServer(uiBuilder), remoteCommandServiceID)
 {
 }