Droit ConvertToDroit(DroitResource resource) { Droit droit = new Droit(resource.ResourceName); foreach (int right in resource.RightValue.ToFlags()) { droit.AddAccessCode(new AccessCode(right)); } return(droit); }
/// <summary> /// 角色实体数据映射 /// </summary> /// <param name="reader"></param> /// <returns></returns> public static DroitResource Resource_Map(DataReader reader) { DroitResource resource = new DroitResource(reader.GetString("ResourceID")) { ResourceName = reader.GetString("ResourceName"), RoleID = reader.GetString("RoleID"), RightValue = reader.GetInt("RightValue"), State = reader.GetInt("State") }; return resource; }
static DroitResourceRepository() { DroitResource entity = new DroitResource(Guid.NewGuid().ToString()); Type type = entity.GetType(); AppendDataMap(type, "ResourceID", () => entity.ResourceID); AppendDataMap(type, "ResourceName", () => entity.ResourceName); AppendDataMap(type, "RoleID", () => entity.RoleID); AppendDataMap(type, "RightValue", () => entity.RightValue); AppendDataMap(type, "State", () => entity.State); ResultMapDelegate<DroitResource> queryMap = Resource_Map; QueryMapContainer[entity.GetType()] = queryMap; }
/// <summary> /// 角色实体数据映射 /// </summary> /// <param name="reader"></param> /// <returns></returns> public static DroitResource Resource_Map(DataReader reader) { DroitResource resource = new DroitResource(reader.GetString("ResourceID")) { ResourceName = reader.GetString("ResourceName"), RoleID = reader.GetString("RoleID"), RightValue = reader.GetInt("RightValue"), State = reader.GetInt("State") }; return(resource); }
static DroitResourceRepository() { DroitResource entity = new DroitResource(Guid.NewGuid().ToString()); Type type = entity.GetType(); AppendDataMap(type, "ResourceID", () => entity.ResourceID); AppendDataMap(type, "ResourceName", () => entity.ResourceName); AppendDataMap(type, "RoleID", () => entity.RoleID); AppendDataMap(type, "RightValue", () => entity.RightValue); AppendDataMap(type, "State", () => entity.State); ResultMapDelegate <DroitResource> queryMap = Resource_Map; QueryMapContainer[entity.GetType()] = queryMap; }