System.Runtime.Remoting.Contexts.Context.AddDynamicProperty C# (CSharp) Method

AddDynamicProperty() static private method

static private AddDynamicProperty ( Context ctx, IDynamicProperty prop ) : bool
ctx Context
prop IDynamicProperty
return bool
        internal static bool AddDynamicProperty(Context ctx, IDynamicProperty prop)
        {
            // Check if we have a property by this name
            if (ctx != null)
            {
                return ctx.AddPerContextDynamicProperty(prop);
            }
            else
            {
                // We have to add a sink that should fire for all contexts
                return AddGlobalDynamicProperty(prop);
            }
        }
    

Usage Example

        public static bool RegisterDynamicProperty(IDynamicProperty prop, ContextBoundObject obj, Context ctx)
        {
            bool fRegistered = false;

            if (prop == null || prop.Name == null || !(prop is IContributeDynamicSink))
            {
                throw new ArgumentNullException("prop");
            }
            if (obj != null && ctx != null)
            {
                // Exactly one of these is allowed to be non-null.
                throw new ArgumentException(Environment.GetResourceString("Argument_NonNullObjAndCtx"));
            }
            if (obj != null)
            {
                // ctx is ignored and must be null.
                fRegistered = IdentityHolder.AddDynamicProperty(obj, prop);
            }
            else
            {
                // ctx may or may not be null
                fRegistered = Context.AddDynamicProperty(ctx, prop);
            }

            return(fRegistered);
        }
All Usage Examples Of System.Runtime.Remoting.Contexts.Context::AddDynamicProperty