Пример #1
0
        private object OpenStore(StoreType type)
        {
            int    storeIndex = type.ordinal();
            object store      = type.open(this);

            _stores[storeIndex] = store;
            return(store);
        }
Пример #2
0
        /// <summary>
        /// Returns specified store by type from already opened store array. Will open a new store if can't find any.
        /// Should be used only during construction of stores.
        /// </summary>
        /// <seealso cref= #getStore </seealso>
        /// <param name="storeType"> store type to get or create </param>
        /// <returns> store of requested type </returns>
        private object GetOrCreateStore(StoreType storeType)
        {
            object store = _stores[storeType.ordinal()];

            if (store == null)
            {
                store = OpenStore(storeType);
            }
            return(store);
        }
Пример #3
0
        /// <summary>
        /// Returns specified store by type from already opened store array. If store is not opened exception will be
        /// thrown.
        /// </summary>
        /// <seealso cref= #getOrCreateStore </seealso>
        /// <param name="storeType"> store type to retrieve </param>
        /// <returns> store of requested type </returns>
        /// <exception cref="IllegalStateException"> if opened store not found </exception>
        private object GetStore(StoreType storeType)
        {
            object store = _stores[storeType.ordinal()];

            if (store == null)
            {
                string message = ArrayUtil.contains(_initializedStores, storeType) ? STORE_ALREADY_CLOSED_MESSAGE : string.format(_storeNotInitializedTemplate, storeType.name());
                throw new System.InvalidOperationException(message);
            }
            return(store);
        }
Пример #4
0
        private void CloseStore(StoreType type)
        {
            int i = type.ordinal();

            if (_stores[i] != null)
            {
                try
                {
                    type.close(_stores[i]);
                }
                finally
                {
                    _stores[i] = null;
                }
            }
        }