public void CollectionRemoval()
        {
            // arrange
            using (var model = new MemoryModel(new Ifc2x3.EntityFactoryIfc2x3()))
                using (var txn = model.BeginTransaction(""))
                {
                    IfcWall wall1 = model.Instances.New <IfcWall>();
                    IfcWall wall2 = model.Instances.New <IfcWall>();

                    var propertySet = model.Instances.New <Ifc2x3.Kernel.IfcPropertySet>();
                    propertySet.HasProperties.Add(model.Instances.New <Ifc2x3.PropertyResource.IfcPropertySingleValue>());

                    // Changing the type of the rel variable from interface to IfcRelDefinesByProperties solves the issue.
                    IIfcRelDefinesByProperties rel = model.Instances.New <Ifc2x3.Kernel.IfcRelDefinesByProperties>();

                    rel.RelatingPropertyDefinition = propertySet;
                    rel.RelatedObjects.Add(wall1);
                    rel.RelatedObjects.Add(wall2);

                    // act
                    rel.RelatedObjects.Remove(wall1);

                    // assert failed. Expected: 1, actual: 2 (null, wall2).
                    Assert.AreEqual(1, rel.RelatedObjects.Count);

                    txn.Commit();
                }
        }
예제 #2
0
        private static IEnumerable <IIfcPropertySetDefinition> GetDefinitions(IIfcRelDefinesByProperties r)
        {
            if (r.RelatingPropertyDefinition == null)
            {
                return(null);
            }
            var defSelect = r.RelatingPropertyDefinition;
            var def       = defSelect as IIfcPropertySetDefinition;

            return(def != null ? new[] { def } : null);
        }
예제 #3
0
 public static IEnumerable <T> PropertySet <T>(this IIfcRelDefinesByProperties r) where T : IIfcPropertySetDefinition
 {
     if (r.RelatingPropertyDefinition is IIfcPropertySetDefinition set)
     {
         return(Enumerable.Repeat(set, 1).OfType <T>());
     }
     else if (r.RelatingPropertyDefinition is IfcPropertySetDefinitionSet setOfSet)
     {
         return(setOfSet.PropertySetDefinitions.OfType <T>());
     }
     else
     {
         return(Enumerable.Empty <T>());
     }
 }
예제 #4
0
        public IIfcRelDefinesByProperties NewPropertySet(string propertySetName, string description = null, IIfcProduct initialProduct = null)
        {
            IIfcRelDefinesByProperties pSetRel = null;

            Wrap(s =>
            {
                var set = s.NewIfcPropertySet(propertySetName, description);
                pSetRel = s.NewIfcRelDefinesByProperties(set);
                if (null != initialProduct)
                {
                    pSetRel.RelatedObjects.Add(initialProduct);
                }
            });
            return(pSetRel);
        }