-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved value tests for attributes and properties.
- Loading branch information
Showing
24 changed files
with
288 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
ids-lib-documentation/IdsLib.IfcSchema/SchemaInfo/GetAttributesXmlTypes.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SchemaInfo.GetAttributesXmlTypes method | ||
|
||
Returns a distinct enumerable of the backing types of the required attributes, given a set of attribut names | ||
|
||
```csharp | ||
public IEnumerable<BaseTypes> GetAttributesXmlTypes(IEnumerable<string> attributeNames) | ||
``` | ||
|
||
| parameter | description | | ||
| --- | --- | | ||
| attributeNames | The names of the attributes to evaluate | | ||
|
||
## Return Value | ||
|
||
string names of the types found in the evaluation of the attributes | ||
|
||
## See Also | ||
|
||
* enum [BaseTypes](../../IdsLib.IdsSchema.XsNodes/XsTypes.BaseTypes.md) | ||
* class [SchemaInfo](../SchemaInfo.md) | ||
* namespace [IdsLib.IfcSchema](../../ids-lib.md) | ||
|
||
<!-- DO NOT EDIT: generated by xmldocmd for ids-lib.dll --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace IdsLib.codegen | ||
{ | ||
internal class XmlSchema_XsTypesGenerator | ||
{ | ||
internal static string Execute(Dictionary<string, typeMetadata> dataTypeDictionary) | ||
{ | ||
var sbXmlTypes = new StringBuilder(); | ||
var xmlTypes = dataTypeDictionary.Values.Select(x => x.XmlBackingType).Where(str => !string.IsNullOrWhiteSpace(str)).Distinct(); | ||
foreach (var dataType in xmlTypes.OrderBy(x => x)) | ||
{ | ||
var t = XmlSchema_XsTypesGenerator.GetRegexString(dataType); | ||
if (string.IsNullOrWhiteSpace(t)) | ||
continue; | ||
var name = dataType.Replace("xs:", ""); | ||
name = name[..1].ToUpper() + name[1..]; | ||
sbXmlTypes.AppendLine($"\t\tprivate readonly static Regex regex{name} = new(@\"{t}\", RegexOptions.Compiled);"); | ||
} | ||
|
||
var source = stub; | ||
source = source.Replace($"<PlaceHolderXmlRegexes>", sbXmlTypes.ToString().TrimEnd('\r', '\n')); | ||
return source; | ||
} | ||
|
||
internal static string GetRegexString(string dataType) | ||
{ | ||
return dataType switch | ||
{ | ||
"xs:boolean" => @"^(true|false|0|1)$", | ||
"xs:date" => @"^\d{4}-\d{2}-\d{2}(Z|([+-]\d{2}:\d{2}))?$", | ||
"xs:dateTime" => @"^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|([+-]\d{2}:\d{2}))?$", | ||
"xs:double" => @"^([-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)?|NaN|\+INF|-INF)$", | ||
"xs:duration" => @"^[-+]?P(\d+Y)?(\d+M)?(\d+D)?(T(\d+H)?(\d+M)?(\d+S)?)?$", | ||
"xs:integer" => @"^[+-]?(\d+)$", | ||
"xs:string" => @"^.?$", | ||
"xs:time" => @"^\d{2}:\d{2}:\d{2}(\.\d+)?(Z|([+-]\d{2}:\d{2}))?$", | ||
_ => "" | ||
}; | ||
} | ||
|
||
private const string stub = @"// <auto-generated/> | ||
// This code was automatically generated. | ||
// Any changes made to this file will be lost. | ||
using System.Text.RegularExpressions; | ||
namespace IdsLib.IdsSchema.XsNodes | ||
{ | ||
public static partial class XsTypes | ||
{ | ||
<PlaceHolderXmlRegexes> | ||
} | ||
} | ||
"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.