Merge pull request #376 from atomia/master
[mono.git] / mcs / class / corlib / System / MarshalByRefObject.cs
index 27249fa188fd0a0e7a32a33ac3aa34a1f43a5423..a2be3e6983319277b899011d41fab47174a394d0 100644 (file)
 using System.Threading;
 using System.Runtime.Remoting;
 using System.Security.Permissions;
+using System.Runtime.InteropServices;
 
 namespace System
 {
        [Serializable]
+       [ComVisible (true)]
+       [StructLayout (LayoutKind.Sequential)]
        public abstract class MarshalByRefObject
        {
                [NonSerialized]
@@ -67,16 +70,18 @@ namespace System
                }
 
                [SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
-               public virtual ObjRef CreateObjRef (Type type)
+               public virtual ObjRef CreateObjRef (Type requestedType)
                {
                        // This method can only be called when this object has been marshalled
                        if (_identity == null)
                                throw new RemotingException (Locale.GetText ("No remoting information was found for the object."));
-                       return _identity.CreateObjRef (type);
+                       return _identity.CreateObjRef (requestedType);
                }
 
+               // corcompare says it is "virtual final", so there is likely
+               // an internal interface in .NET.
                [SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
-               public virtual object GetLifetimeService ()
+               public object GetLifetimeService ()
                {
                        if (_identity == null)
                                return null;
@@ -86,7 +91,18 @@ namespace System
                [SecurityPermission (SecurityAction.LinkDemand, Infrastructure = true)]
                public virtual object InitializeLifetimeService ()
                {
-                       return new System.Runtime.Remoting.Lifetime.Lease();
+                       if (_identity != null && _identity.Lease != null)
+                               return _identity.Lease;
+                       else
+                               return new System.Runtime.Remoting.Lifetime.Lease();
+               }
+
+               protected MarshalByRefObject MemberwiseClone (bool cloneIdentity)
+               {
+                       MarshalByRefObject mbr = (MarshalByRefObject) MemberwiseClone ();
+                       if (!cloneIdentity)
+                               mbr._identity = null;
+                       return mbr;
                }
        }
 }