/// <summary> /// Creates a graph from a stream of the given RDF format. /// </summary> public static RDFGraph FromStream(RDFModelEnums.RDFFormats rdfFormat, Stream inputStream) { if (inputStream != null) { switch (rdfFormat) { case RDFModelEnums.RDFFormats.NTriples: return(RDFNTriples.Deserialize(inputStream)); case RDFModelEnums.RDFFormats.RdfXml: return(RDFXml.Deserialize(inputStream)); case RDFModelEnums.RDFFormats.TriX: return(RDFTriX.Deserialize(inputStream)); case RDFModelEnums.RDFFormats.Turtle: return(RDFTurtle.Deserialize(inputStream)); default: throw new NotImplementedException(); break; } } throw new RDFModelException("Cannot read RDF graph from stream because given \"inputStream\" parameter is null."); }
/// <summary> /// Writes the graph into a stream in the given RDF format. /// </summary> public void ToStream(RDFModelEnums.RDFFormats rdfFormat, Stream outputStream) { if (outputStream != null) { switch (rdfFormat) { case RDFModelEnums.RDFFormats.NTriples: RDFNTriples.Serialize(this, outputStream); break; case RDFModelEnums.RDFFormats.RdfXml: RDFXml.Serialize(this, outputStream); break; case RDFModelEnums.RDFFormats.TriX: RDFTriX.Serialize(this, outputStream); break; case RDFModelEnums.RDFFormats.Turtle: RDFTurtle.Serialize(this, outputStream); break; default: throw new NotImplementedException(); break; } } else { throw new RDFModelException("Cannot write RDF graph to stream because given \"outputStream\" parameter is null."); } }
/// <summary> /// Creates a graph from a file of the given RDF format. /// </summary> public static RDFGraph FromFile(RDFModelEnums.RDFFormats rdfFormat, String filepath) { if (!String.IsNullOrEmpty(filepath)) { if (File.Exists(filepath)) { switch (rdfFormat) { case RDFModelEnums.RDFFormats.NTriples: return(RDFNTriples.Deserialize(filepath)); case RDFModelEnums.RDFFormats.RdfXml: return(RDFXml.Deserialize(filepath)); case RDFModelEnums.RDFFormats.TriX: return(RDFTriX.Deserialize(filepath)); case RDFModelEnums.RDFFormats.Turtle: return(RDFTurtle.Deserialize(filepath)); default: throw new NotImplementedException(); break; } } throw new RDFModelException("Cannot read RDF graph from file because given \"filepath\" parameter (" + filepath + ") does not indicate an existing file."); } throw new RDFModelException("Cannot read RDF graph from file because given \"filepath\" parameter is null or empty."); }
/// <summary> /// Writes the graph into a file in the given RDF format. /// </summary> public void ToFile(RDFModelEnums.RDFFormats rdfFormat, String filepath) { if (!String.IsNullOrEmpty(filepath)) { switch (rdfFormat) { case RDFModelEnums.RDFFormats.NTriples: RDFNTriples.Serialize(this, filepath); break; case RDFModelEnums.RDFFormats.RdfXml: RDFXml.Serialize(this, filepath); break; case RDFModelEnums.RDFFormats.TriX: RDFTriX.Serialize(this, filepath); break; case RDFModelEnums.RDFFormats.Turtle: RDFTurtle.Serialize(this, filepath); break; default: throw new NotImplementedException(); break; } } else { throw new RDFModelException("Cannot write RDF graph to file because given \"filepath\" parameter is null or empty."); } }
/// <summary> /// Creates a graph from a file of the given RDF format. /// </summary> public static RDFGraph FromFile(RDFModelEnums.RDFFormats rdfFormat, String filepath) { if (filepath != null) { if (File.Exists(filepath)) { switch (rdfFormat) { case RDFModelEnums.RDFFormats.NTriples: return(RDFNTriples.Deserialize(filepath)); case RDFModelEnums.RDFFormats.RdfXml: return(RDFXml.Deserialize(filepath)); case RDFModelEnums.RDFFormats.TriX: return(RDFTriX.Deserialize(filepath)); case RDFModelEnums.RDFFormats.Turtle: throw new RDFModelException("Cannot read RDF graph from file because Turtle format is not supported. What about joining the project to contribute it?"); } } throw new RDFModelException("Cannot read RDF graph from file because given \"filepath\" parameter (" + filepath + ") does not indicate an existing file."); } throw new RDFModelException("Cannot read RDF graph from file because given \"filepath\" parameter is null or empty."); }
/// <summary> /// Writes the graph into a file in the given RDF format. /// </summary> public void ToFile(RDFModelEnums.RDFFormats rdfFormat, String filepath) { if (filepath != null && filepath.Trim() != String.Empty) { switch (rdfFormat) { case RDFModelEnums.RDFFormats.NTriples: RDFNTriples.Serialize(this, filepath); break; case RDFModelEnums.RDFFormats.RdfXml: RDFXml.Serialize(this, filepath); break; case RDFModelEnums.RDFFormats.TriX: RDFTriX.Serialize(this, filepath); break; case RDFModelEnums.RDFFormats.Turtle: RDFTurtle.Serialize(this, filepath); break; } } else { throw new RDFModelException("Cannot write RDF graph to file because given \"filepath\" parameter is null or empty."); } }
/// <summary> /// Creates a graph from a stream of the given RDF format. /// </summary> public static RDFGraph FromStream(RDFModelEnums.RDFFormats rdfFormat, Stream inputStream) { if (inputStream != null) { switch (rdfFormat) { case RDFModelEnums.RDFFormats.NTriples: return(RDFNTriples.Deserialize(inputStream)); case RDFModelEnums.RDFFormats.RdfXml: return(RDFXml.Deserialize(inputStream)); case RDFModelEnums.RDFFormats.TriX: return(RDFTriX.Deserialize(inputStream)); case RDFModelEnums.RDFFormats.Turtle: throw new RDFModelException("Cannot read RDF graph from stream because Turtle format is not supported. What about joining the project to contribute it?"); } } throw new RDFModelException("Cannot read RDF graph from stream because given \"filepath\" parameter is null."); }
internal static RDFGraph FromStream(RDFModelEnums.RDFFormats rdfFormat, Stream inputStream, Uri graphContext) { if (inputStream != null) { switch (rdfFormat) { case RDFModelEnums.RDFFormats.RdfXml: return(RDFXml.Deserialize(inputStream, graphContext)); case RDFModelEnums.RDFFormats.Turtle: return(RDFTurtle.Deserialize(inputStream, graphContext)); case RDFModelEnums.RDFFormats.NTriples: return(RDFNTriples.Deserialize(inputStream, graphContext)); case RDFModelEnums.RDFFormats.TriX: return(RDFTriX.Deserialize(inputStream, graphContext)); } } throw new RDFModelException("Cannot read RDF graph from stream because given \"inputStream\" parameter is null."); }