/// <summary> /// 根据codeName得到应用对象 /// </summary> /// <param name="codeName">应用的codeName</param> /// <param name="throwNotExistsApp">不存在App时,是否抛出异常</param> /// <returns>应用对象</returns> protected IApplication GetApplication(string codeName, bool throwNotExistsApp) { IApplication app = null; lock (applicationDict) { if (applicationDict.TryGetValue(codeName, out app) == false) { ApplicationCollection apps = OguPermissionSettings.GetConfig().PermissionFactory.GetApplications(codeName); if (throwNotExistsApp) { ExceptionHelper.FalseThrow(apps.Count > 0, Resource.CanNotFindObject, codeName); } if (apps.Count == 0) { app = null; } else { app = apps[0]; applicationDict.Add(codeName, app); } } } return(app); }
/// <summary> /// 得到所有应用的权限集合 /// </summary> /// <returns></returns> public Dictionary <IApplication, PermissionCollection> GetAllAppPermissions() { ApplicationCollection allApps = OguPermissionSettings.GetConfig().PermissionFactory.GetAllApplications(); lock (this.userAppPermissions) { foreach (IApplication app in allApps) { if (this.userAppPermissions.ContainsKey(app) == false) { PermissionCollection permissions = OguPermissionSettings.GetConfig().PermissionObjectImpls.GetUserPermissions(app, User); this.userAppPermissions.Add(app, permissions); } } } return(this.userAppPermissions); }