Пример #1
0
        public override int Handle(StartOptions command)
        {
            var virgilHub = ServiceHub.Create(ServiceHubConfig.UseAccessToken(ApiConfig.VirgilToken));

            ServiceLocator.Setup(virgilHub);

            var eventAggregator = this.bootstrapper.Container.Resolve <IEventAggregator>();

            eventAggregator.Subscribe(new Listener());

            var appState = this.bootstrapper.Container.Resolve <ApplicationState>();

            appState.Restore();

            if (!appState.HasAccount)
            {
                Console.WriteLine("    There is no Virgil Card stored");
                return(1);
            }

            var folderSettings = this.bootstrapper.Container.Resolve <FolderSettingsStorage>();

            if (folderSettings.FolderSettings.IsEmpty())
            {
                Console.WriteLine("    There is no folder to bropbox link configured");
                return(1);
            }

            var validationErrors = folderSettings.FolderSettings.Validate();

            if (validationErrors.Any())
            {
                foreach (var validationError in validationErrors)
                {
                    Console.WriteLine("    " + validationError);
                }
                return(1);
            }

            ExceptionNotifier.Current.OnDropboxSessionExpired(() =>
            {
                eventAggregator.Publish(new DropboxSessionExpired());
                Console.WriteLine("    Dropbox session has expired");
                Environment.Exit(1);
            });

            var folderLinkFacade = this.bootstrapper.Container.Resolve <FolderLinkFacade>();

            Task.Factory.StartNew(() => folderLinkFacade.Rebuild());

            Console.WriteLine("    Virgil sync is running");

            while (true)
            {
                Console.ReadLine();
            }
        }
Пример #2
0
        /// <summary>
        /// Setups the instance of <see cref="SimpleChat"/> and runs the message loop.
        /// </summary>
        public static async Task Launch()
        {
            serviceHub = ServiceHub.Create(Constants.VirgilSimpleChatAccessToken);

            var emailAddress = Param <string> .Mandatory("Enter Email Address").WaitInput();

            var chatMember = await Authorize(emailAddress);

            var messagingClient = new IPMessagingClient(chatMember.Identity);
            var simpleChat      = new SimpleChat(messagingClient, chatMember);

            Console.WriteLine("\nWelcome to DARKSIDE chat. Feel free to post here your DARK thoughts.\n");

            await simpleChat.StartMessaging();
        }
Пример #3
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            this.DispatcherUnhandledException += this.OnDispatcherUnhandledException;

            var virgilHub = ServiceHub.Create(ServiceHubConfig.UseAccessToken(ApiConfig.VirgilToken));

            Virgil.SDK.Domain.ServiceLocator.Setup(virgilHub);

            var updater = new Updater();

            updater.Start();

            this.Bootstrapper = new Bootstrapper();
            this.Bootstrapper.Initialize();

            this.AppState = this.Bootstrapper.IoC.Get <ApplicationState>();
            this.AppState.Restore();

            this.FolderSettings = this.Bootstrapper.IoC.Get <FolderSettingsStorage>();
            this.MainWindow     = new TrayWindow
            {
                DataContext = this.Bootstrapper.IoC.Get <OperationStatusViewModel>()
            };

            ExceptionNotifier.Current.OnDropboxSessionExpired(() =>
            {
                this.Dispatcher.Invoke(() =>
                {
                    this.Bootstrapper.IoC.Get <IEventAggregator>().Publish(new DropboxSessionExpired());
                });
            });

            this.ShowUI();
        }
Пример #4
0
 /// <summary>
 /// Setups service locator to use virgil api configuration to access services.
 /// </summary>
 /// <param name="config">The configuration.</param>
 public static void Setup(ServiceHubConfig config)
 {
     services = ServiceHub.Create(config);
 }