public void RemoveRole(RoleActor role) { RoleDictionary.Remove(role.Id); role.HostMapCell = null; if (role is PlayerInstance) { Players.Remove(role as PlayerInstance); } else { switch (role.GameType) { case eActorGameType.Npc: NPCs.Remove(role as NPCInstance); break; case eActorGameType.PlayerImage: Images.Remove(role as PlayerImage); break; // case CSCommon.Component.eActorGameType.EffectNpc: // EffectNpcs.Remove(role); // break; //case CSCommon.Component.eActorGameType.DropedItem: // DropedItems.Remove(role as DropedItem.DropedItemRole); // break; // case CSCommon.Component.eActorGameType.GatherItem: // GatherItems.Remove(role as Gather.GatherItem); // break; default: break; } } }
public static int Identifier(this RoleDictionary roleDictionary) { var attribute = roleDictionary.GetType().GetCustomAttribute <DictionaryIdentifierAttribute>(); if (attribute == null) { throw new ArgumentException(); } return(attribute.Identifier); }
/// <summary> /// Define a language role with a given name and description /// </summary> /// <param name="roleName">The role name</param> /// <param name="roleSecription">The role description</param> /// <param name="enableQual">A flag for full symbol qualification of the role</param> /// <returns></returns> public LanguageRole DefineLanguageRole(string roleName, string roleSecription, bool enableQual) { if (RoleDictionary.ContainsKey(roleName)) { return(RoleDictionary[roleName]); } var newRole = new LanguageRole(roleName, roleSecription, enableQual); RoleDictionary.Add(roleName, newRole); return(newRole); }
public void AddRole(RoleActor role) { if (role.HostMapCell == this) { return; } if (role.HostMapCell != null) { role.HostMapCell.RemoveRole(role); } if (!RoleDictionary.ContainsKey(role.Id)) { RoleDictionary[role.Id] = role; if (role is PlayerInstance) { Players.Add(role as PlayerInstance); } else { switch (role.GameType) { case eActorGameType.Npc: NPCs.Add(role as NPCInstance); break; case eActorGameType.PlayerImage: Images.Add(role as PlayerImage); break; // case CSCommon.Component.eActorGameType.EffectNpc: // EffectNpcs.Add(role); // break; //case CSCommon.Component.eActorGameType.DropedItem: // DropedItems.Add(role as DropedItem.DropedItemRole); // break; // case CSCommon.Component.eActorGameType.GatherItem: // GatherItems.Add(role as Gather.GatherItem); // break; default: break; } } role.HostMapCell = this; } }
public async Task <FindCategoriesToReadResult> FindCategoriesToRead() { var user = await database.UserRepository.FindById(httpContextReader.CurrentUserId) ?? throw new EntityNotFoundException("User not found"); RoleType userRole; if (user.AdminRole > 0) { userRole = RoleDictionary.FindRoleTypeByUserRole(new("admin", user.AdminRole)); } else if (user.SupporterRole > 0) { userRole = RoleDictionary.FindRoleTypeByUserRole(new ColumnValue("supporter", user.SupporterRole)); } else { throw new NoPermissionsException(ErrorMessages.NotAllowedMessage); } return(new FindCategoriesToReadResult( ReportCategoryPermissionDictionary.ReportCategoryPermissions[userRole], user.AdminRole >= 3)); }
public Info[] GetInfo(out string itemOfInterest) { // init itemOfInterest = string.Empty; // find event date var eventDate = this.Events.NullCoalesce().FirstOrDefault()?.EventDate?.ToData(); // persons var persons = this.Persons.NullCoalesce() .Select((x, i) => new { Id = x.Id, Person = x.ToData(i + 1, eventDate) }) .ToArray(); // relationships between persons var relationships = new RelationshipCollection(); // person 2 person relationships foreach (var pp in this.RelationsPP.NullCoalesce().Where(x => x.PersonKeyRef.NullCoalesce().Count() == 2)) { // find var person1 = persons.Single(x => x.Id == pp.PersonKeyRef[0]).Person; var person2 = persons.Single(x => x.Id == pp.PersonKeyRef[1]).Person; // relation relationships.Create(person1, person2, pp.RelationType, eventDate); } // events foreach (var e in this.Events.NullCoalesce()) { // init var eventPlace = e.EventPlace?.ToString(); // find actors in this event var dict = this.RelationsEP.NullCoalesce() .Where(x => x.EventKeyRef == e.Id) .GroupBy(x => x.RelationType) .ToDictionary(r => r.Key, g => g.Select(r => persons.SingleOrDefault(x => x.Id == r.PersonKeyRef)?.Person).ToArray()); var actors = new RoleDictionary(dict); // relationships var subject = this.GetSubject(e.EventType) .Where(x => actors.ContainsRole(x)) .FirstOrDefault(); if (string.IsNullOrEmpty(subject)) { // vader, moeder, relatie en ... subject if (actors.ContainsRole("Vader") || actors.ContainsRole("Moeder")) { // init var all = actors.Roles .Where(x => x != "Vader") .Where(x => x != "Moeder") .Where(x => x != "Relatie") .ToArray(); if (all.Length == 1) { subject = all.Single(); } } } // event met enkel persoon relationships.Create(actors[subject], actors["Moeder"], null, ParentChildDirection.Person2IsParentOfPerson1); relationships.Create(actors[subject], actors["Vader"], null, ParentChildDirection.Person2IsParentOfPerson1); relationships.Create(actors[subject], actors["Relatie"], true, null); // bruid en bruidegom var partnerships = relationships.Create(actors["Bruid"], actors["Bruidegom"], true, null); relationships.Create(actors["Vader van de bruid"], actors["Bruid"], null, ParentChildDirection.Person1IsParentOfPerson2); relationships.Create(actors["Moeder van de bruid"], actors["Bruid"], null, ParentChildDirection.Person1IsParentOfPerson2); relationships.Create(actors["Vader van de bruidegom"], actors["Bruidegom"], null, ParentChildDirection.Person1IsParentOfPerson2); relationships.Create(actors["Moeder van de bruidegom"], actors["Bruidegom"], null, ParentChildDirection.Person1IsParentOfPerson2); // specific dates switch (e.EventType.Split(':').Last()) { case "Doop": actors[subject].Import(e, x => x.Baptism, (x, y) => x.Baptism = y); break; case "Geboorte": actors[subject].Import(e, x => x.Birth, (x, y) => x.Birth = y); break; case "Huwelijk": case "Trouwen": partnerships.Import(e, x => x.Marriage, (x, y) => x.Marriage = y); break; case "Ondertrouw": partnerships.Import(e, x => x.MarriageBanns, (x, y) => x.MarriageBanns = y); break; case "Echtscheiding": partnerships.Import(e, x => x.Divorce, (x, y) => x.Divorce = y); break; case "Overlijden": actors[subject].Import(e, x => x.Death, (x, y) => x.Death = y); break; case "Registratie": if (!string.IsNullOrEmpty(eventPlace)) { actors[subject].ForEach(x => x.Residence = x.Residence.Ensure(new Status <string>() { Date = eventDate, Value = eventPlace })); } break; } // gender actors["Bruidegom"].ForEach(x => x.Gender = x.Gender.Ensure(Gender.Male)); actors["Vader"].ForEach(x => x.Gender = x.Gender.Ensure(Gender.Male)); actors["Vader van de bruid"].ForEach(x => x.Gender = x.Gender.Ensure(Gender.Male)); actors["Vader van de bruidegom"].ForEach(x => x.Gender = x.Gender.Ensure(Gender.Male)); actors["Bruid"].ForEach(x => x.Gender = x.Gender.Ensure(Gender.Female)); actors["Moeder"].ForEach(x => x.Gender = x.Gender.Ensure(Gender.Female)); actors["Moeder van de bruid"].ForEach(x => x.Gender = x.Gender.Ensure(Gender.Female)); actors["Moeder van de bruidegom"].ForEach(x => x.Gender = x.Gender.Ensure(Gender.Female)); // item of interest if (string.IsNullOrWhiteSpace(itemOfInterest)) { // init PersonInfo[] interests = null; // marriage or single person? if (partnerships.Length > 0) { // marriage interests = new PersonInfo[] { actors["Bruidegom"].First(), actors["Bruid"].First() }; } else { // single person interests = actors[subject]; } // create names var names = interests .Select(x => string.Format("{0} {1}", x.GivenNames.FirstOrDefault(), x.FamilyName.FirstOrDefault()).Trim()) .ToArray(); // length? switch (names.Length) { case 0: case 1: itemOfInterest = names.FirstOrDefault(); break; case 2: itemOfInterest = string.Join(" en ", names); break; default: itemOfInterest = string.Join(" en ", new string[] { string.Join(", ", names.Take(names.Length - 1)), names.Last() }); break; } } } // done return(persons .Select(x => x.Person) .Cast <Info>() .Concat(relationships.ToArray()) .ToArray()); }
private static SqlQuery BuildRevokeQuery(int id, string column) => new SqlBuilder() .Update(userTable, ColumnValueDictionary.Create(RoleDictionary.DefaultRoleColumnValue(column)), IdColumnValue(id)) .Build();