public bool AddToContext(Requirements.RequirementsSet requirements, IfcActorRole role) { // it is there already if (IsContextFor(requirements)) { return(false); } var lib = requirements.Entity; var relations = role != null?_relations.Where(r => r.ActingRole == role) : _relations; if (!relations.Any()) { var rel = Model.Internal.Instances.New <IfcRelAssignsToActor>(r => { r.RelatingActor = Entity; r.ActingRole = role; }); relations = new[] { rel }; _relations.Add(rel); } var relation = relations.FirstOrDefault(); relation.RelatedObjects.Add(lib); _cache.Add(lib.EntityLabel); return(true); }
public bool AddToContext(Requirements.RequirementsSet requirements, IfcRoleEnum role) { var actorRole = Entity.Model.Instances.FirstOrDefault <IfcActorRole>(r => r.Role == role); if (actorRole == null) { actorRole = Model.New <IfcActorRole>(r => { r.Role = role; }); } return(AddToContext(requirements, actorRole)); }
public bool RemoveFromContext(Requirements.RequirementsSet requirements) { var lib = requirements.Entity; // it is there already if (!IsContextFor(requirements)) { return(false); } foreach (var rel in _relations) { rel.RelatedObjects.Remove(lib); } _cache.Remove(lib.EntityLabel); return(true); }
public bool AddToContext(Requirements.RequirementsSet requirements) { return(AddToContext(requirements, null as IfcActorRole)); }
public bool IsContextFor(Requirements.RequirementsSet requirements) => _cache.Contains(requirements.Entity.EntityLabel);