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


C# IGraph.CreateUriNode方法代码示例

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


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

示例1: 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

示例2: 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

示例3: GetPackageRegistrationUri

 public static Uri GetPackageRegistrationUri(IGraph graph)
 {
     return ((IUriNode)graph.GetTriplesWithPredicateObject(
         graph.CreateUriNode(new Uri("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")),
         graph.CreateUriNode(new Uri("http://schema.nuget.org/schema#PackageRegistration")))
         .First().Subject).Uri;
 }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:7,代码来源:GraphSplitting.cs

示例4: 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

示例5: 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

示例6: ApplyToGraph

        /// <summary>
        /// Add data from nuget.packed.json
        /// </summary>
        public override void ApplyToGraph(IGraph graph, IUriNode mainNode)
        {
            Uri mainUri = mainNode.Uri;
            IUriNode typeNode = graph.CreateUriNode(Schema.Predicates.Type);

            // supported frameworks
            if (SupportedFrameworks != null)
            {
                foreach (string framework in SupportedFrameworks)
                {
                    graph.Assert(new Triple(mainNode, graph.CreateUriNode(Schema.Predicates.SupportedFramework), graph.CreateLiteralNode(framework)));
                }
            }

            // assets
            //if (AssetGroups != null)
            //{
            //    int groupId = 0;
            //    foreach (var group in AssetGroups)
            //    {
            //        // group type and id
            //        var groupNode = GetSubNode(graph, mainUri, "assetGroup", "" + groupId);
            //        graph.Assert(groupNode, typeNode, graph.CreateUriNode(PackageAssetGroupType));
            //        graph.Assert(mainNode, graph.CreateUriNode(AssetGroupPredicate), groupNode);
            //        groupId++;

            //        int propId = 0;

            //        // group properties
            //        foreach (var prop in group.Properties)
            //        {
            //            var propNode = GetSubNode(graph, groupNode, "property", "" + propId);
            //            propId++;
            //            graph.Assert(propNode, typeNode, graph.CreateUriNode(PackageAssetGroupPropertyType));
            //            graph.Assert(groupNode, graph.CreateUriNode(AssetGroupPropertyPredicate), propNode);
            //            graph.Assert(propNode, graph.CreateUriNode(AssetKeyPredicate), graph.CreateLiteralNode(prop.Key));
            //            graph.Assert(propNode, graph.CreateUriNode(AssetValuePredicate), graph.CreateLiteralNode(prop.Value));
            //        }

            //        int assetId = 0;

            //        // group items
            //        foreach (var item in group.Items)
            //        {
            //            var itemNode = GetSubNode(graph, groupNode, "asset", "" + assetId);
            //            assetId++;
            //            graph.Assert(itemNode, typeNode, graph.CreateUriNode(PackageAssetType));
            //            graph.Assert(groupNode, graph.CreateUriNode(AssetPredicate), itemNode);

            //            graph.Assert(itemNode, graph.CreateUriNode(AssetTypePredicate), graph.CreateLiteralNode(item.ArtifactType));
            //            graph.Assert(itemNode, graph.CreateUriNode(AssetPathPredicate), graph.CreateLiteralNode(item.Path));
            //        }
            //    }
            //}
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:58,代码来源:PackedData.cs

示例7: 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

示例8: 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

示例9: GetStats

        public void GetStats(IGraph g)
        {
            g.NamespaceMap.AddNamespace("opt", new Uri(SparqlOptimiser.OptimiserStatsNamespace));
            INode subjectCount = g.CreateUriNode("opt:subjectCount");
            INode predicateCount = g.CreateUriNode("opt:predicateCount");
            INode objectCount = g.CreateUriNode("opt:objectCount");
            INode count = g.CreateUriNode("opt:count");

            this.AddStats(g, this.NodeCounts, count);
            this.AddStats(g, this.ObjectCounts, objectCount);
            this.AddStats(g, this.PredicateCounts, predicateCount);
            this.AddStats(g, this.SubjectCounts, subjectCount);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:13,代码来源:StatsHandler.cs

示例10: 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

示例11: OpenConnectionForm

        /// <summary>
        /// Creates a new Open Connection Form
        /// </summary>
        /// <param name="g">Graph contaning Connection Definitions</param>
        public OpenConnectionForm(IGraph g)
        {
            InitializeComponent();

            //Find connections defined in the Configuration Graph
            this._g = g;
            INode genericManager = ConfigurationLoader.CreateConfigurationNode(g, ConfigurationLoader.ClassGenericManager);
            INode rdfsLabel = g.CreateUriNode(new Uri(NamespaceMapper.RDFS + "label"));

            SparqlParameterizedString getConnections = new SparqlParameterizedString();
            getConnections.QueryText = "SELECT ?obj ?label WHERE { ?obj a @type . OPTIONAL { ?obj @label ?label } } ORDER BY ?label";
            getConnections.SetParameter("type", genericManager);
            getConnections.SetParameter("label", rdfsLabel);

            Object results = this._g.ExecuteQuery(getConnections.ToString());
            if (results is SparqlResultSet)
            {
                SparqlResultSet rset = (SparqlResultSet)results;
                foreach (SparqlResult r in rset)
                {
                    this._connectionNodes.Add(r["obj"]);
                    if (r.HasValue("label"))
                    {
                        this.lstConnections.Items.Add(r["label"]);
                    }
                    else
                    {
                        this.lstConnections.Items.Add(r["obj"]);
                    }
                }
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:36,代码来源:OpenConnectionForm.cs

示例12: 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

示例13: 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

示例14: ReplaceIRI

        public static void ReplaceIRI(IGraph graph, Uri oldIRI, Uri newIRI)
        {
            // replace the local IRI with the NuGet IRI
            string localUri = oldIRI.AbsoluteUri;

            var triples = graph.Triples.ToArray();

            string mainIRI = newIRI.AbsoluteUri;

            foreach (var triple in triples)
            {
                IUriNode subject = triple.Subject as IUriNode;
                IUriNode objNode = triple.Object as IUriNode;
                INode newSubject = triple.Subject;
                INode newObject = triple.Object;

                bool replace = false;

                if (subject != null && subject.Uri.AbsoluteUri.StartsWith(localUri))
                {
                    // TODO: store these mappings in a dictionary
                    Uri iri = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}{1}", mainIRI, subject.Uri.AbsoluteUri.Substring(localUri.Length)));
                    newSubject = graph.CreateUriNode(iri);
                    replace = true;
                }

                if (objNode != null && objNode.Uri.AbsoluteUri.StartsWith(localUri))
                {
                    // TODO: store these mappings in a dictionary
                    Uri iri = new Uri(String.Format(CultureInfo.InvariantCulture, "{0}{1}", mainIRI, objNode.Uri.AbsoluteUri.Substring(localUri.Length)));
                    newObject = graph.CreateUriNode(iri);
                    replace = true;
                }

                if (replace)
                {
                    graph.Assert(newSubject, triple.Predicate, newObject);
                    graph.Retract(triple);
                }
            }
        }
开发者ID:jinujoseph,项目名称:NuGet.Services.Metadata,代码行数:41,代码来源:CantonUtilities.cs

示例15: 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


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