static DynamicPropertyCollection GetDynamicPropertyCollection(ContextBoundObject obj, Context ctx) { if (ctx == null && obj != null) { if (RemotingServices.IsTransparentProxy(obj)) { RealProxy rp = RemotingServices.GetRealProxy(obj); return(rp.ObjectIdentity.ClientDynamicProperties); } else { return(obj.ObjectIdentity.ServerDynamicProperties); } } else if (ctx != null && obj == null) { if (ctx.context_dynamic_properties == null) { ctx.context_dynamic_properties = new DynamicPropertyCollection(); } return(ctx.context_dynamic_properties); } else if (ctx == null && obj == null) { if (global_dynamic_properties == null) { global_dynamic_properties = new DynamicPropertyCollection(); } return(global_dynamic_properties); } else { throw new ArgumentException("Either obj or ctx must be null"); } }
static DynamicPropertyCollection GetDynamicPropertyCollection(ContextBoundObject obj, Context ctx) { if (ctx == null && obj != null) { if (RemotingServices.IsTransparentProxy(obj)) { RealProxy rp = RemotingServices.GetRealProxy (obj); return rp.ObjectIdentity.ClientDynamicProperties; } else { #if FEATURE_REMOTING return obj.ObjectIdentity.ServerDynamicProperties; #else throw new NotSupportedException (); #endif } } else if (ctx != null && obj == null) { if (ctx.context_dynamic_properties == null) ctx.context_dynamic_properties = new DynamicPropertyCollection (); return ctx.context_dynamic_properties; } else if (ctx == null && obj == null) { if (global_dynamic_properties == null) global_dynamic_properties = new DynamicPropertyCollection (); return global_dynamic_properties; } else throw new ArgumentException ("Either obj or ctx must be null"); }
/// <summary>Unregisters a dynamic property implementing the <see cref="T:System.Runtime.Remoting.Contexts.IDynamicProperty" /> interface.</summary> /// <returns>true if the object was successfully unregistered; otherwise, false.</returns> /// <param name="name">The name of the dynamic property to unregister. </param> /// <param name="obj">The object/proxy for which the <paramref name="property" /> is registered. </param> /// <param name="ctx">The context for which the <paramref name="property" /> is registered. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="name" /> parameter is null. </exception> /// <exception cref="T:System.ArgumentException">Both an object as well as a context are specified (both <paramref name="obj" /> and <paramref name="ctx" /> are not null). </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public static bool UnregisterDynamicProperty(string name, ContextBoundObject obj, Context ctx) { DynamicPropertyCollection dynamicPropertyCollection = Context.GetDynamicPropertyCollection(obj, ctx); return(dynamicPropertyCollection.UnregisterDynamicProperty(name)); }
/// <summary>Registers a dynamic property implementing the <see cref="T:System.Runtime.Remoting.Contexts.IDynamicProperty" /> interface with the remoting service.</summary> /// <returns>true if the property was successfully registered; otherwise, false.</returns> /// <param name="prop">The dynamic property to register. </param> /// <param name="obj">The object/proxy for which the <paramref name="property" /> is registered. </param> /// <param name="ctx">The context for which the <paramref name="property" /> is registered. </param> /// <exception cref="T:System.ArgumentNullException">Either <paramref name="prop" /> or its name is null, or it is not dynamic (it does not implement <see cref="T:System.Runtime.Remoting.Contexts.IDynamicProperty" />). </exception> /// <exception cref="T:System.ArgumentException">Both an object as well as a context are specified (both <paramref name="obj" /> and <paramref name="ctx" /> are not null). </exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" /> /// </PermissionSet> public static bool RegisterDynamicProperty(IDynamicProperty prop, ContextBoundObject obj, Context ctx) { DynamicPropertyCollection dynamicPropertyCollection = Context.GetDynamicPropertyCollection(obj, ctx); return(dynamicPropertyCollection.RegisterDynamicProperty(prop)); }