Search code examples
c#expressifc

How to implement: Express (ISO 10303-21) TYPE typename = SELECT in C#


At the moment I am writing a really basic Early Binding for IFC, that is mapped following the Express-standard described in ISO 10303-21. As I've only just started coding two months ago, everything I do is fairly basic still. However, I can already create all the entities and types with all their properties within the given schema. I'm also able to map that to a file, following the ISO. There are still a problem I'm coming across:

  • in the schema, there are types that are SELECT types, looking like the follwoing:

    TYPE IfcGridPlacementDirectionSelect = SELECT
    (IfcDirection
    ,IfcVirtualGridIntersection);
    END_TYPE; 
    

    IfcDirection and IfcVirtualGridIntersection are both entities or types themselves ( I create a class for a type and an entity likewise). My TYPE IfcGridPlacementDirectionSelect - class looks something like this:

    public class IfcGridPlacementDirectionSelect :IfcBase
    {
       public IfcBase _value { get; set; }
    }
    

Is there any way to implement the select structure into csharp so the property-type of _value is either "IfcDirection" or "IfcVirtualGridIntersection" instead of what I'm making it now "IfcBase". So that the SELECT-structure would be represented?


Solution

  • Your solution is legal. But I think that you shouldn't create classes like that. It breaks IFC's structure.

    In my implementation, whenever using IfcGridPlacementDirectionSelect, I create 2 functions: one for IfcDirection and another for IfcVirtualGridIntersection.