public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state)
 {
     if (request == null)
     {
         throw new ArgumentNullException("request");
     }
     HttpWebRequest dsmlConnection = (HttpWebRequest) WebRequest.Create(((DsmlDirectoryIdentifier) base.directoryIdentifier).ServerUri);
     this.PrepareHttpWebRequest(dsmlConnection);
     StringBuilder buffer = new StringBuilder(0x400);
     this.BeginSOAPRequest(ref buffer);
     buffer.Append(request.ToXml().InnerXml);
     this.EndSOAPRequest(ref buffer);
     RequestState state2 = new RequestState {
         request = dsmlConnection,
         requestString = buffer.ToString()
     };
     DsmlAsyncResult key = new DsmlAsyncResult(callback, state) {
         resultObject = state2
     };
     if (request.Count > 0)
     {
         key.hasValidRequest = true;
     }
     state2.dsmlAsync = key;
     this.httpConnectionTable.Add(key, dsmlConnection);
     dsmlConnection.BeginGetRequestStream(new AsyncCallback(DsmlSoapHttpConnection.RequestStreamCallback), state2);
     return key;
 }
 private static void WakeupRoutine(RequestState rs)
 {
     rs.dsmlAsync.manualResetEvent.Set();
     rs.dsmlAsync.completed = true;
     if ((rs.dsmlAsync.callback != null) && !rs.abortCalled)
     {
         rs.dsmlAsync.callback(rs.dsmlAsync);
     }
 }
Example #3
0
        public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state)
        {
            if (request == null)
                throw new ArgumentNullException("request");

            // construct the new httpwebrequest object
            HttpWebRequest asyncConnection = (HttpWebRequest)WebRequest.Create(((DsmlDirectoryIdentifier)directoryIdentifier).ServerUri);
            // Do the generic preparation of the request
            PrepareHttpWebRequest(asyncConnection);

            // construct the request string
            StringBuilder requestStringBuffer = new StringBuilder(1024);
            // Begin the SOAP Envelope, attaching the sessionID if applicable
            BeginSOAPRequest(ref requestStringBuffer);
            // append the document
            requestStringBuffer.Append(request.ToXml().InnerXml);
            // Finish writing the SOAP Envelope
            EndSOAPRequest(ref requestStringBuffer);

            // construct the state object
            RequestState rs = new RequestState();
            rs.request = asyncConnection;
            rs.requestString = requestStringBuffer.ToString();

            // construct the async object
            DsmlAsyncResult asyncResult = new DsmlAsyncResult(callback, state);
            asyncResult.resultObject = rs;
            // give hint about whether this is an empty request or not so later we could validate the response
            if (request.Count > 0)
                asyncResult.hasValidRequest = true;

            // result object needs to have a handle on the waitobject, so later it could wake up the EndSendRequest call
            rs.dsmlAsync = asyncResult;

            // add connection-async pair to our table
            _httpConnectionTable.Add(asyncResult, asyncConnection);

            // begin the requeststream call
            asyncConnection.BeginGetRequestStream(new AsyncCallback(RequestStreamCallback), rs);

            // return the asyncResult
            return (IAsyncResult)asyncResult;
        }
Example #4
0
 private static void WakeupRoutine(RequestState rs)
 {
     // signal waitable object, indicate operation completed and fire callback
     rs.dsmlAsync.manualResetEvent.Set();
     rs.dsmlAsync.completed = true;
     if (rs.dsmlAsync.callback != null && !rs.abortCalled)
     {
         rs.dsmlAsync.callback((IAsyncResult)rs.dsmlAsync);
     }
 }
Example #5
0
		public IAsyncResult BeginSendRequest(DsmlRequestDocument request, AsyncCallback callback, object state)
		{
			if (request != null)
			{
				HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(((DsmlDirectoryIdentifier)this.directoryIdentifier).ServerUri);
				this.PrepareHttpWebRequest(httpWebRequest);
				StringBuilder stringBuilder = new StringBuilder(0x400);
				this.BeginSOAPRequest(ref stringBuilder);
				stringBuilder.Append(request.ToXml().InnerXml);
				this.EndSOAPRequest(ref stringBuilder);
				RequestState requestState = new RequestState();
				requestState.request = httpWebRequest;
				requestState.requestString = stringBuilder.ToString();
				DsmlAsyncResult dsmlAsyncResult = new DsmlAsyncResult(callback, state);
				dsmlAsyncResult.resultObject = requestState;
				if (request.Count > 0)
				{
					dsmlAsyncResult.hasValidRequest = true;
				}
				requestState.dsmlAsync = dsmlAsyncResult;
				this.httpConnectionTable.Add(dsmlAsyncResult, httpWebRequest);
				httpWebRequest.BeginGetRequestStream(new AsyncCallback(DsmlSoapHttpConnection.RequestStreamCallback), requestState);
				return dsmlAsyncResult;
			}
			else
			{
				throw new ArgumentNullException("request");
			}
		}