Exemplo n.º 1
0
        /// <summary>
        /// Register named context
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public IContext CreateSubContext(string name)
        {
            IContext prevContext;

            if (_subcontexts.Lookup(name, out prevContext))
            {
                throw new ArgumentException();
            }

            Context context = new Context(name);

            context.Subscribe(this);

            _subcontexts.Register(name, context);
            return(context);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Register named context
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public IContext CreateContext(string name)
        {
            _contextsLock.EnterWriteLock();

            try {
                IContext prevContext;
                if (_contexts.Lookup(name, out prevContext))
                {
                    throw new ArgumentException();
                }

                Context context = new Context(name);
                context.Subscribe(this);

                _contexts.Register(name, context);
                return(context);
            }
            finally {
                _contextsLock.ExitWriteLock();
            }
        }
        /// <summary>
        ///     Register named context
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public IContext CreateContext(string name)
        {
            this._contextsLock.EnterWriteLock();

            try
            {
                IContext prevContext;
                if (this._contexts.Lookup(name, out prevContext))
                {
                    throw new ArgumentException();
                }

                using (Context context = new Context(name))
                {
                    context.Subscribe(this);

                    this._contexts.Register(name, context);
                    return context;
                }
            }
            finally
            {
                this._contextsLock.ExitWriteLock();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        ///     Register named context
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public IContext CreateSubContext(string name)
        {
            IContext prevContext;
            if (this._subcontexts.Lookup(name, out prevContext))
            {
                throw new ArgumentException();
            }

            using (Context context = new Context(name))
            {
                context.Subscribe(this);

                this._subcontexts.Register(name, context);
                return context;
            }
        }