public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (RoleElement != null) { result.AddRange(RoleElement.Validate()); } if (Type != null) { result.AddRange(Type.Validate()); } if (ReferenceElement != null) { result.AddRange(ReferenceElement.Validate()); } if (DisplayElement != null) { result.AddRange(DisplayElement.Validate()); } if (Agent != null) { result.AddRange(Agent.Validate()); } return(result); }
private static void Fill(ConfigurationDataSet.RoleRow row, RoleElement role) { row.RoleId = role.Id; row.Name = role.Name; row.Description = (string.IsNullOrEmpty(role.Description) ? string.Empty : role.Description); row.ShortName = role.ShortName; row.Rank = role.Rank; row.StartActionId = role.StartPageId; row.BuiltIn = role.BuiltIn; }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as EntityComponent; if (dest == null) { throw new ArgumentException("Can only copy to an object of the same type", "other"); } base.CopyTo(dest); if (RoleElement != null) { dest.RoleElement = (Code <Hl7.Fhir.Model.Provenance.ProvenanceEntityRole>)RoleElement.DeepCopy(); } if (What != null) { dest.What = (Hl7.Fhir.Model.ResourceReference)What.DeepCopy(); } if (Agent != null) { dest.Agent = new List <Hl7.Fhir.Model.Provenance.AgentComponent>(Agent.DeepCopy()); } return(dest); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as EntityComponent; if (dest != null) { base.CopyTo(dest); if (RoleElement != null) { dest.RoleElement = (Code <Hl7.Fhir.Model.Provenance.ProvenanceEntityRole>)RoleElement.DeepCopy(); } if (Type != null) { dest.Type = (Hl7.Fhir.Model.Coding)Type.DeepCopy(); } if (ReferenceElement != null) { dest.ReferenceElement = (Hl7.Fhir.Model.FhirUri)ReferenceElement.DeepCopy(); } if (DisplayElement != null) { dest.DisplayElement = (Hl7.Fhir.Model.FhirString)DisplayElement.DeepCopy(); } if (Agent != null) { dest.Agent = (Hl7.Fhir.Model.Provenance.AgentComponent)Agent.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
private RoleTable() { m_mapElements = new Dictionary <int, RoleElement>(); m_emptyItem = new RoleElement(); m_vecAllElements = new List <RoleElement>(); }
public bool LoadCsv(string strContent) { if (strContent.Length == 0) { return(false); } m_mapElements.Clear(); m_vecAllElements.Clear(); int contentOffset = 0; List <string> vecLine; vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if (vecLine.Count != 49) { Ex.Logger.Log("Role.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "id") { Ex.Logger.Log("Role.csv中字段[id]位置不对应"); return(false); } if (vecLine[1] != "comment") { Ex.Logger.Log("Role.csv中字段[comment]位置不对应"); return(false); } if (vecLine[2] != "race") { Ex.Logger.Log("Role.csv中字段[race]位置不对应"); return(false); } if (vecLine[3] != "occupation") { Ex.Logger.Log("Role.csv中字段[occupation]位置不对应"); return(false); } if (vecLine[4] != "gender") { Ex.Logger.Log("Role.csv中字段[gender]位置不对应"); return(false); } if (vecLine[5] != "race_icon") { Ex.Logger.Log("Role.csv中字段[race_icon]位置不对应"); return(false); } if (vecLine[6] != "race_name") { Ex.Logger.Log("Role.csv中字段[race_name]位置不对应"); return(false); } if (vecLine[7] != "race_desc") { Ex.Logger.Log("Role.csv中字段[race_desc]位置不对应"); return(false); } if (vecLine[8] != "occu_icon") { Ex.Logger.Log("Role.csv中字段[occu_icon]位置不对应"); return(false); } if (vecLine[9] != "create_occu_icon") { Ex.Logger.Log("Role.csv中字段[create_occu_icon]位置不对应"); return(false); } if (vecLine[10] != "occu_name") { Ex.Logger.Log("Role.csv中字段[occu_name]位置不对应"); return(false); } if (vecLine[11] != "occu_desc") { Ex.Logger.Log("Role.csv中字段[occu_desc]位置不对应"); return(false); } if (vecLine[12] != "occu_evaluate") { Ex.Logger.Log("Role.csv中字段[occu_evaluate]位置不对应"); return(false); } if (vecLine[13] != "model_id") { Ex.Logger.Log("Role.csv中字段[model_id]位置不对应"); return(false); } if (vecLine[14] != "strength") { Ex.Logger.Log("Role.csv中字段[strength]位置不对应"); return(false); } if (vecLine[15] != "speed ") { Ex.Logger.Log("Role.csv中字段[speed ]位置不对应"); return(false); } if (vecLine[16] != "agile") { Ex.Logger.Log("Role.csv中字段[agile]位置不对应"); return(false); } if (vecLine[17] != "stamina") { Ex.Logger.Log("Role.csv中字段[stamina]位置不对应"); return(false); } if (vecLine[18] != "spirit") { Ex.Logger.Log("Role.csv中字段[spirit]位置不对应"); return(false); } if (vecLine[19] != "maxhp") { Ex.Logger.Log("Role.csv中字段[maxhp]位置不对应"); return(false); } if (vecLine[20] != "maxmp") { Ex.Logger.Log("Role.csv中字段[maxmp]位置不对应"); return(false); } if (vecLine[21] != "physic_attack") { Ex.Logger.Log("Role.csv中字段[physic_attack]位置不对应"); return(false); } if (vecLine[22] != "physic_defense") { Ex.Logger.Log("Role.csv中字段[physic_defense]位置不对应"); return(false); } if (vecLine[23] != "magic_attack") { Ex.Logger.Log("Role.csv中字段[magic_attack]位置不对应"); return(false); } if (vecLine[24] != "magic_defense") { Ex.Logger.Log("Role.csv中字段[magic_defense]位置不对应"); return(false); } if (vecLine[25] != "hit_value") { Ex.Logger.Log("Role.csv中字段[hit_value]位置不对应"); return(false); } if (vecLine[26] != "hit_rate") { Ex.Logger.Log("Role.csv中字段[hit_rate]位置不对应"); return(false); } if (vecLine[27] != "miss_value") { Ex.Logger.Log("Role.csv中字段[miss_value]位置不对应"); return(false); } if (vecLine[28] != "miss_rate") { Ex.Logger.Log("Role.csv中字段[miss_rate]位置不对应"); return(false); } if (vecLine[29] != "critical_value") { Ex.Logger.Log("Role.csv中字段[critical_value]位置不对应"); return(false); } if (vecLine[30] != "critical_rate") { Ex.Logger.Log("Role.csv中字段[critical_rate]位置不对应"); return(false); } if (vecLine[31] != "tenacity_value") { Ex.Logger.Log("Role.csv中字段[tenacity_value]位置不对应"); return(false); } if (vecLine[32] != "tenacity_rate") { Ex.Logger.Log("Role.csv中字段[tenacity_rate]位置不对应"); return(false); } if (vecLine[33] != "dodge_value") { Ex.Logger.Log("Role.csv中字段[dodge_value]位置不对应"); return(false); } if (vecLine[34] != "dodge_rate") { Ex.Logger.Log("Role.csv中字段[dodge_rate]位置不对应"); return(false); } if (vecLine[35] != "penetrate_value") { Ex.Logger.Log("Role.csv中字段[penetrate_value]位置不对应"); return(false); } if (vecLine[36] != "penetrate_rate") { Ex.Logger.Log("Role.csv中字段[penetrate_rate]位置不对应"); return(false); } if (vecLine[37] != "miss_level") { Ex.Logger.Log("Role.csv中字段[miss_level]位置不对应"); return(false); } if (vecLine[38] != "critical_level") { Ex.Logger.Log("Role.csv中字段[critical_level]位置不对应"); return(false); } if (vecLine[39] != "dodge_level") { Ex.Logger.Log("Role.csv中字段[dodge_level]位置不对应"); return(false); } if (vecLine[40] != "move_speed") { Ex.Logger.Log("Role.csv中字段[move_speed]位置不对应"); return(false); } if (vecLine[41] != "physic_oppose") { Ex.Logger.Log("Role.csv中字段[physic_oppose]位置不对应"); return(false); } if (vecLine[42] != "magic_oppose") { Ex.Logger.Log("Role.csv中字段[magic_oppose]位置不对应"); return(false); } if (vecLine[43] != "physic_add") { Ex.Logger.Log("Role.csv中字段[physic_add]位置不对应"); return(false); } if (vecLine[44] != "magic_add") { Ex.Logger.Log("Role.csv中字段[magic_add]位置不对应"); return(false); } if (vecLine[45] != "scene_id") { Ex.Logger.Log("Role.csv中字段[scene_id]位置不对应"); return(false); } if (vecLine[46] != "posx") { Ex.Logger.Log("Role.csv中字段[posx]位置不对应"); return(false); } if (vecLine[47] != "posz") { Ex.Logger.Log("Role.csv中字段[posz]位置不对应"); return(false); } if (vecLine[48] != "direct") { Ex.Logger.Log("Role.csv中字段[direct]位置不对应"); return(false); } while (true) { vecLine = GameAssist.readCsvLine(strContent, ref contentOffset); if ((int)vecLine.Count == 0) { break; } if ((int)vecLine.Count != (int)49) { return(false); } RoleElement member = new RoleElement(); member.id = Convert.ToInt32(vecLine[0]); member.comment = vecLine[1]; member.race = Convert.ToInt32(vecLine[2]); member.occupation = Convert.ToInt32(vecLine[3]); member.gender = Convert.ToInt32(vecLine[4]); member.race_icon = vecLine[5]; member.race_name = Convert.ToInt32(vecLine[6]); member.race_desc = Convert.ToInt32(vecLine[7]); member.occu_icon = vecLine[8]; member.create_occu_icon = vecLine[9]; member.occu_name = Convert.ToInt32(vecLine[10]); member.occu_desc = Convert.ToInt32(vecLine[11]); member.occu_evaluate = vecLine[12]; member.model_id = Convert.ToInt32(vecLine[13]); member.strength = Convert.ToInt32(vecLine[14]); member.speed = Convert.ToInt32(vecLine[15]); member.agile = Convert.ToInt32(vecLine[16]); member.stamina = Convert.ToInt32(vecLine[17]); member.spirit = Convert.ToInt32(vecLine[18]); member.maxhp = Convert.ToInt32(vecLine[19]); member.maxmp = Convert.ToInt32(vecLine[20]); member.physic_attack = Convert.ToInt32(vecLine[21]); member.physic_defense = Convert.ToInt32(vecLine[22]); member.magic_attack = Convert.ToInt32(vecLine[23]); member.magic_defense = Convert.ToInt32(vecLine[24]); member.hit_value = Convert.ToInt32(vecLine[25]); member.hit_rate = Convert.ToInt32(vecLine[26]); member.miss_value = Convert.ToInt32(vecLine[27]); member.miss_rate = Convert.ToInt32(vecLine[28]); member.critical_value = Convert.ToInt32(vecLine[29]); member.critical_rate = Convert.ToInt32(vecLine[30]); member.tenacity_value = Convert.ToInt32(vecLine[31]); member.tenacity_rate = Convert.ToInt32(vecLine[32]); member.dodge_value = Convert.ToInt32(vecLine[33]); member.dodge_rate = Convert.ToInt32(vecLine[34]); member.penetrate_value = Convert.ToInt32(vecLine[35]); member.penetrate_rate = Convert.ToInt32(vecLine[36]); member.miss_level = Convert.ToInt32(vecLine[37]); member.critical_level = Convert.ToInt32(vecLine[38]); member.dodge_level = Convert.ToInt32(vecLine[39]); member.move_speed = Convert.ToInt32(vecLine[40]); member.physic_oppose = Convert.ToInt32(vecLine[41]); member.magic_oppose = Convert.ToInt32(vecLine[42]); member.physic_add = Convert.ToInt32(vecLine[43]); member.magic_add = Convert.ToInt32(vecLine[44]); member.scene_id = Convert.ToInt32(vecLine[45]); member.posx = Convert.ToSingle(vecLine[46]); member.posz = Convert.ToSingle(vecLine[47]); member.direct = Convert.ToSingle(vecLine[48]); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.id] = member; } return(true); }
public bool LoadBin(byte[] binContent) { m_mapElements.Clear(); m_vecAllElements.Clear(); int nCol, nRow; int readPos = 0; readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nCol); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out nRow); List <string> vecLine = new List <string>(nCol); List <int> vecHeadType = new List <int>(nCol); string tmpStr; int tmpInt; for (int i = 0; i < nCol; i++) { readPos += GameAssist.ReadString(binContent, readPos, out tmpStr); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out tmpInt); vecLine.Add(tmpStr); vecHeadType.Add(tmpInt); } if (vecLine.Count != 49) { Ex.Logger.Log("Role.csv中列数量与生成的代码不匹配!"); return(false); } if (vecLine[0] != "id") { Ex.Logger.Log("Role.csv中字段[id]位置不对应"); return(false); } if (vecLine[1] != "comment") { Ex.Logger.Log("Role.csv中字段[comment]位置不对应"); return(false); } if (vecLine[2] != "race") { Ex.Logger.Log("Role.csv中字段[race]位置不对应"); return(false); } if (vecLine[3] != "occupation") { Ex.Logger.Log("Role.csv中字段[occupation]位置不对应"); return(false); } if (vecLine[4] != "gender") { Ex.Logger.Log("Role.csv中字段[gender]位置不对应"); return(false); } if (vecLine[5] != "race_icon") { Ex.Logger.Log("Role.csv中字段[race_icon]位置不对应"); return(false); } if (vecLine[6] != "race_name") { Ex.Logger.Log("Role.csv中字段[race_name]位置不对应"); return(false); } if (vecLine[7] != "race_desc") { Ex.Logger.Log("Role.csv中字段[race_desc]位置不对应"); return(false); } if (vecLine[8] != "occu_icon") { Ex.Logger.Log("Role.csv中字段[occu_icon]位置不对应"); return(false); } if (vecLine[9] != "create_occu_icon") { Ex.Logger.Log("Role.csv中字段[create_occu_icon]位置不对应"); return(false); } if (vecLine[10] != "occu_name") { Ex.Logger.Log("Role.csv中字段[occu_name]位置不对应"); return(false); } if (vecLine[11] != "occu_desc") { Ex.Logger.Log("Role.csv中字段[occu_desc]位置不对应"); return(false); } if (vecLine[12] != "occu_evaluate") { Ex.Logger.Log("Role.csv中字段[occu_evaluate]位置不对应"); return(false); } if (vecLine[13] != "model_id") { Ex.Logger.Log("Role.csv中字段[model_id]位置不对应"); return(false); } if (vecLine[14] != "strength") { Ex.Logger.Log("Role.csv中字段[strength]位置不对应"); return(false); } if (vecLine[15] != "speed ") { Ex.Logger.Log("Role.csv中字段[speed ]位置不对应"); return(false); } if (vecLine[16] != "agile") { Ex.Logger.Log("Role.csv中字段[agile]位置不对应"); return(false); } if (vecLine[17] != "stamina") { Ex.Logger.Log("Role.csv中字段[stamina]位置不对应"); return(false); } if (vecLine[18] != "spirit") { Ex.Logger.Log("Role.csv中字段[spirit]位置不对应"); return(false); } if (vecLine[19] != "maxhp") { Ex.Logger.Log("Role.csv中字段[maxhp]位置不对应"); return(false); } if (vecLine[20] != "maxmp") { Ex.Logger.Log("Role.csv中字段[maxmp]位置不对应"); return(false); } if (vecLine[21] != "physic_attack") { Ex.Logger.Log("Role.csv中字段[physic_attack]位置不对应"); return(false); } if (vecLine[22] != "physic_defense") { Ex.Logger.Log("Role.csv中字段[physic_defense]位置不对应"); return(false); } if (vecLine[23] != "magic_attack") { Ex.Logger.Log("Role.csv中字段[magic_attack]位置不对应"); return(false); } if (vecLine[24] != "magic_defense") { Ex.Logger.Log("Role.csv中字段[magic_defense]位置不对应"); return(false); } if (vecLine[25] != "hit_value") { Ex.Logger.Log("Role.csv中字段[hit_value]位置不对应"); return(false); } if (vecLine[26] != "hit_rate") { Ex.Logger.Log("Role.csv中字段[hit_rate]位置不对应"); return(false); } if (vecLine[27] != "miss_value") { Ex.Logger.Log("Role.csv中字段[miss_value]位置不对应"); return(false); } if (vecLine[28] != "miss_rate") { Ex.Logger.Log("Role.csv中字段[miss_rate]位置不对应"); return(false); } if (vecLine[29] != "critical_value") { Ex.Logger.Log("Role.csv中字段[critical_value]位置不对应"); return(false); } if (vecLine[30] != "critical_rate") { Ex.Logger.Log("Role.csv中字段[critical_rate]位置不对应"); return(false); } if (vecLine[31] != "tenacity_value") { Ex.Logger.Log("Role.csv中字段[tenacity_value]位置不对应"); return(false); } if (vecLine[32] != "tenacity_rate") { Ex.Logger.Log("Role.csv中字段[tenacity_rate]位置不对应"); return(false); } if (vecLine[33] != "dodge_value") { Ex.Logger.Log("Role.csv中字段[dodge_value]位置不对应"); return(false); } if (vecLine[34] != "dodge_rate") { Ex.Logger.Log("Role.csv中字段[dodge_rate]位置不对应"); return(false); } if (vecLine[35] != "penetrate_value") { Ex.Logger.Log("Role.csv中字段[penetrate_value]位置不对应"); return(false); } if (vecLine[36] != "penetrate_rate") { Ex.Logger.Log("Role.csv中字段[penetrate_rate]位置不对应"); return(false); } if (vecLine[37] != "miss_level") { Ex.Logger.Log("Role.csv中字段[miss_level]位置不对应"); return(false); } if (vecLine[38] != "critical_level") { Ex.Logger.Log("Role.csv中字段[critical_level]位置不对应"); return(false); } if (vecLine[39] != "dodge_level") { Ex.Logger.Log("Role.csv中字段[dodge_level]位置不对应"); return(false); } if (vecLine[40] != "move_speed") { Ex.Logger.Log("Role.csv中字段[move_speed]位置不对应"); return(false); } if (vecLine[41] != "physic_oppose") { Ex.Logger.Log("Role.csv中字段[physic_oppose]位置不对应"); return(false); } if (vecLine[42] != "magic_oppose") { Ex.Logger.Log("Role.csv中字段[magic_oppose]位置不对应"); return(false); } if (vecLine[43] != "physic_add") { Ex.Logger.Log("Role.csv中字段[physic_add]位置不对应"); return(false); } if (vecLine[44] != "magic_add") { Ex.Logger.Log("Role.csv中字段[magic_add]位置不对应"); return(false); } if (vecLine[45] != "scene_id") { Ex.Logger.Log("Role.csv中字段[scene_id]位置不对应"); return(false); } if (vecLine[46] != "posx") { Ex.Logger.Log("Role.csv中字段[posx]位置不对应"); return(false); } if (vecLine[47] != "posz") { Ex.Logger.Log("Role.csv中字段[posz]位置不对应"); return(false); } if (vecLine[48] != "direct") { Ex.Logger.Log("Role.csv中字段[direct]位置不对应"); return(false); } for (int i = 0; i < nRow; i++) { RoleElement member = new RoleElement(); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.id); readPos += GameAssist.ReadString(binContent, readPos, out member.comment); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.race); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.occupation); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.gender); readPos += GameAssist.ReadString(binContent, readPos, out member.race_icon); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.race_name); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.race_desc); readPos += GameAssist.ReadString(binContent, readPos, out member.occu_icon); readPos += GameAssist.ReadString(binContent, readPos, out member.create_occu_icon); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.occu_name); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.occu_desc); readPos += GameAssist.ReadString(binContent, readPos, out member.occu_evaluate); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.model_id); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.strength); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.speed); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.agile); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.stamina); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.spirit); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.maxhp); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.maxmp); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.physic_attack); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.physic_defense); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.magic_attack); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.magic_defense); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.hit_value); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.hit_rate); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.miss_value); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.miss_rate); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.critical_value); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.critical_rate); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.tenacity_value); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.tenacity_rate); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.dodge_value); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.dodge_rate); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.penetrate_value); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.penetrate_rate); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.miss_level); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.critical_level); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.dodge_level); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.move_speed); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.physic_oppose); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.magic_oppose); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.physic_add); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.magic_add); readPos += GameAssist.ReadInt32Variant(binContent, readPos, out member.scene_id); readPos += GameAssist.ReadFloat(binContent, readPos, out member.posx); readPos += GameAssist.ReadFloat(binContent, readPos, out member.posz); readPos += GameAssist.ReadFloat(binContent, readPos, out member.direct); member.IsValidate = true; m_vecAllElements.Add(member); m_mapElements[member.id] = member; } return(true); }
private void ValidateRoleHierarchy(ApplicationElement application, RoleElement role) { List<String> names = new List<String>(); RoleElement current = role; while (true) { ValidateName(current.Name); if (names.Contains(current.Name)) throw new ProviderException("Loop in role hierarchy"); names.Add(current.Name); if (String.Empty == current.Inherits) return; if (current.Name == current.Inherits) throw new ProviderException("Loop in role hierarchy"); current = application.Roles[current.Inherits]; if (null == current) throw new ProviderException("Invalid name for role parent"); } }
private Boolean IsUserInRole(String userName, RoleElement role) { return null != (from NameElement user in role.Users where user.Name == userName select user).FirstOrDefault(); }
private List<String> GetInheritanceList(RoleElement role) { List<String> roles = new List<String>(); RoleElement current = role; while (true) { roles.Add(current.Name); if (String.Empty == current.Inherits) break; current = Application.Roles[current.Inherits]; } return roles; }
/// <summary> ///异步验证 /// </summary> public static async Task DoValidationAsync(IRoleElementRespository roleElementRespository, RoleElement roleElement, string validatorType) { var roleElementValidator = new RoleElementValidator(roleElementRespository); var validatorReresult = await roleElementValidator.DoValidateAsync(roleElement, validatorType); if (!validatorReresult.IsValid) { throw new DomainException(validatorReresult); } }