Example #1
0
        private void AddTokens(StackPanel Details, ProvisioningClient Client, string[] Tokens, RoutedEventHandler OnYes, RoutedEventHandler OnNo, OperationRange Range)
        {
            if (Tokens != null)
            {
                X509Certificate2 Certificate;

                foreach (string Token in Tokens)
                {
                    lock (this.certificates)
                    {
                        if (!this.certificates.TryGetValue(Token, out Certificate))
                        {
                            Certificate = null;
                        }
                    }

                    if (Certificate != null)
                    {
                        this.AddToken(Details, Token, Certificate, OnYes, OnNo, Range);
                    }
                    else
                    {
                        Client.GetCertificate(Token, (sender, e) =>
                        {
                            if (e.Ok)
                            {
                                string Token2 = (string)e.State;

                                lock (this.certificates)
                                {
                                    this.certificates[Token2] = e.Certificate;
                                }

                                MainWindow.UpdateGui(() =>
                                {
                                    this.AddToken(Details, Token2, e.Certificate, OnYes, OnNo, Range);
                                });
                            }

                            return(Task.CompletedTask);
                        }, Token);
                    }
                }
            }
        }
Example #2
0
        private void AddTokens(StackPanel Details, ProvisioningClient Client, string[] Tokens, RoutedEventHandler OnYes, RoutedEventHandler OnNo, OperationRange Range)
        {
            if (Tokens != null)
            {
                X509Certificate2 Certificate;

                foreach (string Token in Tokens)
                {
                    lock (this.certificates)
                    {
                        if (!this.certificates.TryGetValue(Token, out Certificate))
                        {
                            Certificate = null;
                        }
                    }

                    if (Certificate != null)
                    {
                        this.AddToken(Details, Token, Certificate, OnYes, OnNo, Range);
                    }
                    else
                    {
                        Client.GetCertificate(Token, (sender, e) =>
                        {
                            if (e.Ok)
                            {
                                string Token2 = (string)e.State;

                                lock (this.certificates)
                                {
                                    this.certificates[Token2] = e.Certificate;
                                }

                                MainWindow.currentInstance.Dispatcher.BeginInvoke(new ThreadStart(() =>
                                {
                                    this.AddToken(Details, Token2, e.Certificate, OnYes, OnNo, Range);
                                }));
                            }
                        }, Token);
                    }
                }
            }
        }