Skip to content

Commit

Permalink
Give datatypes a IsBuiltIn property
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco De Salvo committed May 27, 2024
1 parent 69868e1 commit 1f7ab41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions RDFSharp.Test/Model/RDFDatatypeRegisterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public void ShouldGetDatatype()
{
Assert.IsNotNull(RDFDatatypeRegister.GetDatatype(RDFVocabulary.XSD.INTEGER.ToString()));
Assert.IsNotNull(RDFDatatypeRegister.GetDatatype(RDFModelEnums.RDFDatatypes.XSD_INTEGER));
}
//Test that these are built-in datatypes
Assert.IsTrue(RDFDatatypeRegister.GetDatatype(RDFVocabulary.XSD.INTEGER.ToString()).IsBuiltIn);
}

[TestMethod]
public void ShouldNotGetDatatype()
Expand All @@ -63,7 +65,9 @@ public void ShouldAddDatatype()

Assert.IsTrue(RDFDatatypeRegister.DatatypesCount >= 51);
Assert.IsNotNull(RDFDatatypeRegister.GetDatatype("ex:length6"));
}
//Test that this isn't built-in datatype
Assert.IsFalse(RDFDatatypeRegister.GetDatatype("ex:length6").IsBuiltIn);
}
#endregion
}
}
5 changes: 5 additions & 0 deletions RDFSharp/Model/RDFDatatype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public class RDFDatatype
/// Facets applied on the target datatype
/// </summary>
internal List<RDFFacet> Facets { get; set; }

/// <summary>
/// Indicates that the datatype is built-in into RDFModelEnums.RDFDatatypes
/// </summary>
internal bool IsBuiltIn { get; set; }
#endregion

#region Ctors
Expand Down
2 changes: 1 addition & 1 deletion RDFSharp/Model/RDFDatatypeRegister.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static RDFDatatypeRegister()
Register = new List<RDFDatatype>() };

foreach (RDFModelEnums.RDFDatatypes datatype in Enum.GetValues(typeof(RDFModelEnums.RDFDatatypes)).Cast<RDFModelEnums.RDFDatatypes>())
Instance.Register.Add(new RDFDatatype(new Uri(RDFModelUtilities.GetDatatypeFromEnum(datatype)), datatype, null));
Instance.Register.Add(new RDFDatatype(new Uri(RDFModelUtilities.GetDatatypeFromEnum(datatype)), datatype, null) { IsBuiltIn = true });
}
#endregion

Expand Down

0 comments on commit 1f7ab41

Please sign in to comment.