示例#1
0
        /// <summary>
        /// Closes the proxy used for test contract with the StackHashService.
        /// </summary>

        private void closeTestServiceProxy()
        {
            if (m_StackHashTestClient != null)
            {
                if (m_StackHashTestClient.State == CommunicationState.Faulted)
                {
                    m_StackHashTestClient.Abort();
                }
                else if (m_StackHashTestClient.State == CommunicationState.Opened)
                {
                    m_StackHashTestClient.Close();
                }
                m_StackHashTestClient = null;
            }
        }
示例#2
0
        /// <summary>
        /// Creates a proxy for communicating with the StackHash service Cab contract.
        /// The proxy is only created once. Trying to call more than once will have no
        /// additionaly effect. If the service is faulted then call CloseServiceProxy
        /// and then call this function again.
        /// A proxy is faulted if...
        /// Proxy.State == System.ServiceModel.CommunicationState.Faulted.
        /// </summary>

        private void openTestServiceProxy()
        {
            if (m_StackHashTestClient == null)
            {
                // create custom endpoint address in code - based on input in the textbox
                EndpointIdentity identity = EndpointIdentity.CreateSpnIdentity(m_ServicePrincipalName);
                EndpointAddress  epa      = new EndpointAddress(new Uri(m_ServiceEndpoint + "Test"), identity);

                m_StackHashTestClient = new StackHashServices.TestContractClient("NetTcpBinding_ITestContract", epa);
                m_StackHashTestClient.InnerChannel.OperationTimeout = new TimeSpan(1, 0, 0);

                //IContextChannel contextProxy = m_StackHashTestClient as IContextChannel;
                //contextProxy.OperationTimeout = new TimeSpan(1, 0, 0); // Might take an hour to create a very large index.
            }
            else
            {
                if (m_StackHashTestClient.State != CommunicationState.Opened)
                {
                    closeTestServiceProxy();
                    openTestServiceProxy();
                }
            }
        }