public static LibraryDataContext GetDataContext()
        {
            IDataContextStorageContainer _dataContextStorageContainer = DataContextStorageFactory.CreateStorageContainer();

            LibraryDataContext libraryDataContext = _dataContextStorageContainer.GetDataContext();

            if (libraryDataContext == null)
            {
                libraryDataContext = new LibraryDataContext();
                _dataContextStorageContainer.Store(libraryDataContext);
            }

            return(libraryDataContext);
        }
        public static LibraryDataContext GetDataContext()
        {
            //由工厂方法获取贮藏存储对象
            IDataContextStorageContainer _dataContextStorageContainer = DataContextStorageFactory.CreateStorageContainer();

            //由于贮藏存储对象实现了指定接口,即实现了GetDataContext方法,调用该方法获取上下文对象
            LibraryDataContext libraryDataContext = _dataContextStorageContainer.GetDataContext();

            if (libraryDataContext == null)
            {
                libraryDataContext = new LibraryDataContext();
                _dataContextStorageContainer.Store(libraryDataContext);
            }

            return(libraryDataContext);
        }