internal GraphObject(JValue data) { GraphObject t = null; switch (data.Type) { case JTokenType.String: case JTokenType.Date: case JTokenType.TimeSpan: case JTokenType.Guid: case JTokenType.Uri: t = GraphObject.FromData(data.ToString()); break; case JTokenType.Integer: t = GraphObject.FromData(data.Value <long>()); break; case JTokenType.Boolean: t = GraphObject.FromData(data.Value <bool>()); break; case JTokenType.Float: t = GraphObject.FromData(data.Value <double>()); break; default: throw new InvalidOperationException($"{data.Type} not support as object"); } IsID = t.IsID; _value = t._value; }
public static void RetractByObject(this IGraph graph, GraphObject o) { foreach (var t in graph.GetByObject(o).ToList()) { graph.Retract(t); } }
// implementation of framing/compact processing private static JToken ProcessObject(WriteContext context, IGraph graph, GraphObject o) { if (o.IsID) { return(ProcessSubject(context, graph, o.Id)); } else { return(JToken.Parse(o.ToJSON())); } }
public bool Exists(string ts, string tp, GraphObject to) { IDictionary <string, ISet <GraphObject> > po; if (_spo.TryGetValue(ts, out po)) { ISet <GraphObject> o; if (po.TryGetValue(tp, out o)) { return(o.Contains(to)); } } return(false); }
private void InnerWriteObject(GraphObject o) { if (o.IsID) { _writer.WriteStartObject(); _writer.WritePropertyName("@id"); _writer.WriteValue(o.Id); _writer.WriteEndObject(); } else { _writer.WriteRawValue(o.ToJSON()); } }
public IEnumerable <Triple> GetByObject(GraphObject to) { IDictionary <string, ISet <string> > sp; if (_osp.TryGetValue(to, out sp)) { foreach (var s in sp) { foreach (var p in s.Value) { yield return(new Triple(s.Key, p, to)); } } } }
public IEnumerable <Triple> GetByObjectSubject(GraphObject to, string ts) { IDictionary <string, ISet <string> > sp; if (_osp.TryGetValue(to, out sp)) { ISet <string> p; if (sp.TryGetValue(ts, out p)) { foreach (var tp in p) { yield return(new Triple(ts, tp, to)); } } } }
public IEnumerable <Triple> GetByPredicateObject(string tp, GraphObject to) { IDictionary <GraphObject, ISet <string> > os; if (_pos.TryGetValue(tp, out os)) { ISet <string> s; if (os.TryGetValue(to, out s)) { foreach (var ts in s) { yield return(new Triple(ts, tp, to)); } } } }
public bool Retract(string s, string p, GraphObject o) { if (s == null || p == null || o == null || o.IsNull) { return(false); } if (Retract(_spo, s, p, o)) { if (Retract(_pos, p, o, s)) { if (Retract(_osp, o, s, p)) { Count--; return(true); } } } return(false); }
public IEnumerable <Triple> GetByObjectSubject(GraphObject to, string ts) { return(_innerGraph.GetByObjectSubject(to, ts)); }
public void WriteObject(GraphObject o) { _currentObjects.Add(o); }
public Triple(string s, string p, GraphObject o) { Subject = s; Predicate = p; Object = o; }
public bool Assert(string s, string p, GraphObject o) { return(Assert(new Triple(s, p, o))); }
public bool Exists(string ts, string tp, GraphObject to) { return(_innerGraph.Exists(ts, tp, to)); }
public IEnumerable <Triple> GetByPredicateObject(string tp, GraphObject to) { return(_innerGraph.GetByPredicateObject(tp, to)); }
public IEnumerable <Triple> GetByObject(GraphObject to) { return(_innerGraph.GetByObject(to)); }
public bool Retract(string s, string p, GraphObject o) { return(Retract(new Triple(s, p, o))); }