diff --git a/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFDivideExpressionTest.cs b/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFDivideExpressionTest.cs index 5b99b56a..2dd47bce 100644 --- a/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFDivideExpressionTest.cs +++ b/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFDivideExpressionTest.cs @@ -392,7 +392,7 @@ public void ShouldApplyExpressionWithEVAndNotCalculateResultBecauseZeroRightExpr DataRow row = table.NewRow(); row["?A"] = new RDFTypedLiteral("50", RDFModelEnums.RDFDatatypes.XSD_DOUBLE).ToString(); row["?B"] = new RDFTypedLiteral("25", RDFModelEnums.RDFDatatypes.XSD_INT).ToString(); - row["?C"] = new RDFTypedLiteral("0", RDFModelEnums.RDFDatatypes.XSD_INT).ToString(); + row["?C"] = RDFTypedLiteral.Zero.ToString(); table.Rows.Add(row); table.AcceptChanges(); @@ -468,7 +468,7 @@ public void ShouldApplyExpressionWithVVAndNotCalculateResultBecauseZeroRightColu table.Columns.Add("?B", typeof(string)); DataRow row = table.NewRow(); row["?A"] = new RDFTypedLiteral("5", RDFModelEnums.RDFDatatypes.XSD_DOUBLE).ToString(); - row["?B"] = new RDFTypedLiteral("0", RDFModelEnums.RDFDatatypes.XSD_NONNEGATIVEINTEGER).ToString(); + row["?B"] = RDFTypedLiteral.Zero.ToString(); table.Rows.Add(row); table.AcceptChanges(); diff --git a/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFGeoDimensionExpressionTest.cs b/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFGeoDimensionExpressionTest.cs index ae190870..3fa6d847 100644 --- a/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFGeoDimensionExpressionTest.cs +++ b/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFGeoDimensionExpressionTest.cs @@ -75,7 +75,7 @@ public void ShouldApplyExpressionWithEXPAndCalculateResult() RDFPatternMember expressionResult = expression.ApplyExpression(table.Rows[0]); Assert.IsNotNull(expressionResult); - Assert.IsTrue(expressionResult.Equals(new RDFTypedLiteral("0", RDFModelEnums.RDFDatatypes.XSD_INTEGER))); + Assert.IsTrue(expressionResult.Equals(RDFTypedLiteral.Zero)); } [TestMethod] diff --git a/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFLengthExpressionTest.cs b/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFLengthExpressionTest.cs index daf73dd9..492d21d6 100644 --- a/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFLengthExpressionTest.cs +++ b/RDFSharp.Test/Query/Mirella/Algebra/Expressions/RDFLengthExpressionTest.cs @@ -75,7 +75,7 @@ public void ShouldApplyExpressionWithExpressionAndCalculateResultOnNull() RDFPatternMember expressionResult = expression.ApplyExpression(table.Rows[0]); Assert.IsNotNull(expressionResult); - Assert.IsTrue(expressionResult.Equals(new RDFTypedLiteral("0", RDFModelEnums.RDFDatatypes.XSD_INTEGER))); + Assert.IsTrue(expressionResult.Equals(RDFTypedLiteral.Zero)); } [TestMethod] diff --git a/RDFSharp/Model/RDFGraph.cs b/RDFSharp/Model/RDFGraph.cs index 1909c29c..ae14f24e 100644 --- a/RDFSharp/Model/RDFGraph.cs +++ b/RDFSharp/Model/RDFGraph.cs @@ -201,9 +201,7 @@ public RDFGraph AddContainer(RDFContainer container) if (container != null) { //Reify the container to get its graph representation - RDFGraph reifCont = container.ReifyContainer(); - //Iterate on the constructed triples - foreach (RDFTriple t in reifCont) + foreach (RDFTriple t in container.ReifyContainer()) AddTriple(t); } return this; @@ -217,9 +215,7 @@ public RDFGraph AddCollection(RDFCollection collection) if (collection != null) { //Reify the collection to get its graph representation - RDFGraph reifColl = collection.ReifyCollection(); - //Iterate on the constructed triples - foreach (RDFTriple t in reifColl) + foreach (RDFTriple t in collection.ReifyCollection()) AddTriple(t); } return this; diff --git a/RDFSharp/Model/RDFNamespaceRegister.cs b/RDFSharp/Model/RDFNamespaceRegister.cs index 74374343..0b872f5a 100644 --- a/RDFSharp/Model/RDFNamespaceRegister.cs +++ b/RDFSharp/Model/RDFNamespaceRegister.cs @@ -157,7 +157,7 @@ public static void AddNamespace(RDFNamespace nSpace) public static void RemoveByUri(string uri) { if (uri != null) - Instance.Register.RemoveAll(ns => ns.NamespaceUri.ToString().Equals(uri.Trim(), StringComparison.OrdinalIgnoreCase)); + Instance.Register.RemoveAll(ns => string.Equals(ns.NamespaceUri.ToString(), uri.Trim(), StringComparison.OrdinalIgnoreCase)); } /// @@ -166,7 +166,7 @@ public static void RemoveByUri(string uri) public static void RemoveByPrefix(string prefix) { if (prefix != null) - Instance.Register.RemoveAll(ns => ns.NamespacePrefix.Equals(prefix.Trim(), StringComparison.OrdinalIgnoreCase)); + Instance.Register.RemoveAll(ns => string.Equals(ns.NamespacePrefix, prefix.Trim(), StringComparison.OrdinalIgnoreCase)); } /// @@ -176,7 +176,7 @@ public static RDFNamespace GetByUri(string uri, bool enablePrefixCCService = fal { if (uri != null) { - RDFNamespace result = Instance.Register.Find(ns => ns.NamespaceUri.ToString().Equals(uri.Trim(), StringComparison.OrdinalIgnoreCase)); + RDFNamespace result = Instance.Register.Find(ns => string.Equals(ns.NamespaceUri.ToString(), uri.Trim(), StringComparison.OrdinalIgnoreCase)); if (result == null && enablePrefixCCService) result = LookupPrefixCC(uri.Trim().TrimEnd(new char[] { '#' }), 2); return result; @@ -191,7 +191,7 @@ public static RDFNamespace GetByPrefix(string prefix, bool enablePrefixCCService { if (prefix != null) { - RDFNamespace result = Instance.Register.Find(ns => ns.NamespacePrefix.Equals(prefix.Trim(), StringComparison.OrdinalIgnoreCase)); + RDFNamespace result = Instance.Register.Find(ns => string.Equals(ns.NamespacePrefix, prefix.Trim(), StringComparison.OrdinalIgnoreCase)); if (result == null && enablePrefixCCService) result = LookupPrefixCC(prefix.Trim(), 1); return result; @@ -213,10 +213,10 @@ internal static RDFNamespace LookupPrefixCC(string data, int lookupMode) { string response = webclient.DownloadString(lookupString); string prefix = response.Split('\t')[0]; - string nspace = response.Split('\t')[1].TrimEnd(new char[] { '\n' }); + string nspace = response.Split('\t')[1].TrimEnd(Environment.NewLine); RDFNamespace result = new RDFNamespace(prefix, nspace); - //Also add the namespace to the register, to avoid future lookups + //Also add the namespace to the register (to avoid future lookups) AddNamespace(result); //Return the found result diff --git a/RDFSharp/Model/RDFTypedLiteral.cs b/RDFSharp/Model/RDFTypedLiteral.cs index e3087e26..d726e373 100644 --- a/RDFSharp/Model/RDFTypedLiteral.cs +++ b/RDFSharp/Model/RDFTypedLiteral.cs @@ -36,6 +36,11 @@ public class RDFTypedLiteral : RDFLiteral /// Represents an handy typed literal for boolean False /// public static readonly RDFTypedLiteral False = new RDFTypedLiteral("false", RDFModelEnums.RDFDatatypes.XSD_BOOLEAN); + + /// + /// Represents an handy typed literal for integer Zero + /// + public static readonly RDFTypedLiteral Zero = new RDFTypedLiteral("0", RDFModelEnums.RDFDatatypes.XSD_INTEGER); #endregion #region Ctors