public OguRoleCollection GetAppRoles(string codeName) { ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(codeName); OguRoleCollection roles = new OguRoleCollection(); if (apps.Count > 0) { roles.CopyFrom(apps[0].Roles); } return(roles); }
public void OguRoleCollectionSerializationTest() { JSONSerializerExecute.RegisterConverter(typeof(OguApplicationConverter)); JSONSerializerExecute.RegisterConverter(typeof(OguRoleConverter)); IRole[] testRoles = DeluxePrincipal.GetRoles(RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles); OguRoleCollection roles = new OguRoleCollection(testRoles); string serializedData = JSONSerializerExecute.Serialize(roles); Console.WriteLine(serializedData); OguRoleCollection deserializedData = JSONSerializerExecute.Deserialize<OguRoleCollection>(serializedData); for (int i = 0; i < roles.Count; i++) ValidatePermissionObject(roles[i], deserializedData[i]); }
protected override void OnDialogContentControlLoaded(Control container) { base.OnDialogContentControlLoaded(container); if (string.IsNullOrEmpty(this.DialogTitle)) { this.DialogTitle = RoleGraphControlParams.DefaultDialogTitle; } this._ApplicationSelector = (HtmlSelect)container.FindControl("applications"); this._RoleSelector = (HtmlSelect)container.FindControl("roles"); this._LoadingTag = (HtmlGenericControl)container.FindControl("loadingTag"); this._RelativeLink = (HtmlAnchor)container.FindControl("relativeLink"); HtmlGenericControl img = (HtmlGenericControl)container.FindControl("loadingImg"); if (img != null) { img.Style["background-image"] = string.Format("url({0})", ControlResources.HourglassLogoUrl); } OguApplicationCollection apps = new OguApplicationCollection(PermissionMechanismFactory.GetMechanism().GetAllApplications()); this._ApplicationsData = apps; if (apps.Count > 0) { string appCodeName = GetAppCodeNameFromFullCodeName(this.SelectedFullCodeName); IApplication selectedApp = null; if (string.IsNullOrEmpty(appCodeName) == false) { selectedApp = apps.Find(app => app.CodeName == appCodeName); } if (selectedApp == null) { selectedApp = apps[0]; } this._RolesData = new OguRoleCollection(selectedApp.Roles); } }
public void OguRoleCollectionSerializationTest() { JSONSerializerExecute.RegisterConverter(typeof(OguApplicationConverter)); JSONSerializerExecute.RegisterConverter(typeof(OguRoleConverter)); IRole[] testRoles = DeluxePrincipal.GetRoles(RolesDefineConfig.GetConfig().RolesDefineCollection["testRole"].Roles); OguRoleCollection roles = new OguRoleCollection(testRoles); string serializedData = JSONSerializerExecute.Serialize(roles); Console.WriteLine(serializedData); OguRoleCollection deserializedData = JSONSerializerExecute.Deserialize <OguRoleCollection>(serializedData); for (int i = 0; i < roles.Count; i++) { ValidatePermissionObject(roles[i], deserializedData[i]); } }
protected override void OnDialogContentControlLoaded(Control container) { base.OnDialogContentControlLoaded(container); if (string.IsNullOrEmpty(this.DialogTitle)) this.DialogTitle = RoleGraphControlParams.DefaultDialogTitle; this._ApplicationSelector = (HtmlSelect)container.FindControl("applications"); this._RoleSelector = (HtmlSelect)container.FindControl("roles"); this._LoadingTag = (HtmlGenericControl)container.FindControl("loadingTag"); this._RelativeLink = (HtmlAnchor)container.FindControl("relativeLink"); HtmlGenericControl img = (HtmlGenericControl)container.FindControl("loadingImg"); if (img != null) img.Style["background-image"] = string.Format("url({0})", ControlResources.HourglassLogoUrl); OguApplicationCollection apps = new OguApplicationCollection(PermissionMechanismFactory.GetMechanism().GetAllApplications()); this._ApplicationsData = apps; if (apps.Count > 0) { string appCodeName = GetAppCodeNameFromFullCodeName(this.SelectedFullCodeName); IApplication selectedApp = null; if (string.IsNullOrEmpty(appCodeName) == false) selectedApp = apps.Find(app => app.CodeName == appCodeName); if (selectedApp == null) selectedApp = apps[0]; this._RolesData = new OguRoleCollection(selectedApp.Roles); } }
public OguRoleCollection GetAppRoles(string codeName) { ApplicationCollection apps = PermissionMechanismFactory.GetMechanism().GetApplications(codeName); OguRoleCollection roles = new OguRoleCollection(); if (apps.Count > 0) roles.CopyFrom(apps[0].Roles); return roles; }