public static RDFSharp.Model.RDFGraph DeserializeGraph(string data, RDFSharp.Model.RDFModelEnums.RDFFormats format) { using (var buffer = new MemoryStream(Encoding.UTF8.GetBytes(data))) { var result = RDFSharp.Model.RDFGraph.FromStream(format, buffer); return(result); } }
public static string SerializeGraph(RDFSharp.Model.RDFGraph graph, RDFSharp.Model.RDFModelEnums.RDFFormats format) { using (var buffer = new MemoryStream()) { graph.ToStream(format, buffer); var result = Encoding.UTF8.GetString(buffer.ToArray()).Trim(); return(result); } }
public static void WriteSerializedRepresentation(RDFSharp.Model.RDFGraph graph, RDFSharp.Model.RDFModelEnums.RDFFormats format) { var serialization = SerializeGraph(graph, format); WriteLine($"{format} representation of graph '{graph.Context}'"); WriteLine(); WriteLine(serialization); }