private static void ReadCallback(IAsyncResult asyncResult)
        {
            RequestState asyncState = (RequestState)asyncResult.AsyncState;

            try
            {
                int num = asyncState.responseStream.EndRead(asyncResult);
                if (num <= 0)
                {
                    asyncState.responseStream.Close();
                    DsmlSoapHttpConnection.WakeupRoutine(asyncState);
                }
                else
                {
                    string str  = asyncState.encoder.GetString(asyncState.bufferRead);
                    int    num1 = Math.Min(str.Length, num);
                    asyncState.responseString.Append(str, 0, num1);
                    asyncState.responseStream.BeginRead(asyncState.bufferRead, 0, 0x400, new AsyncCallback(DsmlSoapHttpConnection.ReadCallback), asyncState);
                }
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                asyncState.responseStream.Close();
                asyncState.exception = exception;
                DsmlSoapHttpConnection.WakeupRoutine(asyncState);
            }
        }
 public DsmlSoapHttpConnection(DsmlDirectoryIdentifier identifier, NetworkCredential credential) : this(identifier)
 {
     NetworkCredential      networkCredential;
     DsmlSoapHttpConnection dsmlSoapHttpConnection = this;
     if (credential != null)
     {
         networkCredential = new NetworkCredential(credential.UserName, credential.Password, credential.Domain);
     }
     else
     {
         networkCredential = null;
     }
     dsmlSoapHttpConnection.directoryCredential = networkCredential;
 }
        private static void ResponseCallback(IAsyncResult asyncResult)
        {
            RequestState asyncState = (RequestState)asyncResult.AsyncState;

            try
            {
                WebResponse webResponse = asyncState.request.EndGetResponse(asyncResult);
                asyncState.responseStream = webResponse.GetResponseStream();
                asyncState.responseStream.BeginRead(asyncState.bufferRead, 0, 0x400, new AsyncCallback(DsmlSoapHttpConnection.ReadCallback), asyncState);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (asyncState.responseStream != null)
                {
                    asyncState.responseStream.Close();
                }
                asyncState.exception = exception;
                DsmlSoapHttpConnection.WakeupRoutine(asyncState);
            }
        }
        private static void RequestStreamCallback(IAsyncResult asyncResult)
        {
            RequestState   asyncState     = (RequestState)asyncResult.AsyncState;
            HttpWebRequest httpWebRequest = asyncState.request;

            try
            {
                asyncState.requestStream = httpWebRequest.EndGetRequestStream(asyncResult);
                byte[] bytes = asyncState.encoder.GetBytes(asyncState.requestString);
                asyncState.requestStream.BeginWrite(bytes, 0, (int)bytes.Length, new AsyncCallback(DsmlSoapHttpConnection.WriteCallback), asyncState);
            }
            catch (Exception exception1)
            {
                Exception exception = exception1;
                if (asyncState.requestStream != null)
                {
                    asyncState.requestStream.Close();
                }
                asyncState.exception = exception;
                DsmlSoapHttpConnection.WakeupRoutine(asyncState);
            }
        }
        private static void WriteCallback(IAsyncResult asyncResult)
        {
            RequestState asyncState = (RequestState)asyncResult.AsyncState;

            try
            {
                try
                {
                    asyncState.requestStream.EndWrite(asyncResult);
                    asyncState.request.BeginGetResponse(new AsyncCallback(DsmlSoapHttpConnection.ResponseCallback), asyncState);
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    asyncState.exception = exception;
                    DsmlSoapHttpConnection.WakeupRoutine(asyncState);
                }
            }
            finally
            {
                asyncState.requestStream.Close();
            }
        }