当前位置: 首页>>代码示例>>C#>>正文


C# IGraph.GetTriplesWithSubjectPredicate方法代码示例

本文整理汇总了C#中IGraph.GetTriplesWithSubjectPredicate方法的典型用法代码示例。如果您正苦于以下问题:C# IGraph.GetTriplesWithSubjectPredicate方法的具体用法?C# IGraph.GetTriplesWithSubjectPredicate怎么用?C# IGraph.GetTriplesWithSubjectPredicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IGraph的用法示例。


在下文中一共展示了IGraph.GetTriplesWithSubjectPredicate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetLists

        private static IDictionary<INode, List<INode>> GetLists(IGraph graph)
        {
            INode first = graph.CreateUriNode(new Uri(First));
            INode rest = graph.CreateUriNode(new Uri(Rest));
            INode nil = graph.CreateUriNode(new Uri(Nil));

            IDictionary<INode, List<INode>> lists = new Dictionary<INode, List<INode>>();
            IEnumerable<Triple> ends = graph.GetTriplesWithPredicateObject(rest, nil);
            foreach (Triple end in ends)
            {
                List<INode> list = new List<INode>();
                Triple iterator = graph.GetTriplesWithSubjectPredicate(end.Subject, first).First();
                INode head = iterator.Subject;
                while (true)
                {
                    list.Add(iterator.Object);
                    IEnumerable<Triple> restTriples = graph.GetTriplesWithPredicateObject(rest, iterator.Subject);
                    if (!restTriples.Any())
                    {
                        break;
                    }

                    iterator = graph.GetTriplesWithSubjectPredicate(restTriples.First().Subject, first).First();
                    head = iterator.Subject;
                }

                list.Reverse();
                lists.Add(head, list);
            }

            return lists;
        }
开发者ID:alien-mcl,项目名称:URSA,代码行数:32,代码来源:JsonLdWriter.cs

示例2: ExpansionDataset

        public ExpansionDataset(IGraph expansionDescription, INode datasetSubj)
            : base(expansionDescription, datasetSubj)
        {
            //Check for aat:ignoreDataset
            IEnumerable<Triple> ts = expansionDescription.GetTriplesWithSubjectPredicate(datasetSubj, expansionDescription.CreateUriNode("aat:ignoreDataset"));
            Triple t = ts.FirstOrDefault();
            if (t != null)
            {
                if (t.Object.NodeType == NodeType.Literal)
                {
                    ILiteralNode l = (ILiteralNode)t.Object;
                    if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeBoolean))
                    {
                        this._ignore = Boolean.Parse(l.Value);
                    }
                }
            }

            //Find URI Discovery Endpoints
            ts = expansionDescription.GetTriplesWithSubjectPredicate(datasetSubj, expansionDescription.CreateUriNode("aat:uriDiscoveryEndpoint"));
            foreach (Triple endpoint in ts)
            {
                if (endpoint.Object.NodeType == NodeType.Uri)
                {
                    this._discoveryEndpoints.Add(((IUriNode)endpoint.Object).Uri);
                }
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:28,代码来源:ExpansionDataset.cs

示例3: VoIDDataset

        public VoIDDataset(IGraph voidDescription, INode datasetSubj)
        {
            this._subj = datasetSubj;

            IEnumerable<Triple> ts;
            Triple t;

            //Get Title, Description and Homepage (if present)
            ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("dcterms:title"));
            t = ts.FirstOrDefault();
            if (t != null)
            {
                if (t.Object.NodeType == NodeType.Literal)
                {
                    this._title = ((ILiteralNode)t.Object).Value;
                }
            }
            ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("dcterms:description"));
            t = ts.FirstOrDefault();
            if (t != null)
            {
                if (t.Object.NodeType == NodeType.Literal)
                {
                    this._description = ((ILiteralNode)t.Object).Value;
                }
            }
            ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("foaf:homepage"));
            t = ts.FirstOrDefault();
            if (t != null)
            {
                if (t.Object.NodeType == NodeType.Uri)
                {
                    this._homepage = ((IUriNode)t.Object).Uri;
                }
            }

            //Find SPARQL Endpoints
            ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("void:sparqlEndpoint"));
            foreach (Triple endpoint in ts) 
            {
                if (endpoint.Object.NodeType == NodeType.Uri)
                {
                    this._sparqlEndpoints.Add(((IUriNode)endpoint.Object).Uri);
                }
            }

            //Find URI Lookup Endpoints
            ts = voidDescription.GetTriplesWithSubjectPredicate(datasetSubj, voidDescription.CreateUriNode("void:uriLookupEndpoint"));
            foreach (Triple endpoint in ts)
            {
                if (endpoint.Object.NodeType == NodeType.Uri)
                {
                    this._lookupEndpoints.Add(((IUriNode)endpoint.Object).Uri);
                }
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:56,代码来源:VoIDDataset.cs

示例4: CreatePageGraph

        IGraph CreatePageGraph(INode subject, IGraph graph)
        {
            Graph pageGraph = new Graph();

            Triple idTriple = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Id)).First();
            Triple versionTriple = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Version)).First();

            pageGraph.Assert(idTriple.CopyTriple(pageGraph));
            pageGraph.Assert(versionTriple.CopyTriple(pageGraph));

            return pageGraph;
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:12,代码来源:NuspecStage.cs

示例5: Promote

        public static RegistrationKey Promote(string resourceUri, IGraph graph)
        {
            INode subject = graph.CreateUriNode(new Uri(resourceUri));
            string id = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Id)).First().Object.ToString();

            return new RegistrationKey(id);
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:7,代码来源:RegistrationKey.cs

示例6: Replace

        private void Replace(IGraph graph, IUriNode parent, Uri predicate, string jsonField)
        {
            JToken token = null;
            if (_galleryPage.TryGetValue(jsonField, out token))
            {
                JArray array = token as JArray;
                JValue val = token as JValue;

                if (array != null || val != null)
                {
                    var pred = graph.CreateUriNode(predicate);

                    var old = graph.GetTriplesWithSubjectPredicate(parent, pred).ToArray();

                    // remove the old values
                    foreach (var triple in old)
                    {
                        graph.Retract(triple);
                    }

                    if (array != null)
                    {
                        foreach (var child in array)
                        {
                            graph.Assert(parent, pred, graph.CreateLiteralNode(child.ToString()));
                        }
                    }
                    else
                    {
                        graph.Assert(parent, pred, graph.CreateLiteralNode(val.ToString()));
                    }
                }
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:34,代码来源:GalleryGraphAddon.cs

示例7: IsListed

        static bool IsListed(INode subject, IGraph graph)
        {
            //return graph.ContainsTriple(new Triple(subject, graph.CreateUriNode(Schema.Predicates.Listed), graph.CreateLiteralNode("true", Schema.DataTypes.Boolean)));

            Triple listed = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Listed)).FirstOrDefault();
            if (listed != null)
            {
                return ((ILiteralNode)listed.Object).Value.Equals("true", StringComparison.InvariantCultureIgnoreCase);
            }
            Triple published = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Published)).FirstOrDefault();
            if (published != null)
            {
                DateTime publishedDate = DateTime.Parse(((ILiteralNode)published.Object).Value);
                return publishedDate.Year != 1900;
            }
            return true;
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:17,代码来源:RegistrationCatalogEntry.cs

示例8: VoIDLinkset

        public VoIDLinkset(IGraph voidDescription, INode linksetSubj)
        {
            IUriNode target = voidDescription.CreateUriNode("void:target");
            IUriNode subjTarget = voidDescription.CreateUriNode("void:subjectsTarget");
            IUriNode objTarget = voidDescription.CreateUriNode("void:objectsTarget");
            IUriNode linkPredicate = voidDescription.CreateUriNode("void:linkPredicate");

            if (voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, target).Any())
            {
                IEnumerable<Triple> ts = voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, target).Take(2);
                this._subjectTarget = ts.First().Object;
                this._objectsTarget = ts.Last().Object;
            }
            else
            {
                this._subjectTarget = voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, subjTarget).First().Object;
                this._objectsTarget = voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, objTarget).First().Object;
                this._directed = true;
            }

            this._predicates.AddRange(voidDescription.GetTriplesWithSubjectPredicate(linksetSubj, linkPredicate).Select(t => t.Object));
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:22,代码来源:VoIDLinkset.cs

示例9: Promote

        public static KeyValuePair<RegistrationEntryKey, RegistrationCatalogEntry> Promote(string resourceUri, IGraph graph, bool isExistingItem)
        {
            INode subject = graph.CreateUriNode(new Uri(resourceUri));
            string version = graph.GetTriplesWithSubjectPredicate(subject, graph.CreateUriNode(Schema.Predicates.Version)).First().Object.ToString();

            RegistrationEntryKey registrationEntryKey = new RegistrationEntryKey(RegistrationKey.Promote(resourceUri, graph), version);

            RegistrationCatalogEntry registrationCatalogEntry = IsDelete(subject, graph) 
                ? null 
                : new RegistrationCatalogEntry(resourceUri, graph, isExistingItem);

            return new KeyValuePair<RegistrationEntryKey, RegistrationCatalogEntry>(registrationEntryKey, registrationCatalogEntry);
        }
开发者ID:NuGet,项目名称:NuGet.Services.Metadata,代码行数:13,代码来源:RegistrationCatalogEntry.cs

示例10: TryLoadObject

 public bool TryLoadObject(IGraph g, INode objNode, Type targetType, out object obj)
 {
     if (targetType == typeof (MockStorageServer))
     {
         var server = new MockStorageServer();
         var storeIdNode = g.CreateUriNode("http://www.dotnetrdf.org/configuration#storeId");
         foreach (var t in g.GetTriplesWithSubjectPredicate(objNode, storeIdNode))
         {
             var lit = t.Object as ILiteralNode;
             if (lit != null)
             {
                 server.AddStore(lit.Value);
             }
         }
         obj = server;
         return true;
     }
     obj = null;
     return false;
 }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:20,代码来源:MockStorageServerFactory.cs

示例11: ExpansionLinkset

        public ExpansionLinkset(IGraph expansionDescription, INode linksetSubj)
            : base(expansionDescription, linksetSubj) 
        {
            this._subject = linksetSubj;

            //Check for aat:ignoreLinkset
            IEnumerable<Triple> ts = expansionDescription.GetTriplesWithSubjectPredicate(linksetSubj, expansionDescription.CreateUriNode("aat:ignoreDataset"));
            Triple t = ts.FirstOrDefault();
            if (t != null)
            {
                if (t.Object.NodeType == NodeType.Literal)
                {
                    ILiteralNode l = (ILiteralNode)t.Object;
                    if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeBoolean))
                    {
                        this._ignore = Boolean.Parse(l.Value);
                    }
                }
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:20,代码来源:ExpansionLinkset.cs

示例12: SetIdVersionFromGraph

        private void SetIdVersionFromGraph(IGraph graph)
        {
            var resource = graph.GetTriplesWithPredicateObject(
                graph.CreateUriNode(Schema.Predicates.Type), graph.CreateUriNode(GetItemType())).First();

            var id = graph.GetTriplesWithSubjectPredicate(
                resource.Subject, graph.CreateUriNode(Schema.Predicates.Id)).FirstOrDefault();
            if (id != null)
            {
                _id = ((ILiteralNode)id.Object).Value;
            }

            var version = graph.GetTriplesWithSubjectPredicate(
                resource.Subject, graph.CreateUriNode(Schema.Predicates.Version)).FirstOrDefault();
            if (version != null)
            {
                _version = ((ILiteralNode)version.Object).Value;
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:19,代码来源:DeleteCatalogItem.cs

示例13: Initialise

        protected override void Initialise(IGraph g)
        {
            if (g.BaseUri != null) this._node = g.CreateUriNode();

            //First ensure all the correct namespace prefixes are set to the correct URIs
            g.NamespaceMap.AddNamespace("rdf", new Uri(NamespaceMapper.RDF));
            g.NamespaceMap.AddNamespace("void", new Uri(VoIDNamespace));
            g.NamespaceMap.AddNamespace("foaf", new Uri(FoafNamespace));
            g.NamespaceMap.AddNamespace("dcterms", new Uri(DublinCoreTermsNamespace));
            g.NamespaceMap.AddNamespace("aat", new Uri(AATNamespace));

            //First look for an Expansion Profile description
            Triple profileDescriptor = new Triple(g.CreateUriNode(), g.CreateUriNode("rdf:type"), g.CreateUriNode("aat:ExpansionProfile"));
            if (g.ContainsTriple(profileDescriptor))
            {
                //Does it specify a Max Expansion Depth?
                Triple maxDepthSpecifier = g.GetTriplesWithSubjectPredicate(g.CreateUriNode(), g.CreateUriNode("aat:maxExpansionDepth")).FirstOrDefault();
                if (maxDepthSpecifier != null)
                {
                    if (maxDepthSpecifier.Object.NodeType == NodeType.Literal)
                    {
                        ILiteralNode l = (ILiteralNode)maxDepthSpecifier.Object;
                        if (l.DataType != null && l.DataType.ToString().Equals(XmlSpecsHelper.XmlSchemaDataTypeInteger))
                        {
                            this._maxDepth = Int32.Parse(l.Value);
                        }
                    }
                }
            }

            //Find Datasets
            foreach (Triple t in g.GetTriplesWithPredicateObject(g.CreateUriNode("rdf:type"), g.CreateUriNode("void:Dataset")))
            {
                ExpansionDataset dataset = new ExpansionDataset(g, t.Subject);
                if (this._datasets.ContainsKey(t.Subject))
                {
                    throw new NotImplementedException("Merging Expansion Datasets is not yet implemented");
                }
                else
                {
                    this._datasets.Add(t.Subject, dataset);
                }
            }

            //Find Linksets
            foreach (Triple t in g.GetTriplesWithPredicateObject(g.CreateUriNode("rdf:type"), g.CreateUriNode("void:Linkset")))
            {
                ExpansionLinkset linkset = new ExpansionLinkset(g, t.Subject);
                if (this._linksets.ContainsKey(t.Subject))
                {
                    throw new NotImplementedException("Merging Expansion Linksets is not yet implemented");
                }
                else
                {
                    this._linksets.Add(t.Subject, linkset);
                }
            }

        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:59,代码来源:ExpansionProfile.cs

示例14: GetConfigurationInt32

        /// <summary>
        /// Gets the 64 bit Integer value or a given default of the first instance of a property for a given Object in the Configuration Graph
        /// </summary>
        /// <param name="g">Configuration Graph</param>
        /// <param name="objNode">Object Node</param>
        /// <param name="property">Property Node</param>
        /// <param name="defValue">Default Value to return if there is no valid boolean value</param>
        /// <returns>
        /// If there is a valid integer value for the property then that is returned, in any other case the given <paramref name="defValue">Default Value</paramref> is returned
        /// </returns>
        public static int GetConfigurationInt32(IGraph g, INode objNode, INode property, int defValue)
        {
            INode n = g.GetTriplesWithSubjectPredicate(objNode, property).Select(t => t.Object).FirstOrDefault();
            if (n == null) return defValue;

            //Resolve AppSettings
            if (n.NodeType != NodeType.Literal)
            {
                n = ResolveAppSetting(g, n);
                if (n == null) return defValue;
            }

            if (n.NodeType == NodeType.Literal)
            {
                int temp;
                if (Int32.TryParse(((ILiteralNode)n).Value, out temp))
                {
                    return temp;
                }
                else
                {
                    return defValue;
                }
            }
            else
            {
                return defValue;
            }
        }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:39,代码来源:ConfigurationLoader.cs

示例15: GetConfigurationValue

 /// <summary>
 /// Gets the String value or null of the first instance of a property for a given Object in the Configuration Graph
 /// </summary>
 /// <param name="g">Configuration Graph</param>
 /// <param name="objNode">Object Node</param>
 /// <param name="property">Property Node</param>
 /// <returns></returns>
 public static String GetConfigurationValue(IGraph g, INode objNode, INode property)
 {
     INode n = g.GetTriplesWithSubjectPredicate(objNode, property).Select(t => t.Object).FirstOrDefault();
     if (n == null) return null;
     switch (n.NodeType)
     {
         case NodeType.Blank:
             return n.ToString();
         case NodeType.Literal:
             return ((ILiteralNode)n).Value;
         case NodeType.Uri:
             INode temp = ResolveAppSetting(g, n);
             if (temp == null) return null;
             if (temp.NodeType == NodeType.Literal)
             {
                 return ((ILiteralNode)temp).Value;
             }
             else
             {
                 return temp.ToString();
             }
         default:
             return null;
     }
 }
开发者ID:jbunzel,项目名称:MvcRQ_git,代码行数:32,代码来源:ConfigurationLoader.cs


注:本文中的IGraph.GetTriplesWithSubjectPredicate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。