示例#1
0
        /// <summary>
        /// Creates an <see cref="IExtendedQueue" /> instance from a <see cref="IQueue" /> instance.
        /// </summary>
        /// <param name="original">The <see cref="IQueue" /> instance to wrap into an <see cref="IExtendedQueue" /> instance.</param>
        /// <returns>
        /// An <see cref="IExtendedQueue" /> instance backed by the <paramref name="original" /> instance.
        /// </returns>
        public IExtendedQueue Create(IQueue original)
        {
            var asExtended = original as IExtendedQueue;

            if (asExtended != null)
            {
                return(asExtended);
            }


            var baseQueue = new ExtendedQueue(original, this.MessageProvider, this.MaximumMessageSizeProvider, this.MaximumMessagesProvider);

            ExtendedQueueBase decoratedQueue = baseQueue;

            foreach (var action in this.Decorators)
            {
                decoratedQueue = action(decoratedQueue);
            }


            decoratedQueue.LogAction(ExtendedQueueBase.LogSeverity.Info,
                                     "Created a new IExtendedQueue instance using the DefaultExtendedQueueFactory instance",
                                     "Queue name: {0}, Actual type of the factory: {1}",
                                     original.Name,
                                     this.GetType().FullName);

            return(decoratedQueue);
        }
 protected ExtendedQueueBase()
 {
     this.Statistics = new StatisticsContainer();
     this._top       = this;
 }