* WebService.cs: Added SoapVersion property.
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Messaging / ConstructionCall.cs
index f9e19b3f54d77441894f3ce38d1b8330d1163139..e920ad930213baf547bfd4bf12d036287de2fc11 100644 (file)
@@ -4,54 +4,85 @@
 // Author: Lluis Sanchez Gual (lluis@ideary.com)
 //
 // (C) 2003, Lluis Sanchez Gual
-//\r
-\r
-using System;\r
-using System.Threading;\r
-using System.Collections;\r
-using System.Runtime.Remoting.Activation;\r
-using System.Runtime.Serialization;\r
-using System.Runtime.Remoting.Contexts;\r
-\r
-namespace System.Runtime.Remoting.Messaging\r
-{\r
+//
+
+//
+// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Threading;
+using System.Collections;
+using System.Runtime.Remoting.Activation;
+using System.Runtime.Serialization;
+using System.Runtime.Remoting.Contexts;
+
+namespace System.Runtime.Remoting.Messaging
+{
        [Serializable] [CLSCompliant (false)]
-       public class ConstructionCall: MethodCall, IConstructionCallMessage\r
-       {\r
-               IActivator _activator;\r
-               object[] _activationAttributes;\r
-               IList _contextProperties;\r
-               Type _activationType;\r
-               string _activationTypeName;\r
-\r
-               public ConstructionCall(IMessage msg): base (msg)\r
-               {\r
-                       _activationTypeName = TypeName;\r
-\r
-/*                     object[] attribs = ActivationType.GetCustomAttributes (typeof (IContextProperty), true);\r
-\r
-                       if (attribs.Length > 0)\r
-                               _contextProperties = new ArrayList (attribs);\r
-*/\r
-                       _activationAttributes = null;   // FIXME: put something here\r
-               }\r
-\r
-               public ConstructionCall (Header[] headers): base (headers)\r
-               {\r
-               }\r
-\r
+       public class ConstructionCall: MethodCall, IConstructionCallMessage
+       {
+               IActivator _activator;
+               object[] _activationAttributes;
+               IList _contextProperties;
+               Type _activationType;
+               string _activationTypeName;
+               bool _isContextOk;
+
+               public ConstructionCall(IMessage msg): base (msg)
+               {
+                       _activationTypeName = TypeName;
+                       _isContextOk = true;
+               }
+
+               internal ConstructionCall (Type type)
+               {
+                       _activationType = type;
+                       _activationTypeName = type.AssemblyQualifiedName;
+                       _isContextOk = true;
+               }
+
+               public ConstructionCall (Header[] headers): base (headers)
+               {
+               }
+
                internal ConstructionCall (SerializationInfo info, StreamingContext context): base (info, context)
                {
                }
-\r
-               internal override void InitDictionary()\r
-               {\r
-                       ConstructionCallDictionary props = new ConstructionCallDictionary (this);\r
+
+               internal override void InitDictionary()
+               {
+                       ConstructionCallDictionary props = new ConstructionCallDictionary (this);
                        ExternalProperties = props;
-                       InternalProperties = props.GetInternalProperties();\r
-               }\r
-\r
-               public Type ActivationType \r
+                       InternalProperties = props.GetInternalProperties();
+               }
+
+               internal bool IsContextOk
+               {
+                       get { return _isContextOk; }
+                       set { _isContextOk = value; }
+               }
+
+               public Type ActivationType 
                {
                        get 
                        { 
@@ -60,27 +91,36 @@ namespace System.Runtime.Remoting.Messaging
                        }
                }
 
-               public string ActivationTypeName \r
+               public string ActivationTypeName 
                {
                        get { return _activationTypeName; }
                }
 
-               public IActivator Activator \r
+               public IActivator Activator 
                {
                        get { return _activator; }
                        set { _activator = value; }
                }
 
-               public object [] CallSiteActivationAttributes \r
+               public object [] CallSiteActivationAttributes 
                {
                        get { return _activationAttributes; }
                }
 
-               public IList ContextProperties \r
+               internal void SetActivationAttributes (object [] attributes)
+               {
+                       _activationAttributes = attributes;
+               }
+
+               public IList ContextProperties 
                {
-                       get { return _contextProperties; }
-               }\r
-\r
+                       get 
+                       {
+                               if (_contextProperties == null) _contextProperties = new ArrayList ();
+                               return _contextProperties; 
+                       }
+               }
+
                internal override void InitMethodProperty(string key, object value)
                {
                        switch (key)
@@ -98,11 +138,19 @@ namespace System.Runtime.Remoting.Messaging
                {
                        base.GetObjectData (info, context);
 
+                       IList props = _contextProperties;
+                       if (props != null && props.Count == 0) props = null;
+
                        info.AddValue ("__Activator", _activator);
                        info.AddValue ("__CallSiteActivationAttributes", _activationAttributes);
                        info.AddValue ("__ActivationType", null);
-                       info.AddValue ("__ContextProperties", _contextProperties);
+                       info.AddValue ("__ContextProperties", props);
                        info.AddValue ("__ActivationTypeName", _activationTypeName);
-               } \r
-       }\r
-}\r
+               } 
+               
+               public override IDictionary Properties 
+               {
+                       get { return base.Properties; }
+               }
+       }
+}