コード例 #1
0
        void OnServiceBusLogOn(object sender, EventArgs e)
        {
            string serviceNamespace = "";

            if (IsServiceBusAddress(m_MexAddressTextBox.Text))
            {
                serviceNamespace = ServiceBusHelper.ExtractNamespace(new Uri(m_MexAddressTextBox.Text));
            }

LOGIN:
            LogonDialog dialog = new LogonDialog(serviceNamespace, ServiceBusHelper.DefaultIssuer);

            dialog.ShowDialog();

            if (IsServiceBusAddress(m_MexAddressTextBox.Text) == false)
            {
                try
                {
                    m_MexAddressTextBox.Text = ServiceBusEnvironment.CreateServiceUri("sb", dialog.ServiceNamespace, "").AbsoluteUri;
                }
                catch
                {
                    System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Invalid service namespace", "MEX Explorer", System.Windows.Forms.MessageBoxButtons.RetryCancel, System.Windows.Forms.MessageBoxIcon.Error);
                    if (result == System.Windows.Forms.DialogResult.Retry)
                    {
                        goto LOGIN;
                    }
                    else
                    {
                        return;
                    }
                }
            }


            TransportClientEndpointBehavior credentials = new TransportClientEndpointBehavior();

            credentials.CredentialType = TransportClientCredentialType.SharedSecret;
            credentials.Credentials.SharedSecret.IssuerName   = dialog.Issuer;
            credentials.Credentials.SharedSecret.IssuerSecret = dialog.Secret;

            m_NamespaceCredentials[dialog.ServiceNamespace] = credentials;
        }
コード例 #2
0
      void OnServiceBusLogOn(object sender,EventArgs e)
      {
         string serviceNamespace = "";

         if(IsServiceBusAddress(m_MexAddressTextBox.Text))
         {
            serviceNamespace = ServiceBusHelper.ExtractNamespace(new Uri(m_MexAddressTextBox.Text));
         }

         LOGIN:
         LogonDialog dialog = new LogonDialog(serviceNamespace,ServiceBusHelper.DefaultIssuer);
         dialog.ShowDialog();

         if(IsServiceBusAddress(m_MexAddressTextBox.Text) == false)
         {
            try
            {
               m_MexAddressTextBox.Text = ServiceBusEnvironment.CreateServiceUri("sb",dialog.ServiceNamespace,"").AbsoluteUri;
            }
            catch
            {
               System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Invalid service namespace","MEX Explorer",System.Windows.Forms.MessageBoxButtons.RetryCancel,System.Windows.Forms.MessageBoxIcon.Error);
               if(result == System.Windows.Forms.DialogResult.Retry)
               {
                  goto LOGIN;
               }
               else
               {
                  return;
               }
            }
         }


         TransportClientEndpointBehavior credentials = new TransportClientEndpointBehavior();
         credentials.TokenProvider = TokenProvider.CreateSharedSecretTokenProvider(dialog.Issuer,dialog.Secret);

         m_NamespaceCredentials[dialog.ServiceNamespace] = credentials.TokenProvider;         
      }