X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;ds=inline;f=mcs%2Fclass%2Fcorlib%2FSystem.Runtime.Remoting%2FRemotingServices.cs;h=9fa45c85328fe4eb1c1201bc9b481fd2b0faf7d1;hb=a4f8889331e541c66d9826e804fae71f75496593;hp=7c9389577cd594a814663fb7f74d7e3c35ba3146;hpb=38f320d19a29a3e7d6a92cdb0b3ebec149d7c1a7;p=mono.git diff --git a/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs b/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs index 7c9389577cd..9fa45c85328 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs @@ -7,10 +7,7 @@ // Patrik Torstensson // // (C) 2001 Ximian, Inc. http://www.ximian.com -// - -// -// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// Copyright (C) 2004, 2006 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 @@ -32,7 +29,6 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System; using System.Diagnostics; using System.Text; using System.Reflection; @@ -49,6 +45,7 @@ using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.IO; using System.Runtime.Remoting.Services; +using System.Security.Permissions; #if NET_2_0 using System.Runtime.ConstrainedExecution; @@ -437,15 +434,25 @@ namespace System.Runtime.Remoting public static bool IsObjectOutOfAppDomain(object tp) { + MarshalByRefObject mbr = tp as MarshalByRefObject; + + if (mbr == null) + return false; + // TODO: use internal call for better performance - Identity ident = GetObjectIdentity((MarshalByRefObject)tp); + Identity ident = GetObjectIdentity (mbr); return ident is ClientIdentity; } public static bool IsObjectOutOfContext(object tp) { + MarshalByRefObject mbr = tp as MarshalByRefObject; + + if (mbr == null) + return false; + // TODO: use internal call for better performance - Identity ident = GetObjectIdentity((MarshalByRefObject)tp); + Identity ident = GetObjectIdentity (mbr); if (ident == null) return false; ServerIdentity sident = ident as ServerIdentity; @@ -522,15 +529,48 @@ namespace System.Runtime.Remoting RemotingProxy proxy = new RemotingProxy (type, ChannelServices.CrossContextUrl, activationAttributes); return proxy.GetTransparentProxy(); } + + internal static object CreateClientProxyForComInterop (Type type) + { + Mono.Interop.ComInteropProxy proxy = new Mono.Interop.ComInteropProxy (type); + return proxy.GetTransparentProxy (); + } internal static Identity GetIdentityForUri (string uri) { + string normUri = GetNormalizedUri (uri); lock (uri_hash) { - return (Identity)uri_hash [GetNormalizedUri(uri)]; + Identity i = (Identity) uri_hash [normUri]; + + if (i == null) { + normUri = RemoveAppNameFromUri (uri); + if (normUri != null) + i = (Identity) uri_hash [normUri]; + } + + return i; } } + // + // If the specified uri starts with the application name, + // RemoveAppNameFromUri returns the uri w/out the leading + // application name, otherwise it returns null. + // + // Assumes that the uri is not normalized. + // + static string RemoveAppNameFromUri (string uri) + { + string name = RemotingConfiguration.ApplicationName; + if (name == null) return null; + name = "/" + name + "/"; + if (uri.StartsWith (name)) + return uri.Substring (name.Length); + else + return null; + } + internal static Identity GetObjectIdentity (MarshalByRefObject obj) { if (IsTransparentProxy(obj)) @@ -677,6 +717,7 @@ namespace System.Runtime.Remoting } // This method is called by the runtime + [SecurityPermission (SecurityAction.Assert, SerializationFormatter = true)] // FIXME: to be reviewed internal static byte[] SerializeCallData (object obj) { LogicalCallContext ctx = CallContext.CreateLogicalCallContext (false); @@ -694,6 +735,7 @@ namespace System.Runtime.Remoting } // This method is called by the runtime + [SecurityPermission (SecurityAction.Assert, SerializationFormatter = true)] // FIXME: to be reviewed internal static object DeserializeCallData (byte[] array) { if (array == null) return null; @@ -710,6 +752,7 @@ namespace System.Runtime.Remoting } // This method is called by the runtime + [SecurityPermission (SecurityAction.Assert, SerializationFormatter = true)] // FIXME: to be reviewed internal static byte[] SerializeExceptionData (Exception ex) { try {