Beispiel #1
0
        private void ConfigureEndpoint(ConfiguredEndpoint endpoint)
        {
            EndpointComIdentity comIdentity = endpoint.ComIdentity;

            if (comIdentity == null)
            {
                comIdentity = new EndpointComIdentity();
                comIdentity.Specification = ComSpecification.DA;
                endpoint.ComIdentity      = comIdentity;
            }

            string oldProgId = PseudoComServer.CreateProgIdFromUrl(endpoint.ComIdentity.Specification, endpoint.EndpointUrl.ToString());

            endpoint = new ConfiguredServerDlg().ShowDialog(endpoint, m_configuration);

            if (endpoint == null)
            {
                return;
            }

            if (String.IsNullOrEmpty(comIdentity.ProgId) || oldProgId == comIdentity.ProgId)
            {
                comIdentity.ProgId = PseudoComServer.CreateProgIdFromUrl(endpoint.ComIdentity.Specification, endpoint.EndpointUrl.ToString());

                if (comIdentity.Clsid == Guid.Empty)
                {
                    comIdentity.Clsid = Guid.NewGuid();
                }
            }

            m_endpoint      = endpoint;
            EndpointTB.Text = m_endpoint.EndpointUrl.ToString();
        }
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public EndpointComIdentity ShowDialog(ConfiguredEndpoint endpoint)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }

            m_comIdentity = endpoint.ComIdentity;

            // assign a default prog id/clsid.
            if (String.IsNullOrEmpty(m_comIdentity.ProgId))
            {
                m_comIdentity.ProgId = PseudoComServer.CreateProgIdFromUrl(ComSpecification.DA, endpoint.EndpointUrl.ToString());
                m_comIdentity.Clsid  = ConfigUtils.CLSIDFromProgID(m_comIdentity.ProgId);

                if (m_comIdentity.Clsid == Guid.Empty)
                {
                    m_comIdentity.Clsid = Guid.NewGuid();
                }
            }

            SpecificationCB.SelectedItem = m_comIdentity.Specification;
            ClsidTB.Text  = m_comIdentity.Clsid.ToString();
            ProgIdTB.Text = m_comIdentity.ProgId;

            if (ShowDialog() != DialogResult.OK)
            {
                return(null);
            }

            return(m_comIdentity);
        }
Beispiel #3
0
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public EndpointComIdentity ShowDialog(ConfiguredEndpoint endpoint)
        {
            if (endpoint == null) throw new ArgumentNullException("endpoint");

            m_comIdentity = endpoint.ComIdentity;

            // assign a default prog id/clsid.
            if (String.IsNullOrEmpty(m_comIdentity.ProgId))
            {
                m_comIdentity.ProgId = PseudoComServer.CreateProgIdFromUrl(ComSpecification.DA, endpoint.EndpointUrl.ToString());
                m_comIdentity.Clsid = ConfigUtils.CLSIDFromProgID(m_comIdentity.ProgId);

                if (m_comIdentity.Clsid == Guid.Empty)
                {
                    m_comIdentity.Clsid = Guid.NewGuid();
                }
            }

            SpecificationCB.SelectedItem = m_comIdentity.Specification;
            ClsidTB.Text  = m_comIdentity.Clsid.ToString();
            ProgIdTB.Text = m_comIdentity.ProgId;

            if (ShowDialog() != DialogResult.OK)
            {
                return null;
            }
                        
            return m_comIdentity;      
        }
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public ConfiguredEndpoint ShowDialog(ConfiguredEndpoint endpoint, ApplicationConfiguration configuration)
        {
            if (endpoint == null) throw new ArgumentNullException("endpoint");

            m_endpoint = endpoint;
            m_configuration = configuration;

            // construct a list of available endpoint descriptions for the application.
            m_availableEndpoints = new EndpointDescriptionCollection();
            m_availableEndpointsDescriptions = new List<EndpointDescriptionString>();

            m_availableEndpoints.Add(endpoint.Description);
            m_currentDescription = endpoint.Description;
            m_endpointConfiguration = endpoint.Configuration;

            if (m_endpointConfiguration == null)
            {
                m_endpointConfiguration = EndpointConfiguration.Create(configuration);
            }

            if (endpoint.Collection != null)
            {
                foreach (ConfiguredEndpoint existingEndpoint in endpoint.Collection.Endpoints)
                {
                    if (existingEndpoint.Description.Server.ApplicationUri == endpoint.Description.Server.ApplicationUri)
                    {
                        m_availableEndpoints.Add(existingEndpoint.Description);
                    }
                }
            }

            BuildEndpointDescriptionStrings(m_availableEndpoints);

            UserTokenPolicy policy = m_endpoint.SelectedUserTokenPolicy;

            if (policy == null)
            {
                if (m_endpoint.Description.UserIdentityTokens.Count > 0)
                {
                    policy = m_endpoint.Description.UserIdentityTokens[0];
                }
            }

            if (policy != null)
            {
                UserTokenItem userTokenItem = new UserTokenItem(policy);

                if (policy.TokenType == UserTokenType.UserName && m_endpoint.UserIdentity is UserNameIdentityToken)
                {
                    m_userIdentities[userTokenItem.ToString()] = m_endpoint.UserIdentity;
                }

                if (policy.TokenType == UserTokenType.Certificate && m_endpoint.UserIdentity is X509IdentityToken)
                {
                    m_userIdentities[userTokenItem.ToString()] = m_endpoint.UserIdentity;
                }

                if (policy.TokenType == UserTokenType.IssuedToken && m_endpoint.UserIdentity is IssuedIdentityToken)
                {
                    m_userIdentities[userTokenItem.ToString()] = m_endpoint.UserIdentity;
                }
            }

            // copy com identity.
            m_comIdentity = endpoint.ComIdentity;

            // initializing the protocol will trigger an update to all other controls.
            InitializeProtocols(m_availableEndpoints);

            // check if the current settings match the defaults.
            EndpointConfiguration defaultConfiguration = EndpointConfiguration.Create(configuration);

            // discover endpoints in the background.
            Interlocked.Increment(ref m_discoverCount);
            ThreadPool.QueueUserWorkItem(new WaitCallback(OnDiscoverEndpoints), m_endpoint.Description.Server);

            if (ShowDialog() != DialogResult.OK)
            {
                return null;
            }

            return m_endpoint;
        }
        private void ConfigureEndpoint(ConfiguredEndpoint endpoint)
        {
            EndpointComIdentity comIdentity = endpoint.ComIdentity;

            if (comIdentity == null)
            {
                comIdentity = new EndpointComIdentity();
                comIdentity.Specification = ComSpecification.DA;
                endpoint.ComIdentity = comIdentity;
            }

            string oldProgId = PseudoComServer.CreateProgIdFromUrl(endpoint.ComIdentity.Specification, endpoint.EndpointUrl.ToString());

            endpoint = new ConfiguredServerDlg().ShowDialog(endpoint, m_configuration);

            if (endpoint == null)
            {
                return;
            }

            if (String.IsNullOrEmpty(comIdentity.ProgId) || oldProgId == comIdentity.ProgId)
            {
                comIdentity.ProgId = PseudoComServer.CreateProgIdFromUrl(endpoint.ComIdentity.Specification, endpoint.EndpointUrl.ToString());

                if (comIdentity.Clsid == Guid.Empty)
                {
                    comIdentity.Clsid = Guid.NewGuid();
                }
            }

            m_endpoint = endpoint;
            EndpointTB.Text = m_endpoint.EndpointUrl.ToString();
        }
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public ConfiguredEndpoint ShowDialog(ConfiguredEndpoint endpoint, ApplicationConfiguration configuration)
        {
            if (endpoint == null)
            {
                throw new ArgumentNullException("endpoint");
            }

            m_endpoint      = endpoint;
            m_configuration = configuration;

            // construct a list of available endpoint descriptions for the application.
            m_availableEndpoints = new EndpointDescriptionCollection();

            m_availableEndpoints.Add(endpoint.Description);
            m_currentDescription    = endpoint.Description;
            m_endpointConfiguration = endpoint.Configuration;

            if (m_endpointConfiguration == null)
            {
                m_endpointConfiguration = EndpointConfiguration.Create(configuration);
            }

            if (endpoint.Collection != null)
            {
                foreach (ConfiguredEndpoint existingEndpoint in endpoint.Collection.Endpoints)
                {
                    if (existingEndpoint.Description.Server.ApplicationUri == endpoint.Description.Server.ApplicationUri)
                    {
                        m_availableEndpoints.Add(existingEndpoint.Description);
                    }
                }
            }

            // copy user identity.
            if (endpoint.UserIdentity != null)
            {
                UserTokenType tokenType = UserTokenType.Anonymous;

                if (endpoint.UserIdentity is UserNameIdentityToken)
                {
                    tokenType = UserTokenType.UserName;
                }
                else if (endpoint.UserIdentity is X509IdentityToken)
                {
                    tokenType = UserTokenType.Certificate;
                }
                else if (endpoint.UserIdentity is IssuedIdentityToken)
                {
                    tokenType = UserTokenType.IssuedToken;
                }

                m_userIdentities[tokenType] = endpoint.UserIdentity;
            }

            // copy com identity.
            m_comIdentity = endpoint.ComIdentity;

            // initializing the protocol will trigger an update to all other controls.
            InitializeProtocols(m_availableEndpoints);

            // check if the current settings match the defaults.
            EndpointConfiguration defaultConfiguration = EndpointConfiguration.Create(configuration);

            if (SameAsDefaults(defaultConfiguration, m_endpoint.Configuration))
            {
                UseDefaultLimitsCB.SelectedItem = UseDefaultLimits.Yes;
            }
            else
            {
                UseDefaultLimitsCB.SelectedItem = UseDefaultLimits.No;
            }

            // discover endpoints in the background.
            Interlocked.Increment(ref m_discoverCount);
            ThreadPool.QueueUserWorkItem(new WaitCallback(OnDiscoverEndpoints), m_endpoint.Description.Server);

            if (ShowDialog() != DialogResult.OK)
            {
                return(null);
            }

            return(m_endpoint);
        }
        /// <summary>
        /// Displays the dialog.
        /// </summary>
        public async Task<ConfiguredEndpoint> ShowDialog(ConfiguredEndpoint endpoint, ApplicationConfiguration configuration)
        {
            if (endpoint == null) throw new ArgumentNullException("endpoint");

            m_endpoint = endpoint;
            m_configuration = configuration;

            // construct a list of available endpoint descriptions for the application.
            m_availableEndpoints = new EndpointDescriptionCollection();

            m_availableEndpoints.Add(endpoint.Description);
            m_currentDescription = endpoint.Description;
            m_endpointConfiguration = endpoint.Configuration;

            if (m_endpointConfiguration == null)
            {
                m_endpointConfiguration = EndpointConfiguration.Create(configuration);
            }

            if (endpoint.Collection != null)
            {
                foreach (ConfiguredEndpoint existingEndpoint in endpoint.Collection.Endpoints)
                {
                    if (existingEndpoint.Description.Server.ApplicationUri == endpoint.Description.Server.ApplicationUri)
                    {
                        m_availableEndpoints.Add(existingEndpoint.Description);
                    }
                }
            }

            UserTokenPolicy policy = m_endpoint.SelectedUserTokenPolicy;

            if (policy == null)
            {
                if (m_endpoint.Description.UserIdentityTokens.Count > 0)
                {
                    policy = m_endpoint.Description.UserIdentityTokens[0];
                }
            }

            if (policy != null)
            {
                UserTokenItem userTokenItem = new UserTokenItem(policy);

                if (policy.TokenType == UserTokenType.UserName && m_endpoint.UserIdentity is UserNameIdentityToken)
                {
                    m_userIdentities[userTokenItem.ToString()] = m_endpoint.UserIdentity;
                }

                if (policy.TokenType == UserTokenType.Certificate && m_endpoint.UserIdentity is X509IdentityToken)
                {
                    m_userIdentities[userTokenItem.ToString()] = m_endpoint.UserIdentity;
                }

                if (policy.TokenType == UserTokenType.IssuedToken && m_endpoint.UserIdentity is IssuedIdentityToken)
                {
                    m_userIdentities[userTokenItem.ToString()] = m_endpoint.UserIdentity;
                }

                UserTokenTypeCB.Items.Add(userTokenItem);
                UserTokenTypeCB.SelectedIndex = UserTokenTypeCB.Items.IndexOf(userTokenItem);
            }

            // copy com identity.
            m_comIdentity = endpoint.ComIdentity;

            // initializing the protocol will trigger an update to all other controls.
            InitializeProtocols(m_availableEndpoints);

            // check if the current settings match the defaults.
            EndpointConfiguration defaultConfiguration = EndpointConfiguration.Create(configuration);

            if (SameAsDefaults(defaultConfiguration, m_endpoint.Configuration))
            {
                UseDefaultLimitsCB.SelectedIndex = (int)UseDefaultLimits.Yes;
            }
            else
            {
                UseDefaultLimitsCB.SelectedIndex = (int)UseDefaultLimits.No;
            }

            // discover endpoints in the background.
            Interlocked.Increment(ref m_discoverCount);
            OnDiscoverEndpoints(m_endpoint.Description.Server);

            TaskCompletionSource<ConfiguredEndpoint> tcs = new TaskCompletionSource<ConfiguredEndpoint>();
            // display dialog
            dialogPopup.Child = this;
            dialogPopup.IsOpen = true;
            dialogPopup.Closed += (o, e) =>
            {
                tcs.SetResult(m_endpoint);
            };
            return await tcs.Task;
        }