public static bool TryLoadGraph(string name, out IGraph graph, string connectionString, string publishContainer) { CloudStorageAccount account = CloudStorageAccount.Parse(connectionString); CloudBlobClient client = account.CreateCloudBlobClient(); CloudBlobContainer container = client.GetContainerReference(publishContainer); if (container.CreateIfNotExists()) { Console.WriteLine("Created '{0}' publish container", publishContainer); } CloudBlockBlob blob = container.GetBlockBlobReference(name); if (blob.Exists()) { MemoryStream stream = new MemoryStream(); blob.DownloadToStream(stream); stream.Seek(0, SeekOrigin.Begin); //RdfJsonParser rdfJsonParser = new RdfJsonParser(); JsonLdReader reader = new JsonLdReader(); graph = new Graph(); reader.Load(graph, new StreamReader(stream)); return(true); } graph = null; return(false); }
public static IGraph CreateGraph(JToken compacted) { JToken flattened = JsonLdProcessor.Flatten(compacted, new JsonLdOptions()); IRdfReader rdfReader = new JsonLdReader(); IGraph graph = new Graph(); rdfReader.Load(graph, new StringReader(flattened.ToString())); return(graph); }
public static IGraph CreateGraph(JToken compacted, bool readOnly) { JToken flattened = JsonLdProcessor.Flatten(compacted, new JsonLdOptions()); IRdfReader rdfReader = new JsonLdReader(); IGraph graph = new Graph(); rdfReader.Load(graph, new StringReader(flattened.ToString(Newtonsoft.Json.Formatting.None, new Newtonsoft.Json.JsonConverter[0]))); if (readOnly) { graph = new ReadOnlyGraph(graph); } return(graph); }