1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/backend/model/ObjectManagerRepository.ts

68 lines
2.2 KiB
TypeScript
Raw Normal View History

2016-05-26 18:05:10 +08:00
///<reference path="../../typings/index.d.ts"/>
2016-04-22 19:23:44 +08:00
import {IUserManager} from "./IUserManager";
import {IGalleryManager} from "./IGalleryManager";
2016-05-05 00:34:54 +08:00
import {ISearchManager} from "./ISearchManager";
2016-04-22 19:23:44 +08:00
2016-05-09 23:04:56 +08:00
export class ObjectManagerRepository {
2016-04-22 19:23:44 +08:00
private _galleryManager:IGalleryManager;
private _userManager:IUserManager;
2016-05-05 00:34:54 +08:00
private _searchManager:ISearchManager;
2016-04-22 19:23:44 +08:00
private static _instance:ObjectManagerRepository = null;
2016-05-09 23:04:56 +08:00
public static InitMongoManagers() {
2016-05-26 18:05:10 +08:00
let MongoGalleryManager = require("./mongoose/MongoGalleryManager");
let MongoUserManager = require("./mongoose/MongoUserManager");
let MongoSearchManager = require("./mongoose/MongoSearchManager");
2016-04-22 19:23:44 +08:00
ObjectManagerRepository.getInstance().setGalleryManager(new MongoGalleryManager());
ObjectManagerRepository.getInstance().setUserManager(new MongoUserManager());
2016-05-05 00:34:54 +08:00
ObjectManagerRepository.getInstance().setSearchManager(new MongoSearchManager());
2016-04-22 19:23:44 +08:00
}
2016-05-09 23:04:56 +08:00
public static MemoryMongoManagers() {
2016-05-26 18:05:10 +08:00
let GalleryManager = require("./memory/GalleryManager");
let UserManager = require("./memory/UserManager");
let SearchManager = require("./memory/SearchManager");
2016-04-22 19:23:44 +08:00
ObjectManagerRepository.getInstance().setGalleryManager(new GalleryManager());
ObjectManagerRepository.getInstance().setUserManager(new UserManager());
2016-05-05 00:34:54 +08:00
ObjectManagerRepository.getInstance().setSearchManager(new SearchManager());
2016-04-22 19:23:44 +08:00
}
2016-05-09 23:04:56 +08:00
public static getInstance() {
if (this._instance === null) {
2016-04-22 19:23:44 +08:00
this._instance = new ObjectManagerRepository();
}
return this._instance;
}
2016-05-26 02:17:42 +08:00
public static reset() {
this._instance = null;
}
2016-04-22 19:23:44 +08:00
getGalleryManager():IGalleryManager {
return this._galleryManager;
}
setGalleryManager(value:IGalleryManager) {
this._galleryManager = value;
}
getUserManager():IUserManager {
return this._userManager;
}
setUserManager(value:IUserManager) {
this._userManager = value;
}
2016-05-05 00:34:54 +08:00
getSearchManager():ISearchManager {
return this._searchManager;
}
setSearchManager(value:ISearchManager) {
this._searchManager = value;
}
2016-04-22 19:23:44 +08:00
}