Beispiel #1
0
        /// <summary>
        /// Check whether an entity (string) is a supertype of another entity
        /// </summary>
        /// <param name="context">the IFC version in context for the check</param>
        /// <param name="superTypeName">the supertype name</param>
        /// <param name="subTypeName">the subtype name</param>
        /// <param name="strict">whether the supertype is strictly supertype. Set to false if it "supertype == subtype" is acceptable</param>
        /// <returns>true if it is supertype</returns>
        static public bool IsSuperTypeOf(string context, string superTypeName, string subTypeName, bool strict = true)
        {
            IfcSchemaEntityTree ifcEntitySchemaTree = GetEntityDictFor(context);

            //var ifcEntitySchemaTree = IfcSchemaEntityTree.GetEntityDictFor(context);
            if (ifcEntitySchemaTree == null || ifcEntitySchemaTree.IfcEntityDict == null || ifcEntitySchemaTree.IfcEntityDict.Count == 0)
            {
                throw new Exception("Unable to locate IFC Schema xsd file! Make sure the relevant xsd " + context + " exists.");
            }

            IfcSchemaEntityNode theNode = ifcEntitySchemaTree.Find(superTypeName);

            if (theNode != null)
            {
                if (strict)
                {
                    return(theNode.IsSuperTypeOf(subTypeName));
                }
                else
                {
                    return(theNode.Name.Equals(subTypeName, StringComparison.InvariantCultureIgnoreCase) || theNode.IsSuperTypeOf(subTypeName));
                }
            }

            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Check whether an entity is a supertype of another entity
        /// </summary>
        /// <param name="superTypeName">candidate of the supertype entity name</param>
        /// <param name="subTypeName">candidate of the subtype entity name</param>
        /// <returns>true: if the the superTypeName is the supertype of subtTypeName</returns>
        static public bool IsSuperTypeOf(string superTypeName, string subTypeName)
        {
            IfcSchemaEntityNode theNode = Find(superTypeName);

            if (theNode != null)
            {
                return(theNode.IsSuperTypeOf(subTypeName));
            }

            return(false);
        }
        /// <summary>
        /// Check whether an entity is a supertype of another entity
        /// </summary>
        /// <param name="superTypeName">candidate of the supertype entity name</param>
        /// <param name="subTypeName">candidate of the subtype entity name</param>
        /// <returns>true: if the the superTypeName is the supertype of subtTypeName</returns>
        static public bool IsSuperTypeOf(string superTypeName, string subTypeName, bool strict = true)
        {
            IfcSchemaEntityNode theNode = Find(superTypeName);

            if (theNode != null)
            {
                if (strict)
                {
                    return(theNode.IsSuperTypeOf(subTypeName));
                }
                else
                {
                    return(theNode.Name.Equals(subTypeName, StringComparison.InvariantCultureIgnoreCase) || theNode.IsSuperTypeOf(subTypeName));
                }
            }

            return(false);
        }