Interaction logic for TPMSelector.xaml
Inheritance: DialogWindow
Exemplo n.º 1
0
        public override Task<ConnectedServiceConfigurator> CreateConfiguratorAsync(ConnectedServiceProviderContext context)
        {
            ConnectedServiceConfigurator configurator;

            var project = GetActiveProject();
            var projectKind = new Guid(project.Kind);

            if (projectKind != CsProjectType)
            {
                // For now, only C# projects support TPM.
                configurator = new AzureIoTHubAccountProviderGrid(this.IoTHubAccountManager, this.ServiceProvider);
            }
            else
            {
                var securityMode = new TPMSelector();
                var dlgResult = securityMode.ShowModal();
                if (dlgResult.HasValue && dlgResult.Value)
                {
                    var useTPM = securityMode.rbUseTPM.IsChecked;
                    if (useTPM.HasValue && useTPM.Value)
                    {
                        // The user has chosen to use TPM
                        configurator = new ConnectedServiceSansUI(false);
                    }
                    else
                    {
                        // No TPM
                        configurator = new AzureIoTHubAccountProviderGrid(this.IoTHubAccountManager, this.ServiceProvider);
                    }
                }
                else
                {
                    // User cancelled
                    configurator = new ConnectedServiceSansUI(true);
                }
            }

            return Task.FromResult(configurator);
        }
Exemplo n.º 2
0
        public override Task <ConnectedServiceConfigurator> CreateConfiguratorAsync(ConnectedServiceProviderContext context)
        {
            ConnectedServiceConfigurator configurator;

            var project     = GetActiveProject();
            var projectKind = new Guid(project.Kind);

            if (projectKind != CsProjectType)
            {
                // For now, only C# projects support TPM.
                configurator = new AzureIoTHubAccountProviderGrid(this.IoTHubAccountManager, this.ServiceProvider);
            }
            else
            {
                var securityMode = new TPMSelector();
                var dlgResult    = securityMode.ShowModal();
                if (dlgResult.HasValue && dlgResult.Value)
                {
                    var useTPM = securityMode.rbUseTPM.IsChecked;
                    if (useTPM.HasValue && useTPM.Value)
                    {
                        // The user has chosen to use TPM
                        configurator = new ConnectedServiceSansUI(false);
                    }
                    else
                    {
                        // No TPM
                        configurator = new AzureIoTHubAccountProviderGrid(this.IoTHubAccountManager, this.ServiceProvider);
                    }
                }
                else
                {
                    // User cancelled
                    configurator = new ConnectedServiceSansUI(true);
                }
            }

            return(Task.FromResult(configurator));
        }