diff --git a/ids-lib/IfcSchema/IfcSchemaVersionsExtensions.cs b/ids-lib/IfcSchema/IfcSchemaVersionsExtensions.cs index 05d6803..905d34a 100644 --- a/ids-lib/IfcSchema/IfcSchemaVersionsExtensions.cs +++ b/ids-lib/IfcSchema/IfcSchemaVersionsExtensions.cs @@ -10,20 +10,35 @@ namespace IdsLib.IfcSchema; public static class IfcSchemaVersionsExtensions { /// - /// Converts a set of IFC schema name strings to the relative enum value + /// Canonical string version of the schema version /// - /// Enumerable strings to be evaluated - /// A single enumeration value representing all the - public static IfcSchemaVersions GetSchema(IEnumerable schemasStrings) + public const string IfcSchema2x3String = "Ifc2x3"; + + /// + /// Canonical string version of the schema version + /// + public const string IfcSchema4String = "Ifc4"; + + /// + /// Canonical string version of the schema version + /// + public const string IfcSchema4x3String = "Ifc4x3"; + + /// + /// Converts a set of IFC schema name strings to the relative enum value + /// + /// Enumerable strings to be evaluated + /// A single enumeration value representing all the + public static IfcSchemaVersions GetSchema(IEnumerable schemaStrings) { IfcSchemaVersions ret = IfcSchemaVersions.IfcNoVersion; - foreach (var scheme in schemasStrings) + foreach (var scheme in schemaStrings) { IfcSchemaVersions v = scheme switch { - "Ifc2x3" => IfcSchemaVersions.Ifc2x3, - "Ifc4" => IfcSchemaVersions.Ifc4, - "Ifc4x3" => IfcSchemaVersions.Ifc4x3, + IfcSchema2x3String => IfcSchemaVersions.Ifc2x3, + IfcSchema4String => IfcSchemaVersions.Ifc4, + IfcSchema4x3String => IfcSchemaVersions.Ifc4x3, _ => IfcSchemaVersions.IfcNoVersion, }; if (v == IfcSchemaVersions.IfcNoVersion) @@ -33,12 +48,40 @@ public static IfcSchemaVersions GetSchema(IEnumerable schemasStrings) return ret; } - /// - /// Makes it easy to use the directly from a schema enum. - /// - /// the enum to evaluate - /// the identified schema infos - /// true if the values are matched + /// + /// Converts a set of IFC schema strings, concatenated in a single space separated string (useful for XML attribute reading). + /// + /// A single string possibly containing multiple space separated values to be evaluated + /// A single enumeration value representing all the + public static IfcSchemaVersions ParseXmlSchemasFromAttribute(this string spaceSeparatedSchemaStrings) + { + var tmp = spaceSeparatedSchemaStrings.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); + return GetSchema(tmp); + } + + /// + /// Encodes a schemas enum to a string formatted as an enumerable XML attribute. + /// + /// The versions enum to convert to XML attribute encoding + /// the encoded string + public static string EncodeAsXmlSchemasAttribute(this IfcSchemaVersions versions) + { + List schemas = new(); + if (versions.HasFlag(IfcSchemaVersions.Ifc2x3)) + schemas.Add(IfcSchema2x3String); + if (versions.HasFlag(IfcSchemaVersions.Ifc4)) + schemas.Add(IfcSchema4String); + if (versions.HasFlag(IfcSchemaVersions.Ifc4x3)) + schemas.Add(IfcSchema4x3String); + return string.Join(" ", schemas); + } + + /// + /// Makes it easy to use the directly from a schema enum. + /// + /// the enum to evaluate + /// the identified schema infos + /// true if the values are matched public static bool TryGetSchemaInformation(this IfcSchemaVersions schemas, out IEnumerable schemaInfo) { return SchemaInfo.TryGetSchemaInformation(schemas, out schemaInfo); diff --git a/ids-lib/LibraryInformation.cs b/ids-lib/LibraryInformation.cs index fd7abc9..a4aa73d 100644 --- a/ids-lib/LibraryInformation.cs +++ b/ids-lib/LibraryInformation.cs @@ -32,6 +32,6 @@ public static class LibraryInformation /// /// Static field with hardcoded DLL version number. /// - public static string AssemblyVersion => "1.0.48"; + public static string AssemblyVersion => "1.0.49"; } } diff --git a/ids-lib/ids-lib.csproj b/ids-lib/ids-lib.csproj index 2dce12a..7221790 100644 --- a/ids-lib/ids-lib.csproj +++ b/ids-lib/ids-lib.csproj @@ -20,7 +20,7 @@ First implementation. README.md - 1.0.48 + 1.0.49 $(AssemblyVersion) $(AssemblyVersion) true diff --git a/ids-tool/ids-tool.csproj b/ids-tool/ids-tool.csproj index f08eba1..6d6a5d7 100644 --- a/ids-tool/ids-tool.csproj +++ b/ids-tool/ids-tool.csproj @@ -16,7 +16,7 @@ icon.png IDS, buildingSmart - 1.0.48 + 1.0.49 $(AssemblyVersion) $(AssemblyVersion) https://github.com/buildingSMART/IDS-Audit-tool.git