Ejemplo n.º 1
0
        /// <summary>
        /// Create an Rdf data store, with config.
        /// </summary>
        public RdfData(INodeFactory factory)
        {
            _factory = factory ?? new NodeFactory();

            _data = new List <Quad>();

            System  = _factory.Uri(DefaultSysGraphUri);
            Default = _factory.Uri(DefaultGraphUri);
        }
Ejemplo n.º 2
0
        /// <summary>Create an new <see cref="RdfsList"/>.</summary>
        public RdfsList(INodeFactory f, Graph owner)
        {
            _f     = f;
            _owner = owner;

            _first = f.Uri(RDFS.First);
            _next  = f.Uri(RDFS.Rest);
            _nil   = f.Uri(RDFS.Nil);
        }
Ejemplo n.º 3
0
        private void BreadthFirstReadInfo(Queue <DirectoryInfo> q,
                                          GraphBuilder g, INodeFactory f, int maxDepth = -1)
        {
            var contains       = f.Uri("app:contains");
            var itemType       = f.Uri("app:type");
            var itemTypeFolder = f.New("folder");
            var itemTypeFile   = f.New("file");

            var lastModify = f.Uri(PosixStat.LastModified);
            var size       = f.Uri(PosixStat.Size);

            var depth = 0;

            while (q.Count > 0)
            {
                var root = q.Dequeue();

                var subject = f.Uri(root.AsUri());
                try
                {
                    foreach (var file in root.EnumerateFiles())
                    {
                        g.For(subject)
                        .With(contains).To(f.Uri(file.AsUri()))
                        .With(itemType).Add(itemTypeFile)
                        .Then()
                        .With(lastModify).Add(f.New(file.LastWriteTime))
                        .Then()
                        .With(size).Add(f.New(file.Length));
                    }

                    foreach (var dir in root.EnumerateDirectories())
                    {
                        g.For(subject).With(contains).To(f.Uri(dir.AsUri()))
                        .With(itemType).Add(itemTypeFolder);
                    }

                    if (maxDepth > 0 && depth < maxDepth)
                    {
                        foreach (var subDir in root.GetDirectories())
                        {
                            q.Enqueue(subDir);
                        }
                        depth++;
                    }
                }
                catch (UnauthorizedAccessException ex)
                {
                    g.For(subject)
                    .With("app:AccessGranted", out _).Add(false)
                    .Then().With("app:error", out _)
                    .Add(ex.Message)
                    .Add(ex);
                }
            }
        }
Ejemplo n.º 4
0
 /// <inheritdoc />
 public UriNode Uri(ReadOnlySpan <char> uriValue)
 => _factory.Uri(uriValue);