local ____lualib = require("lualib_bundle") local __TS__New = ____lualib.__TS__New local ____exports = __module.env --- -- @noSelf local function ResolveClassName(ctor, explicitName) if explicitName ~= nil and explicitName ~= "" then return explicitName end local rawName = ctor.name if rawName ~= nil and type(rawName) == "string" and rawName ~= "" then return rawName end return tostring(ctor) end ____exports.MgrRegistry = __TS__DefineClass("MgrRegistry", __module) local MgrRegistry = ____exports.MgrRegistry MgrRegistry.name = "MgrRegistry" function MgrRegistry.prototype.____constructor(self) self.mgrByCtor = {} self.mgrNameByCtor = {} self.mgrByName = {} self.dataByCtor = {} self.disposed = false end function MgrRegistry.prototype.CreateMgrData(self, ctor) local existing = self.dataByCtor[ctor] if existing ~= nil then return existing end local data = __TS__New(ctor) self.dataByCtor[ctor] = data return data end function MgrRegistry.prototype.GetMgrData(self, ctor) return self.dataByCtor[ctor] end function MgrRegistry.prototype.DelMgrData(self, ctor) local data = self.dataByCtor[ctor] if data == nil then return end self.dataByCtor[ctor] = nil data:Dispose() end function MgrRegistry.prototype.CreateMgr(self, ctor, explicitName) local existing = self.mgrByCtor[ctor] if existing ~= nil then return existing end local mgr = __TS__New(ctor) local name = ResolveClassName(ctor, explicitName) self.mgrByCtor[ctor] = mgr self.mgrNameByCtor[ctor] = name self.mgrByName[name] = mgr mgr:Initialization() return mgr end function MgrRegistry.prototype.GetMgr(self, ctor) return self.mgrByCtor[ctor] end function MgrRegistry.prototype.GetMgrByName(self, name) return self.mgrByName[name] end function MgrRegistry.prototype.DelMgr(self, ctor) local mgr = self.mgrByCtor[ctor] if mgr == nil then return end local name = self.mgrNameByCtor[ctor] self.mgrByCtor[ctor] = nil self.mgrNameByCtor[ctor] = nil if name ~= nil and self.mgrByName[name] == mgr then self.mgrByName[name] = nil end mgr:Dispose() end function MgrRegistry.prototype.GetMgrCount(self) local count = 0 for _, mgr in pairs(self.mgrByCtor) do if mgr ~= nil then count = count + 1 end end return count end function MgrRegistry.prototype.Dispose(self) if self.disposed then return end self.disposed = true local mgrList = {} for key, mgr in pairs(self.mgrByCtor) do if mgr ~= nil then self.mgrByCtor[key] = nil mgrList[#mgrList + 1] = mgr end end self.mgrNameByCtor = {} self.mgrByName = {} do local i = 0 while i < #mgrList do mgrList[i + 1]:Dispose() i = i + 1 end end local dataList = {} for key, data in pairs(self.dataByCtor) do if data ~= nil then self.dataByCtor[key] = nil dataList[#dataList + 1] = data end end do local i = 0 while i < #dataList do dataList[i + 1]:Dispose() i = i + 1 end end end function __module.UpdateImports() end