示例#1
0
        /// <summary>
        /// Check whether an entity (string) is a subtype of another entity
        /// </summary>
        /// <param name="context">the IFC version in context for the check</param>
        /// <param name="subTypeName">the subtype name</param>
        /// <param name="superTypeName">the supertype name</param>
        /// <param name="strict">whether the subtype is strictly subtype. Set to false if it "supertype == subtype" is acceptable</param>
        /// <returns>true if it is subtype</returns>
        static public bool IsSubTypeOf(string context, string subTypeName, string superTypeName, 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(subTypeName);

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

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

            if (theNode != null)
            {
                return(theNode.IsSubTypeOf(superTypeName));
            }

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

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

            return(false);
        }