2003-10-22 Todd Berman <tberman@gentoo.org>
authorTodd Berman <tberman@mono-cvs.ximian.com>
Wed, 22 Oct 2003 18:15:35 +0000 (18:15 -0000)
committerTodd Berman <tberman@mono-cvs.ximian.com>
Wed, 22 Oct 2003 18:15:35 +0000 (18:15 -0000)
        * SoapContext.cs: Added Addressing objects, SetActor, SetTo,
        Processed, SetIsInbound and SetProcessed.
        * SoapEnvelope.cs: Added Encoding, Processed and SetProcessed and
        fixed up Save (string)
        * AsyncResult.cs: Basic Implementation for WSE2 (not for WSE1 yet).

svn path=/trunk/mcs/; revision=19308

mcs/class/Microsoft.Web.Services/Microsoft.Web.Services/AsyncResult.cs [new file with mode: 0644]
mcs/class/Microsoft.Web.Services/Microsoft.Web.Services/ChangeLog
mcs/class/Microsoft.Web.Services/Microsoft.Web.Services/SoapContext.cs
mcs/class/Microsoft.Web.Services/Microsoft.Web.Services/SoapEnvelope.cs

diff --git a/mcs/class/Microsoft.Web.Services/Microsoft.Web.Services/AsyncResult.cs b/mcs/class/Microsoft.Web.Services/Microsoft.Web.Services/AsyncResult.cs
new file mode 100644 (file)
index 0000000..9a38d80
--- /dev/null
@@ -0,0 +1,120 @@
+//
+// Microsoft.Web.Services.AsyncResult.cs
+//
+// Author: Todd Berman <tberman@gentoo.org>
+//
+// (C) 2003 Todd Berman
+
+using System;
+using System.Threading;
+
+namespace Microsoft.Web.Services
+{
+       public class AsyncResult : IAsyncResult
+       {
+               private AsyncCallback _callback;
+               private bool _completed;
+               private bool _completedSync;
+               private bool _endCalled;
+               private ManualResetEvent _event;
+               private Exception _exception;
+               private object _state;
+
+               protected AsyncResult (object s) : this (null, s)
+               {
+               }
+
+               protected AsyncResult (AsyncCallback call, object s) : base ()
+               {
+                       _callback = call;
+                       _state = s;
+               }
+
+               protected AsyncResult () : this (null, null)
+               {
+               }
+
+               protected void Complete (bool csync, Exception e)
+               {
+                       _completed = true;
+                       _completedSync = csync;
+                       _exception = e;
+
+                       if(_event != null) {
+                               _event.Set ();
+                       }
+                       try {
+                               if(_callback != null) {
+                                       _callback (this);
+                               }
+                       } catch (Exception ex) {
+                               ThreadPool.QueueUserWorkItem (new WaitCallback (ThrowException), this);
+                       }
+               }
+
+               protected void Complete (bool csync)
+               {
+                       this.Complete (csync, null);
+               }
+
+               public static void End (IAsyncResult result)
+               {
+                       if(result == null) {
+                               throw new ArgumentNullException ("result");
+                       }
+                       AsyncResult mws_result = (AsyncResult) result;
+
+                       if(mws_result == null) {
+                               throw new ArgumentException ("Invalid result");
+                       }
+
+                       if(mws_result._endCalled == true) {
+                               throw new InvalidOperationException ("Async Operation already finished");
+                       }
+
+                       mws_result._endCalled = true;
+
+                       if(mws_result._completed == true) {
+                               mws_result.AsyncWaitHandle.WaitOne ();
+                       }
+
+                       if(mws_result._exception != null) {
+                               throw mws_result._exception;
+                       }
+               }
+               
+               private void ThrowException (object o)
+               {
+                       Exception e = (Exception) o;
+                       throw e;
+               }
+
+               public object AsyncState {
+                       get { return _state; }
+               }
+
+               public WaitHandle AsyncWaitHandle {
+                       get {
+                               if(_event == null) {
+                                       bool complete = _completed;
+
+                                       lock (this) {
+                                               _event = new ManualResetEvent (_completed);
+                                       }
+                                       if(complete == true || _completed == false) {
+                                               _event.Set ();
+                                       }
+                               }
+                               return _event;
+                       }
+               }
+
+               public bool CompletedSynchronously {
+                       get { return _completedSync; }
+               }
+
+               public bool IsCompleted {
+                       get { return _completed; }
+               }
+       }
+}
index 452ee3ca26b1452b5b2b2e32fad90a66cfe2b6c3..0f9cf6c7b67c706c77470561c1450464cbdbd7d8 100755 (executable)
@@ -1,7 +1,10 @@
-2003-10-13  Todd Berman <tberman@gentoo.org>
+2003-10-22  Todd Berman <tberman@gentoo.org>
 
-       * SoapContext.cs: Added Addressing objects.
-       * SoapEnvelope.cs: Added Encoding and fixed up Save (string)
+       * SoapContext.cs: Added Addressing objects, SetActor, SetTo, 
+       Processed, SetIsInbound and SetProcessed.
+       * SoapEnvelope.cs: Added Encoding, Processed and SetProcessed and 
+       fixed up Save (string)
+       * AsyncResult.cs: Basic Implementation for WSE2 (not for WSE1 yet).
 
 2003-10-05  Sebastien Pouliot  <spouliot@videotron.ca>
 
index 1d6c97fc116371d2fb426d0ff2b5323c61433518..964085ee82835740a8c2681dfafb339eda1991a7 100644 (file)
@@ -14,6 +14,7 @@ using Microsoft.Web.Services.Security;
 using Microsoft.Web.Services.Timestamp;
 #if !WSE1
 using Microsoft.Web.Services.Addressing;
+using Microsoft.Web.Services.Messaging;
 #endif
 
 using System;
@@ -24,8 +25,12 @@ namespace Microsoft.Web.Services {
        public sealed class SoapContext {
 
                private SoapEnvelope envelope;
+#if WSE1
                private Uri actor;
-               private Microsoft.Web.Services.Timestamp.Timestamp timestamp;
+#else
+               private Uri actor = new Uri ("http://" + System.Net.Dns.GetHostName ());
+#endif
+               private Timestamp timestamp = new Timestamp ();
                private Microsoft.Web.Services.Security.Security security;
                private Hashtable table;
                private DimeAttachmentCollection attachments;
@@ -34,6 +39,9 @@ namespace Microsoft.Web.Services {
                private ReferralCollection referrals;
 #if !WSE1
                 private AddressingHeaders addressingHeaders;
+               private SoapChannel _channel;
+               private bool _processed = false;
+               private bool _isInbound = false;
 #endif
                internal SoapContext () : this (null) 
                {
@@ -96,6 +104,37 @@ namespace Microsoft.Web.Services {
                        get { return addressingHeaders.RelatesTo; }
                        set { addressingHeaders.RelatesTo = value; }
                }
+
+               public SoapChannel Channel {
+                       get { return _channel; }
+                       set { _channel = value; }
+               }
+
+               public bool Processed {
+                       get { return _processed; }
+               }
+
+               public void SetProcessed (bool to) {
+                       _processed = to;
+               }
+
+               public void SetTo (Uri uri) {
+                       addressingHeaders.To = uri;
+               }
+
+               public void SetTo (To to) {
+                       addressingHeaders.To = to;
+               }
+
+               public void SetActor (Uri act)
+               {
+                       actor = act;
+               }
+
+               public void SetIsInbound (bool to)
+               {
+                       _isInbound = to;
+               }
 #endif
                public Uri Actor { 
                        get { return actor; }
index 04fe7f64853bbb4a9d37e3ad21f95b7327792154..a2fb5d3e8648250fb24ca57907fa2cf35cb6d944 100755 (executable)
@@ -22,6 +22,7 @@ namespace Microsoft.Web.Services {
                private XmlElement header;
 #if WSE2
                private Encoding _encoding;
+               private bool _processed = false;
 #endif
 
                public SoapEnvelope ()
@@ -50,6 +51,17 @@ namespace Microsoft.Web.Services {
                                }
                        }
                }
+
+               public bool Processed {
+                       get { return _processed; }
+               }
+
+
+               //Potential LAMESPEC: Why not a property?!?
+               public void SetProcessed (bool to)
+               {
+                       _processed = to;
+               }
 #endif
 
                public XmlElement Body {