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


C# Model.Triple类代码示例

本文整理汇总了C#中BrightstarDB.Model.Triple的典型用法代码示例。如果您正苦于以下问题:C# Triple类的具体用法?C# Triple怎么用?C# Triple使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: TestSimpleQuery

        public void TestSimpleQuery()
        {
            var sid = Guid.NewGuid().ToString();
            using (var store = _storeManager.CreateStore(Configuration.StoreLocation + "\\" + sid))
            {
                var t = new Triple
                            {
                                Subject = "http://www.networkedplanet.com/people/10",
                                Predicate = "http://www.networkedplanet.com/model/isa",
                                Object = "http://www.networkedplanet.com/types/person"
                            };
                store.InsertTriple(t);

                store.Commit(Guid.Empty);
            }
            using (var store = _storeManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                var triples = store.GetResourceStatements("http://www.networkedplanet.com/people/10");
                Assert.AreEqual(1, triples.Count());

                // do query 
                const string query =
                    "select ?t where { ?t <http://www.networkedplanet.com/model/isa> <http://www.networkedplanet.com/types/person> }";
                store.ExecuteSparqlQuery(query, SparqlResultsFormat.Xml);
            }
        }
开发者ID:phatcher,项目名称:BrightstarDB,代码行数:26,代码来源:QueryTests.cs

示例2: TestLookupByIdentifierAndType

        public void TestLookupByIdentifierAndType()
        {
            var sid = Guid.NewGuid().ToString();
            using (var store = _storeManager.CreateStore(Configuration.StoreLocation + "\\" + sid))
            {

                var t = new Triple
                            {
                                Subject = "http://www.networkedplanet.com/people/10",
                                Predicate = "http://www.networkedplanet.com/model/isa",
                                Object = "http://www.networkedplanet.com/types/person"
                            };
                store.InsertTriple(t);

                store.Commit(Guid.Empty);
            }

            using (var store = _storeManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                // do query 
                const string query =
                    "select ?t where { ?t <http://www.networkedplanet.com/model/isa> <http://www.networkedplanet.com/types/person> . FILTER ( ?t = <http://www.networkedplanet.com/people/10> ) }";
                var doc = XDocument.Parse(store.ExecuteSparqlQuery(query, SparqlResultsFormat.Xml));

                Assert.IsTrue(doc.SparqlResultRows().Count() == 1);
                Assert.AreEqual("http://www.networkedplanet.com/people/10",
                                doc.SparqlResultRows().FirstOrDefault().GetColumnValue("t").ToString());
            }
        }
开发者ID:phatcher,项目名称:BrightstarDB,代码行数:29,代码来源:QueryTests.cs

示例3: Triple

 public void Triple(Triple t)
 {
     string dt = null;
     if (t.IsLiteral && t.DataType != null) dt = t.DataType.ToString();
     _sink.Triple(t.Subject, t.Subject.StartsWith("_:"),
                  t.Predicate, t.Predicate.StartsWith("_:"),
                  t.Object.ToString(), !t.IsLiteral && t.ToString().StartsWith("_:"),
                  t.IsLiteral, dt, t.LangCode, t.Graph.ToString());
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:9,代码来源:BrightstarTripleSinkAdapter.cs

示例4: TestInsert1000000TriplesWithUniqueSubjectResources

        public void TestInsert1000000TriplesWithUniqueSubjectResources()
        {
            var sid = Guid.NewGuid().ToString();
            var store = _storeManager.CreateStore(BrightstarDB.Configuration.StoreLocation + "\\" + sid);

            var start = DateTime.UtcNow;
            for (int i = 0; i < 1000000; i++)
            {
                var t = new Triple
                {
                    Subject = "http://www.networkedplanet.com/people/" + i,
                    Predicate = "http://www.networkedplanet.com/model/isa",
                    Object = "http://www.networkedplanet.com/types/person"
                };
                store.InsertTriple(t);
            }
            var end = DateTime.UtcNow;
            Console.WriteLine("Insert triples took " + (end - start).TotalMilliseconds);

            start = DateTime.UtcNow;
            store.Commit(Guid.Empty);
            end = DateTime.UtcNow;
            Console.WriteLine("Commit triples took " + (end - start).TotalMilliseconds);
        }
开发者ID:phatcher,项目名称:BrightstarDB,代码行数:24,代码来源:ScalingTests.cs

示例5: InsertTriple

 /// <summary>
 /// Inserts a triple into the store
 /// </summary>
 /// <param name="triple"></param>
 public void InsertTriple(Triple triple)
 {
     InsertTriple(triple.Subject, triple.Predicate, triple.Object, triple.IsLiteral, triple.DataType,
                  triple.LangCode, triple.Graph ?? Constants.DefaultGraphUri);
 }
开发者ID:rexwhitten,项目名称:BrightstarDB,代码行数:9,代码来源:Store.cs

示例6: AddLiteralProperty

        private void AddLiteralProperty(IDataObject type, string value, string dataType, string langCode = null)
        {
            CheckLoaded();

            var triple = new Triple
                             {
                                 Graph = _store.UpdateGraphUri,
                                 IsLiteral = true,
                                 Object = value,
                                 DataType = dataType,
                                 LangCode = langCode,
                                 Predicate = type.Identity,
                                 Subject = Identity
                             };

            // add to DataObject state triples
            _triples.Add(triple);

            // add to txn
            _store.AddTriples.Add(triple);
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:21,代码来源:DataObject.cs

示例7: SetVersionTriple

        private void SetVersionTriple(Triple triple)
        {
            // see if there are any triples for this property
            bool haveMatch = _triples.Any(t => t.Predicate.Equals(triple.Predicate));
            if (haveMatch)
            {
                // remove all triples in current state that match the predicate
                _triples.RemoveAll(t => t.Predicate.Equals(triple.Predicate));

                // remove any existing property triple in the add triples collection
                _store.AddTriples.RemoveAll(t => t.Subject.Equals(triple.Subject) && t.Predicate.Equals(triple.Predicate));
            }

            // Because this is a set, we use a wildcard to delete any existing properties with the same predicate
            if (!_isNew && !_store.DeletePatterns.Any(t => t.Subject.Equals(triple.Subject) && t.Predicate.Equals(triple.Predicate) && t.Object.Equals(Constants.WildcardUri)))
            {
                _store.DeletePatterns.Add(new Triple
                {
                    Subject = triple.Subject,
                    Predicate = triple.Predicate,
                    Object = Constants.WildcardUri,
                    Graph = _store.VersionGraphUri
                });
            }

            // add new triple to current triples
            _triples.Add(triple);

            // add new triple to txn add triples
            _store.AddTriples.Add(triple);
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:31,代码来源:DataObject.cs

示例8: SetPropertyLiteral

        private void SetPropertyLiteral(IDataObject type, string value, string dataType, string langCode = null)
        {
            CheckLoaded();

            if (type.Identity.Equals(Constants.VersionPredicateUri))
            {
                // Update of version property has slightly different handling due to different target graph
                var triple = new Triple
                    {
                        Subject = Identity,
                        Predicate = Constants.VersionPredicateUri,
                        IsLiteral = true,
                        Object = value,
                        DataType = dataType,
                        LangCode = langCode,
                        Graph = _store.VersionGraphUri
                    };
                SetVersionTriple(triple);
            }
            else
            {
                // create a new value triple
                var triple = new Triple
                    {
                        Subject = Identity,
                        Predicate = type.Identity,
                        IsLiteral = true,
                        Object = value,
                        DataType = dataType,
                        LangCode = langCode,
                        Graph = _store.UpdateGraphUri
                    };

                // use common method for updating local state and the txn
                SetTriple(triple);
            }
            // return this DataObject
            return;
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:39,代码来源:DataObject.cs

示例9: SetRelatedObject

        /// <summary>
        /// Sets the property of this object to the specified data object
        /// </summary>
        /// <param name="type">The type of the property to set</param>
        /// <param name="value">The new value of the property</param>
        /// <returns>This IDataObject to allow chained calls</returns>
        /// <remarks>This method will remove all existing properties of type <paramref name="type"/> from this data object
        /// and add a single replacement property of the same type with <paramref name="value"/> as the property value.</remarks>
        private IDataObject SetRelatedObject(IDataObject type, IDataObject value)
        {
            CheckLoaded();

            // create a new value triple
            var triple = new Triple
                             {
                                 Graph = Constants.DefaultGraphUri,
                                 IsLiteral = false,
                                 Object = value.Identity,
                                 Predicate = type.Identity,
                                 Subject = Identity
                             };

            // use common method for updating local state and the txn
            SetTriple(triple);

            // return this DataObject
            return this;
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:28,代码来源:DataObject.cs

示例10: TestMatchTriplesWithNulls

        public virtual void TestMatchTriplesWithNulls()
        {
            var sid = Guid.NewGuid().ToString();
            var t1 = new Triple
            {
                Subject = "http://www.networkedplanet.com/people/10",
                Predicate = "http://www.networkedplanet.com/model/isa",
                Object = "bob",
                DataType = RdfDatatypes.String,
                IsLiteral = true
            };
            var t2 = new Triple
            {
                Subject = "http://www.networkedplanet.com/people/10",
                Predicate = "http://www.networkedplanet.com/model/isa",
                Object = "kal",
                DataType = RdfDatatypes.String,
                IsLiteral = true
            };
            using (var store = StoreManager.CreateStore(Configuration.StoreLocation + "\\" + sid))
            {
                store.InsertTriple(t1);
                store.InsertTriple(t2);

                store.Commit(Guid.Empty);
            }
            // match triple
            using (var store = StoreManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                var matches = store.Match(t1.Subject, t1.Predicate, t1.Object, true, RdfDatatypes.String, null,
                                          Constants.DefaultGraphUri);
                Assert.AreEqual(1, matches.Count());
                matches = store.Match(t1.Subject, t1.Predicate, t1.Object, true, RdfDatatypes.String, null, graphs: null);
                Assert.AreEqual(1, matches.Count(), "Failed to match triple using null graphs array");
            }

            using (var store = StoreManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                var triples = store.GetResourceStatements("http://www.networkedplanet.com/people/10");
                Assert.AreEqual(2, triples.Count());
            }
        }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:42,代码来源:StoreTestsBase.cs

示例11: TestInsertAndRetrieveXmlLiteral

        public virtual void TestInsertAndRetrieveXmlLiteral()
        {
            var sid = Guid.NewGuid().ToString();
            var doc = new XDocument(
                new XComment("This is a comment"),
                new XElement("Root",
                             new XElement("Child1", "data1"),
                             new XElement("Child2", "data2"),
                             new XElement("Child3", "data3"),
                             new XElement("Child2", "data4"),
                             new XElement("Info5", "info5"),
                             new XElement("Info6", "info6"),
                             new XElement("Info7", "info7"),
                             new XElement("Info8", "info8")
                    )
                );

            var t = new Triple
                        {
                            Subject = "http://www.networkedplanet.com/people/10",
                            Predicate = "http://www.networkedplanet.com/model/isa",
                            Object = doc.ToString(),
                            DataType = RdfDatatypes.XmlLiteral,
                            IsLiteral = true
                        };
            using (var store = StoreManager.CreateStore(Configuration.StoreLocation + "\\" + sid))
            {
                store.InsertTriple(t);

                store.Commit(Guid.Empty);
            }

            // match triple
            using (var store = StoreManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                var matches = store.Match(t.Subject, t.Predicate, t.Object, true,
                                          RdfDatatypes.XmlLiteral, null, Constants.DefaultGraphUri)
                    .ToList();
                Assert.AreEqual(1, matches.Count());

                // check document is ok.
                var outDoc = XDocument.Parse(matches.First().Object);

                Assert.IsNotNull(outDoc);
                Assert.IsNotNull(outDoc.Root);
                Assert.AreEqual(8, outDoc.Root.Elements().Count());
            }
        }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:48,代码来源:StoreTestsBase.cs

示例12: TestInsertAndRetrieveLiteralObjectTriple

        public virtual void TestInsertAndRetrieveLiteralObjectTriple()
        {
            var sid = Guid.NewGuid().ToString();
            var t = new Triple
            {
                Subject = "http://www.networkedplanet.com/people/10",
                Predicate = "http://www.networkedplanet.com/model/isa",
                Object = "graham",
                LangCode = "en",
                IsLiteral = true
            };
            using (var store = StoreManager.CreateStore(Configuration.StoreLocation + "\\" + sid))
            {
                store.InsertTriple(t);
                store.Commit(Guid.Empty);
            }

            // match triple
            using (var store = StoreManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                var matches = store.Match(t.Subject, t.Predicate, t.Object, true,
                                          RdfDatatypes.PlainLiteral, "en", Constants.DefaultGraphUri).ToList();
                Assert.AreEqual(1, matches.Count());
                var tout = matches.First();
                Assert.AreEqual("en", tout.LangCode);
                Assert.AreEqual(RdfDatatypes.PlainLiteral, tout.DataType);
            }
        }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:28,代码来源:StoreTestsBase.cs

示例13: TestInsertAndRetrieveTripleWithSameLiteralAndDifferentDataType

        public virtual void TestInsertAndRetrieveTripleWithSameLiteralAndDifferentDataType()
        {
            var sid = Guid.NewGuid().ToString();
            var store = StoreManager.CreateStore(Configuration.StoreLocation + "\\" + sid);

            var t = new Triple
                        {
                            Subject = "http://www.networkedplanet.com/people/10",
                            Predicate = "http://www.networkedplanet.com/model/isa",
                            Object = "24/03/76",
                            DataType = RdfDatatypes.String,
                            IsLiteral = true
                        };
            store.InsertTriple(t);

            t = new Triple
                    {
                        Subject = "http://www.networkedplanet.com/people/10",
                        Predicate = "http://www.networkedplanet.com/model/isa",
                        Object = "24/03/76",
                        DataType = RdfDatatypes.DateTime,
                        IsLiteral = true
                    };
            store.InsertTriple(t);
            store.Commit(Guid.Empty);

            // match triple
            store = StoreManager.OpenStore(Configuration.StoreLocation + "\\" + sid, true);

            var matches = store.Match(t.Subject, t.Predicate, t.Object, true,
                                      RdfDatatypes.DateTime, null, Constants.DefaultGraphUri);
            Assert.AreEqual(1, matches.Count());
            matches = store.Match(t.Subject, t.Predicate, t.Object, true,
                                  RdfDatatypes.String, null, Constants.DefaultGraphUri);
            Assert.AreEqual(1, matches.Count());
        }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:36,代码来源:StoreTestsBase.cs

示例14: TestDeleteTriples

        public virtual void TestDeleteTriples()
        {
            var sid = Guid.NewGuid().ToString();
            var t1 = new Triple
                         {
                             Subject = "http://www.networkedplanet.com/people/10",
                             Predicate = "http://www.networkedplanet.com/model/isa",
                             Object = "bob",
                             IsLiteral = true
                         };
            var t2 = new Triple
                         {
                             Subject = "http://www.networkedplanet.com/people/10",
                             Predicate = "http://www.networkedplanet.com/model/isa",
                             Object = "kal",
                             IsLiteral = true
                         };

            using (var store = StoreManager.CreateStore(Configuration.StoreLocation + "\\" + sid))
            {
                store.InsertTriple(t1);
                store.InsertTriple(t2);
                store.Commit(Guid.Empty);
            }
            // delete triple
            using (var store = StoreManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                store.DeleteTriple(t2);
                store.Commit(Guid.Empty);
            }
            using (var store = StoreManager.OpenStore(Configuration.StoreLocation + "\\" + sid))
            {
                var triples = store.GetResourceStatements("http://www.networkedplanet.com/people/10");
                Assert.AreEqual(1, triples.Count());
            }
        }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:36,代码来源:StoreTestsBase.cs

示例15: TestFetchMultipleResourceStatements

        public virtual void TestFetchMultipleResourceStatements()
        {
            var sid = Guid.NewGuid().ToString();
            var store = StoreManager.CreateStore(Configuration.StoreLocation + "\\" + sid);

            for (int i = 0; i < 1000; i++)
            {
                var t = new Triple
                            {
                                Subject = "http://www.networkedplanet.com/people/gra",
                                Predicate = "http://www.networkedplanet.com/model/hasSkill",
                                Object = "http://www.networkedplanet.com/skills/" + i
                            };
                store.InsertTriple(t);
            }

            store.Commit(Guid.Empty);

            store = StoreManager.OpenStore(Configuration.StoreLocation + "\\" + sid, true);

            var triples = store.GetResourceStatements("http://www.networkedplanet.com/people/gra");

            Assert.AreEqual(1000, triples.Count());
        }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:24,代码来源:StoreTestsBase.cs


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