ToString() public method

Returns a System.String that represents this instance.
public ToString ( ) : string
return string
示例#1
0
        /// <summary>
        /// Setups the trust relationship between two applications.
        /// </summary>
        /// <param name="application1">The application1.</param>
        /// <param name="application2">The application2.</param>
        private bool SetupTrustRelationship(ManagedApplication application1, ManagedApplication application2)
        {
            X509Certificate2 certificate1 = application1.Certificate.Find();

            if (certificate1 == null)
            {
                MessageBox.Show(application1.ToString() + " does not have a certificate defined.", "Setup Trust Relationship", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            X509Certificate2 certificate2 = application2.Certificate.Find();

            if (certificate2 == null)
            {
                MessageBox.Show(application2.ToString() + " does not have a certificate defined.", "Setup Trust Relationship", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return false;
            }

            if (application1.TrustList != null)
            {
                ICertificateStore store = application1.TrustList.OpenStore();

                try
                {
                    if (store.FindByThumbprint(certificate2.Thumbprint) == null)
                    {
                        store.Add(new X509Certificate2(certificate2.RawData));
                    }
                }
                finally
                {
                    store.Close();
                }
            }

            if (application2.TrustList != null)
            {
                ICertificateStore store = application2.TrustList.OpenStore();

                try
                {
                    if (store.FindByThumbprint(certificate1.Thumbprint) == null)
                    {
                        store.Add(new X509Certificate2(certificate1.RawData));
                    }
                }
                finally
                {
                    store.Close();
                }
            }

            return true;
        }