Author: atsushi
Date: 2008-02-14 10:42:35 -0500 (Thu, 14 Feb 2008)
New Revision: 95642

Modified:
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
   trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog
   
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/WebChannelFactory.cs
Log:
2008-02-14  Atsushi Enomoto  <[EMAIL PROTECTED]>

        * WebChannelFactory.cs : call base.OnOpening().

        * WebMessageFormatter.cs : pass QueryStringConverter which is used to
          convert parameter objects to the components of the request URI.

        * WebHttpBehavior.cs : now WebMessageFormatter requires 
          QueryStringConverter. Hence implemented GetQueryStringConverter().



Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
 2008-02-14 15:31:24 UTC (rev 95641)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/ChangeLog
 2008-02-14 15:42:35 UTC (rev 95642)
@@ -1,5 +1,10 @@
 2008-02-14  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * WebHttpBehavior.cs : now WebMessageFormatter requires 
+         QueryStringConverter. Hence implemented GetQueryStringConverter().
+
+2008-02-14  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * WebHttpBehavior.cs : use WebMessageFormatter (note that they are
          not done yet).
 

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
        2008-02-14 15:31:24 UTC (rev 95641)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Description/WebHttpBehavior.cs
        2008-02-14 15:42:35 UTC (rev 95642)
@@ -75,24 +75,23 @@
                {
                }
 
-               [MonoTODO]
+               [MonoTODO ("where should I set reply client formatter?")]
                public virtual void ApplyClientBehavior (ServiceEndpoint 
endpoint, ClientRuntime clientRuntime)
                {
                        foreach (ClientOperation oper in 
clientRuntime.Operations) {
-                               // 
GetClientRequestFormatter/GetClientReplyFormatter
                                oper.Formatter = GetRequestClientFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint);
-                               oper.Formatter = GetReplyClientFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint);
+                               //oper.Formatter = GetReplyClientFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint); // FIXME: see 
MonoTODO.
                        }
                }
 
+               [MonoTODO ("where should I set reply dispatch formatter?")]
                public virtual void ApplyDispatchBehavior (ServiceEndpoint 
endpoint, EndpointDispatcher endpointDispatcher)
                {
                        endpointDispatcher.DispatchRuntime.OperationSelector = 
GetOperationSelector (endpoint);
 
                        foreach (DispatchOperation oper in 
endpointDispatcher.DispatchRuntime.Operations) {
-                               // 
GetClientRequestFormatter/GetClientReplyFormatter
                                oper.Formatter = GetRequestDispatchFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint);
-                               oper.Formatter = GetReplyDispatchFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint);
+                               //oper.Formatter = GetReplyDispatchFormatter 
(endpoint.Contract.Operations.Find (oper.Name), endpoint); // FIXME: see 
MonoTODO.
                        }
                }
 
@@ -101,34 +100,33 @@
                        return new WebHttpDispatchOperationSelector (endpoint);
                }
 
-               [MonoTODO]
                protected virtual QueryStringConverter GetQueryStringConverter 
(OperationDescription operationDescription)
                {
-                       throw new NotImplementedException ();
+                       return new QueryStringConverter ();
                }
 
                [MonoTODO]
                protected virtual IClientMessageFormatter 
GetReplyClientFormatter (OperationDescription operationDescription, 
ServiceEndpoint endpoint)
                {
-                       return new WebMessageFormatter.ReplyClientFormatter 
(operationDescription, endpoint);
+                       return new WebMessageFormatter.ReplyClientFormatter 
(operationDescription, endpoint, GetQueryStringConverter 
(operationDescription));
                }
 
                [MonoTODO]
                protected virtual IDispatchMessageFormatter 
GetReplyDispatchFormatter (OperationDescription operationDescription, 
ServiceEndpoint endpoint)
                {
-                       return new WebMessageFormatter.ReplyDispatchFormatter 
(operationDescription, endpoint);
+                       return new WebMessageFormatter.ReplyDispatchFormatter 
(operationDescription, endpoint, GetQueryStringConverter 
(operationDescription));
                }
 
                [MonoTODO]
                protected virtual IClientMessageFormatter 
GetRequestClientFormatter (OperationDescription operationDescription, 
ServiceEndpoint endpoint)
                {
-                       return new WebMessageFormatter.RequestClientFormatter 
(operationDescription, endpoint);
+                       return new WebMessageFormatter.RequestClientFormatter 
(operationDescription, endpoint, GetQueryStringConverter 
(operationDescription));
                }
 
                [MonoTODO]
                protected virtual IDispatchMessageFormatter 
GetRequestDispatchFormatter (OperationDescription operationDescription, 
ServiceEndpoint endpoint)
                {
-                       return new WebMessageFormatter.RequestDispatchFormatter 
(operationDescription, endpoint);
+                       return new WebMessageFormatter.RequestDispatchFormatter 
(operationDescription, endpoint, GetQueryStringConverter 
(operationDescription));
                }
 
                [MonoTODO]

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
  2008-02-14 15:31:24 UTC (rev 95641)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog
  2008-02-14 15:42:35 UTC (rev 95642)
@@ -1,5 +1,10 @@
 2008-02-14  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * WebMessageFormatter.cs : pass QueryStringConverter which is used to
+         convert parameter objects to the components of the request URI.
+
+2008-02-14  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * WebMessageFormatter.cs : new message formatter that is created
          from WebHttpBehavior and handles [WebGet] or [WebInvoke]. Not done.
 

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
     2008-02-14 15:31:24 UTC (rev 95641)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs
     2008-02-14 15:42:35 UTC (rev 95642)
@@ -26,6 +26,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 using System;
+using System.Collections.Specialized;
 using System.Reflection;
 using System.ServiceModel;
 using System.ServiceModel.Channels;
@@ -40,12 +41,14 @@
                OperationDescription operation;
                MessageDescription message_desc;
                ServiceEndpoint endpoint;
+               QueryStringConverter converter;
                UriTemplate template;
 
-               public WebMessageFormatter (OperationDescription operation, 
ServiceEndpoint endpoint)
+               public WebMessageFormatter (OperationDescription operation, 
ServiceEndpoint endpoint, QueryStringConverter converter)
                {
                        this.operation = operation;
                        this.endpoint = endpoint;
+                       this.converter = converter;
                        ApplyWebAttribute ();
                }
 
@@ -71,10 +74,14 @@
                        get { return operation; }
                }
 
-               public MessageDescription Message {
+               public MessageDescription MessageDescription {
                        get { return message_desc; }
                }
 
+               public QueryStringConverter Converter {
+                       get { return converter; }
+               }
+
                public ServiceEndpoint Endpoint {
                        get { return endpoint; }
                }
@@ -85,6 +92,15 @@
 
                public abstract MessageDirection MessageDirection { get; }
 
+               protected void CheckMessageVersion (MessageVersion 
messageVersion)
+               {
+                       if (messageVersion == null)
+                               throw new ArgumentNullException 
("messageVersion");
+
+                       if (!MessageVersion.None.Equals (messageVersion))
+                               throw new ArgumentException ("Only 
MessageVersion.None is supported");
+               }
+
                string BuildUriTemplate ()
                {
                        StringBuilder sb = new StringBuilder ();
@@ -109,90 +125,115 @@
                        throw new SystemException ("INTERNAL ERROR: no 
corresponding message description for the specified direction: " + 
MessageDirection);
                }
 
-               internal class RequestClientFormatter : WebMessageFormatter, 
IClientMessageFormatter
+               internal class RequestClientFormatter : 
WebClientMessageFormatter
                {
-                       public RequestClientFormatter (OperationDescription 
operation, ServiceEndpoint endpoint)
-                               : base (operation, endpoint)
+                       public RequestClientFormatter (OperationDescription 
operation, ServiceEndpoint endpoint, QueryStringConverter converter)
+                               : base (operation, endpoint, converter)
                        {
                        }
+               }
 
-                       public override MessageDirection MessageDirection {
-                               get { return MessageDirection.Input; }
+               internal class ReplyClientFormatter : WebClientMessageFormatter
+               {
+                       public ReplyClientFormatter (OperationDescription 
operation, ServiceEndpoint endpoint, QueryStringConverter converter)
+                               : base (operation, endpoint, converter)
+                       {
                        }
+               }
 
-                       public Message SerializeRequest (MessageVersion 
messageVersion, object [] parameters)
+               internal class RequestDispatchFormatter : 
WebDispatchMessageFormatter
+               {
+                       public RequestDispatchFormatter (OperationDescription 
operation, ServiceEndpoint endpoint, QueryStringConverter converter)
+                               : base (operation, endpoint, converter)
                        {
-                               throw new NotImplementedException ();
                        }
+               }
 
-                       public object DeserializeReply (Message message, object 
[] parameters)
+               internal class ReplyDispatchFormatter : 
WebDispatchMessageFormatter
+               {
+                       public ReplyDispatchFormatter (OperationDescription 
operation, ServiceEndpoint endpoint, QueryStringConverter converter)
+                               : base (operation, endpoint, converter)
                        {
-                               throw new NotImplementedException ();
                        }
                }
 
-               internal class ReplyClientFormatter : WebMessageFormatter, 
IClientMessageFormatter
+               internal abstract class WebClientMessageFormatter : 
WebMessageFormatter, IClientMessageFormatter
                {
-                       public ReplyClientFormatter (OperationDescription 
operation, ServiceEndpoint endpoint)
-                               : base (operation, endpoint)
+                       protected WebClientMessageFormatter 
(OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter 
converter)
+                               : base (operation, endpoint, converter)
                        {
                        }
 
                        public override MessageDirection MessageDirection {
-                               get { return MessageDirection.Output; }
+                               get { return MessageDirection.Input; }
                        }
 
                        public Message SerializeRequest (MessageVersion 
messageVersion, object [] parameters)
                        {
-                               throw new NotImplementedException ();
-                       }
+                               if (parameters == null)
+                                       throw new ArgumentNullException 
("parameters");
+                               CheckMessageVersion (messageVersion);
 
-                       public object DeserializeReply (Message message, object 
[] parameters)
-                       {
-                               throw new NotImplementedException ();
-                       }
-               }
+                               var c = new NameValueCollection ();
 
-               internal class RequestDispatchFormatter : WebMessageFormatter, 
IDispatchMessageFormatter
-               {
-                       public RequestDispatchFormatter (OperationDescription 
operation, ServiceEndpoint endpoint)
-                               : base (operation, endpoint)
-                       {
-                       }
+                               if (parameters.Length != 
MessageDescription.Body.Parts.Count)
+                                       throw new ArgumentException ("Parameter 
array length does not match the number of message body parts");
 
-                       public override MessageDirection MessageDirection {
-                               get { return MessageDirection.Input; }
+                               for (int i = 0; i < parameters.Length; i++) {
+                                       var p = MessageDescription.Body.Parts 
[i];
+                                       string name = p.Name.ToUpperInvariant 
();
+                                       if 
(UriTemplate.PathSegmentVariableNames.Contains (name) ||
+                                           
UriTemplate.QueryValueVariableNames.Contains (name))
+                                               c.Add (name, parameters [i] != 
null ? Converter.ConvertValueToString (parameters [i], parameters [i].GetType 
()) : null);
+                                       else
+                                               // FIXME: bind as a message part
+                                               throw new 
NotImplementedException (String.Format ("parameter {0} is not contained in the 
URI template {1} {2} {3}", p.Name, UriTemplate, 
UriTemplate.PathSegmentVariableNames.Count, 
UriTemplate.QueryValueVariableNames.Count));
+                               }
+
+                               Uri to = UriTemplate.BindByName 
(Endpoint.Address.Uri, c);
+
+                               Message ret = Message.CreateMessage 
(messageVersion, null);
+                               ret.Headers.To = to;
+
+                               return ret;
                        }
 
-                       public Message SerializeReply (MessageVersion 
messageVersion, object [] parameters, object result)
+                       public object DeserializeReply (Message message, object 
[] parameters)
                        {
-                               throw new NotImplementedException ();
-                       }
+                               if (parameters == null)
+                                       throw new ArgumentNullException 
("parameters");
+                               CheckMessageVersion (message.Version);
 
-                       public void DeserializeRequest (Message message, object 
[] parameters)
-                       {
                                throw new NotImplementedException ();
                        }
                }
 
-               internal class ReplyDispatchFormatter : WebMessageFormatter, 
IDispatchMessageFormatter
+               internal abstract class WebDispatchMessageFormatter : 
WebMessageFormatter, IDispatchMessageFormatter
                {
-                       public ReplyDispatchFormatter (OperationDescription 
operation, ServiceEndpoint endpoint)
-                               : base (operation, endpoint)
+                       protected WebDispatchMessageFormatter 
(OperationDescription operation, ServiceEndpoint endpoint, QueryStringConverter 
converter)
+                               : base (operation, endpoint, converter)
                        {
                        }
 
                        public override MessageDirection MessageDirection {
-                               get { return MessageDirection.Output; }
+                               get { return MessageDirection.Input; }
                        }
 
                        public Message SerializeReply (MessageVersion 
messageVersion, object [] parameters, object result)
                        {
+                               if (parameters == null)
+                                       throw new ArgumentNullException 
("parameters");
+                               CheckMessageVersion (messageVersion);
+
                                throw new NotImplementedException ();
                        }
 
                        public void DeserializeRequest (Message message, object 
[] parameters)
                        {
+                               if (parameters == null)
+                                       throw new ArgumentNullException 
("parameters");
+                               CheckMessageVersion (message.Version);
+
                                throw new NotImplementedException ();
                        }
                }

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog
===================================================================
--- trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog 
2008-02-14 15:31:24 UTC (rev 95641)
+++ trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/ChangeLog 
2008-02-14 15:42:35 UTC (rev 95642)
@@ -1,5 +1,9 @@
 2008-02-14  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
+       * WebChannelFactory.cs : call base.OnOpening().
+
+2008-02-14  Atsushi Enomoto  <[EMAIL PROTECTED]>
+
        * WebAttributeInfo.cs : new class to unify WebGet and WebInvoke.
        * WebInvokeAttribute.cs, WebGetAttribute.cs : rewrote to use above.
        * WebChannelFactory.cs : removed couple of MonoTODOs.

Modified: 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/WebChannelFactory.cs
===================================================================
--- 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/WebChannelFactory.cs
      2008-02-14 15:31:24 UTC (rev 95641)
+++ 
trunk/olive/class/System.ServiceModel.Web/System.ServiceModel.Web/WebChannelFactory.cs
      2008-02-14 15:42:35 UTC (rev 95642)
@@ -88,6 +88,8 @@
 
                        if (Endpoint.Binding == null)
                                Endpoint.Binding = new WebHttpBinding ();
+
+                       base.OnOpening ();
                }
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to