System.Runtime.Remoting.RemotingServices.IsObjectOutOfContext C# (CSharp) Méthode

IsObjectOutOfContext() public static méthode

public static IsObjectOutOfContext ( Object tp ) : bool
tp Object
Résultat bool
        public static bool IsObjectOutOfContext(Object tp)
        {
            if (!IsTransparentProxy(tp))
            {
                return false;
            }

            RealProxy rp = GetRealProxy(tp);
            Identity id = rp.IdentityObject;
            ServerIdentity serverID = id as ServerIdentity;
            if ((null == serverID) || !(rp is RemotingProxy))
            {
                return true;
            }

            return(Thread.CurrentContext != serverID.ServerContext);
        }

Usage Example

        internal static bool RemoveDynamicProperty(MarshalByRefObject obj, String name)
        {
            if (RemotingServices.IsObjectOutOfContext(obj))
            {
                // We have to add a proxy side property, get the identity
                RealProxy rp = RemotingServices.GetRealProxy(obj);
                return(rp.IdentityObject.RemoveProxySideDynamicProperty(name));
            }
            else
            {
                MarshalByRefObject realObj =
                    (MarshalByRefObject)
                    RemotingServices.AlwaysUnwrap((ContextBoundObject)obj);

                // This is a real object. See if we have an identity for it
                ServerIdentity srvID = (ServerIdentity)MarshalByRefObject.GetIdentity(realObj);
                if (srvID != null)
                {
                    return(srvID.RemoveServerSideDynamicProperty(name));
                }
                else
                {
                    // identity not found, we can't set a sink for this object.
                    throw new RemotingException(
                              Environment.GetResourceString("Remoting_NoIdentityEntry"));
                }
            }
        }
All Usage Examples Of System.Runtime.Remoting.RemotingServices::IsObjectOutOfContext
RemotingServices