Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }