Skip to content

Commit

Permalink
Refactor Namespace class and fix test failures
Browse files Browse the repository at this point in the history
* Refactored the Namespace class to just be an indexed collection of strings rather than a dynamic object as the automatic URI casting wasn't happening as hoped.
* Removed XML/Binary serialization support from more classes.
* Split BaseXXX classes out into their own source file
* Fixed all unit tests that were failing due to the change to the RDF 1.1 model
  • Loading branch information
Kal committed May 3, 2020
1 parent f3bbaaa commit cddcdbf
Show file tree
Hide file tree
Showing 38 changed files with 2,562 additions and 3,981 deletions.
56 changes: 10 additions & 46 deletions Libraries/dotNetRDF.Query.Spin/Util/Resource.cs
Expand Up @@ -27,12 +27,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using VDS.RDF;
using VDS.RDF.Nodes;
using VDS.RDF.Query.Spin;
using VDS.RDF.Query.Spin.Model;
using System.Reflection;
using VDS.RDF.Query.Datasets;

namespace VDS.RDF.Query.Spin.Util
{
Expand All @@ -44,8 +41,8 @@ internal class Resource : IResource, IComparable<IResource>, IEquatable<IResourc

#region "Basic resource wrapper implementation "

private INode _source;
private SpinProcessor _model;
private readonly INode _source;
private readonly SpinProcessor _model;

//TODO DO NOT USE THIS ONE !!!
//internal static Resource Get(INode node)
Expand All @@ -60,9 +57,9 @@ internal class Resource : IResource, IComparable<IResource>, IEquatable<IResourc
internal static Resource Get(INode node, SpinProcessor spinModel)
{
if (node == null) return null;
if (node is Resource && ((IResource)node).getModel() == spinModel)
if (node is Resource resource && resource.getModel() == spinModel)
{
return (Resource)node;
return resource;
}
return new Resource(node, spinModel);
}
Expand Down Expand Up @@ -311,32 +308,14 @@ public IResource inferRDFNode(INode property)

#region "INode implementation "

public NodeType NodeType
{
get
{
return _source.NodeType;
}
}
public NodeType NodeType => _source.NodeType;

public IGraph Graph
{
get
{
return _source.Graph;
}
}
public IGraph Graph => _source.Graph;

public Uri GraphUri
{
get
{
return _source.GraphUri;
}
set
{
_source.GraphUri = value;
}
get => _source.GraphUri;
set => _source.GraphUri = value;
}

public string ToString(Writing.Formatting.INodeFormatter formatter)
Expand Down Expand Up @@ -423,24 +402,9 @@ public bool Equals(IVariableNode other)
return _source.Equals(other);
}

public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
{
_source.GetObjectData(info, context);
}

public System.Xml.Schema.XmlSchema GetSchema()
{
return _source.GetSchema();
}

public void ReadXml(System.Xml.XmlReader reader)
{
_source.ReadXml(reader);
}

public void WriteXml(System.Xml.XmlWriter writer)
public override int GetHashCode()
{
_source.WriteXml(writer);
return _source.GetHashCode();
}

#endregion
Expand Down

0 comments on commit cddcdbf

Please sign in to comment.