Class GraphExtensions
Provides useful Extension Methods for working with Graphs.
Inheritance
Inherited Members
Namespace: VDS.RDF
Assembly: dotNetRdf.dll
Syntax
public static class GraphExtensions
Methods
| Improve this Doc View SourceGetETag(IGraph)
Computes the ETag for a Graph.
Declaration
public static string GetETag(this IGraph g)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph. |
Returns
Type | Description |
---|---|
string |
LoadFromEmbeddedResource(IGraph, string, IRdfReader)
Loads RDF data from an Embedded Resource into a Graph.
Declaration
public static void LoadFromEmbeddedResource(this IGraph g, string resource, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
string | resource | Assembly qualified name of the resource to load from. |
IRdfReader | parser | Parser to use. |
Remarks
This is just a shortcut to using the static Load() methods from the EmbeddedResourceLoader class located in the Parsing namespace.
LoadFromEmbeddedResource(IGraph, string)
Loads RDF data from an Embedded Resource into a Graph.
Declaration
public static void LoadFromEmbeddedResource(this IGraph g, string resource)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
string | resource | Assembly qualified name of the resource to load from. |
Remarks
This is just a shortcut to using the static Load() methods from the EmbeddedResourceLoader class located in the Parsing namespace.
LoadFromFile(IGraph, string, IRdfReader)
Loads RDF data from a file into a Graph.
Declaration
public static void LoadFromFile(this IGraph g, string file, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
string | file | File to load from. |
IRdfReader | parser | Parser to use. |
Remarks
This is just a shortcut to using the static Load() methods from the FileLoader class located in the Parsing namespace.
Note: FileLoader will assign the Graph a file URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
If a File URI is assigned it will always be an absolute URI for the file.
LoadFromFile(IGraph, string)
Loads RDF data from a file into a Graph.
Declaration
public static void LoadFromFile(this IGraph g, string file)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
string | file | File to load from. |
Remarks
This is just a shortcut to using the static Load() methods from the FileLoader class located in the Parsing namespace.
Note: FileLoader will assign the Graph a file URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
If a File URI is assigned it will always be an absolute URI for the file.
LoadFromString(IGraph, string, IRdfReader)
Loads RDF data from a String into a Graph.
Declaration
public static void LoadFromString(this IGraph g, string data, IRdfReader parser)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
string | data | Data to load. |
IRdfReader | parser | Parser to use. |
Remarks
This is just a shortcut to using the static Parse() methods from the StringParser class located in the Parsing namespace.
LoadFromString(IGraph, string)
Loads RDF data from a String into a Graph.
Declaration
public static void LoadFromString(this IGraph g, string data)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
string | data | Data to load. |
Remarks
This is just a shortcut to using the static Parse() methods from the StringParser class located in the Parsing namespace.
LoadFromUri(IGraph, Uri, IRdfReader, Loader)
Loads RDF data from a URI into a Graph.
Declaration
public static void LoadFromUri(this IGraph g, Uri u, IRdfReader parser, Loader loader = null)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
System.Uri | u | URI to load from. |
IRdfReader | parser | Parser to use. |
Loader | loader | Loader to use. |
Remarks
This is just a shortcut to using the static LoadGraph() methods from the UriLoader class located in the Parsing namespace.
Note: Loader will assign the Graph the source URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
LoadFromUri(IGraph, Uri, Loader)
Loads RDF data from a URI into a Graph.
Declaration
public static void LoadFromUri(this IGraph g, Uri u, Loader loader = null)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to load into. |
System.Uri | u | URI to load from. |
Loader | loader | Loader to use. |
Remarks
This is just a shortcut to using the static LoadGraph() methods from the UriLoader class located in the Parsing namespace.
Note: UriLoader will assign the Graph the source URI as it's Base URI unless the Graph already has a Base URI or is non-empty prior to attempting parsing. Note that any Base URI specified in the RDF contained in the file will override this initial Base URI. In some cases this may lead to invalid RDF being accepted and generating strange relative URIs, if you encounter this either set a Base URI prior to calling this method or create an instance of the relevant parser and invoke it directly.
SaveToFile(IGraph, string, IRdfWriter)
Saves a Graph to a File.
Declaration
public static void SaveToFile(this IGraph g, string file, IRdfWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to save. |
string | file | File to save to. |
IRdfWriter | writer | Writer to use. |
SaveToFile(IGraph, string, IStoreWriter)
Saves a Graph to a File.
Declaration
public static void SaveToFile(this IGraph g, string file, IStoreWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to save. |
string | file | File to save to. |
IStoreWriter | writer | Writer to use. |
SaveToFile(IGraph, string)
Saves a Graph to a File.
Declaration
public static void SaveToFile(this IGraph g, string file)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to save. |
string | file | File to save to. |
SaveToStream(IGraph, TextWriter, IRdfWriter)
Saves a Graph to a stream.
Declaration
public static void SaveToStream(this IGraph g, TextWriter streamWriter, IRdfWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to save. |
System.IO.TextWriter | streamWriter | Stream to save to. |
IRdfWriter | writer | Writer to use. |
SaveToStream(IGraph, TextWriter, IStoreWriter)
Saves a Graph to a stream.
Declaration
public static void SaveToStream(this IGraph g, TextWriter streamWriter, IStoreWriter writer)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | Graph to save. |
System.IO.TextWriter | streamWriter | Stream to save to. |
IStoreWriter | writer | Writer to use. |
SaveToStream(IGraph, string, TextWriter)
Save a graph to a stream, determining the type of writer to use by the output file name.
Declaration
public static void SaveToStream(this IGraph g, string filename, TextWriter streamWriter)
Parameters
Type | Name | Description |
---|---|---|
IGraph | g | The graph to write. |
string | filename | The output file name to use to determine the output format to write. |
System.IO.TextWriter | streamWriter | The stream to write to. |