/// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            LogRouter.Initialize();
            this.logger = LogRouter.GetClassLogger();
            this.logger.Log("Constructor: app launched");

            this.Suspending += this.OnSuspending;
            MVARegistrationHelpers.UnlockLimitedAccessFeature();

            this.CopyConfigAndAssignValues().GetAwaiter();

            var keywordRegistration = new KeywordRegistration(
                "Contoso",
                "{C0F1842F-D389-44D1-8420-A32A63B35568}",
                "1033",
                "MICROSOFT_KWSGRAPH_V1",
                "ms-appx:///MVAKeywords/Contoso.bin",
                new Version(1, 0, 0, 0),
                "ms-appx:///SDKKeywords/Contoso.table");

            this.agentSessionManager = new AgentSessionManager();

            this.dialogManager = new DialogManager <List <byte> >(
                new DirectLineSpeechDialogBackend(),
                keywordRegistration,
                new AgentAudioInputProvider(),
                this.agentSessionManager,
                new MediaPlayerDialogAudioOutputAdapter());

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton(this.dialogManager);
            serviceCollection.AddSingleton <IKeywordRegistration>(keywordRegistration);
            serviceCollection.AddSingleton(this.agentSessionManager);
            this.Services = serviceCollection.BuildServiceProvider();

            CoreApplication.Exiting += async(object sender, object args) =>
            {
                this.logger.Log($"Exiting!");
                await this.dialogManager.FinishConversationAsync();

                var session = await this.agentSessionManager.GetSessionAsync();

                session?.Dispose();
                this.logger.Log("Exited");
            };

            this.InitializeSignalDetection();
            this.InitializeComponent();
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            LogRouter.Initialize();
            this.logger = LogRouter.GetClassLogger();
            this.logger.Log("Constructor: app launched");

            Task.Run(async() => await LocalSettingsHelper.InitializeAsync()).Wait();

            this.Suspending += this.OnSuspending;
            MVARegistrationHelpers.UnlockLimitedAccessFeature();

            var keywordRegistration = new KeywordRegistration(
                new Version(1, 0, 0, 0));

            this.agentSessionManager = new AgentSessionManager();

            this.dialogManager = new DialogManager <List <byte> >(
                new DirectLineSpeechDialogBackend(),
                keywordRegistration,
                new AgentAudioInputProvider(),
                this.agentSessionManager,
                new MediaPlayerDialogAudioOutputAdapter());

            var serviceCollection = new ServiceCollection();

            serviceCollection.AddSingleton(this.dialogManager);
            serviceCollection.AddSingleton <IKeywordRegistration>(keywordRegistration);
            serviceCollection.AddSingleton(this.agentSessionManager);
            this.Services = serviceCollection.BuildServiceProvider();

            CoreApplication.Exiting += async(object sender, object args) =>
            {
                this.logger.Log($"Exiting!");
                await this.dialogManager.FinishConversationAsync();

                var session = await this.agentSessionManager.GetSessionAsync();

                session?.Dispose();
                this.logger.Log("Exited");
            };

            this.InitializeSignalDetection();
            this.InitializeComponent();
        }