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


C# Graph.CreateLiteralNode方法代码示例

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


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

示例1: NodesDistinct

        public void NodesDistinct()
        {
            Graph g = new Graph();
            List<INode> test = new List<INode>()
            {
                g.CreateUriNode("rdf:type"),
                g.CreateUriNode(new Uri("http://example.org")),
                g.CreateBlankNode(),
                g.CreateBlankNode(),
                null,
                g.CreateBlankNode("test"),
                g.CreateLiteralNode("Test text"),
                g.CreateLiteralNode("Test text", "en"),
                g.CreateLiteralNode("Test text", new Uri(XmlSpecsHelper.XmlSchemaDataTypeString)),
                g.CreateUriNode("rdf:type"),
                null,
                g.CreateUriNode(new Uri("http://example.org#test")),
                g.CreateUriNode(new Uri("http://example.org"))
            };

            foreach (INode n in test.Distinct())
            {
                if (n != null)
                {
                    Console.WriteLine(n.ToString());
                }
                else
                {
                    Console.WriteLine("null");
                }
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:32,代码来源:BasicTests1.cs

示例2: ParsingRdfXmlAmpersands

        public void ParsingRdfXmlAmpersands()
        {
            List<IRdfWriter> writers = new List<IRdfWriter>()
            {
                new RdfXmlWriter(),
                new FastRdfXmlWriter()
            };
            IRdfReader parser = new RdfXmlParser();

            Graph g = new Graph();
            g.BaseUri = new Uri("http://example.org/ampersandsInRdfXml");
            g.Assert(new Triple(g.CreateUriNode(), g.CreateUriNode(new Uri("http://example.org/property")), g.CreateUriNode(new Uri("http://example.org/a&b"))));
            g.Assert(new Triple(g.CreateUriNode(), g.CreateUriNode(new Uri("http://example.org/property")), g.CreateLiteralNode("A & B")));

            foreach (IRdfWriter writer in writers)
            {
                try
                {
                    Console.WriteLine(writer.GetType().ToString());
                    String temp = StringWriter.Write(g, writer);
                    Console.WriteLine(temp);
                    Graph h = new Graph();
                    StringParser.Parse(h, temp);
                    Assert.AreEqual(g, h, "Graphs should be equal");
                    Console.WriteLine();
                }
                catch (Exception ex)
                {
                    TestTools.ReportError("Error", ex, true);
                }
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:32,代码来源:RdfXmlTests.cs

示例3: SparqlFunctionsIsNumeric

        public void SparqlFunctionsIsNumeric()
        {
            Graph g = new Graph();
            IUriNode subj = g.CreateUriNode(new Uri("http://example.org/subject"));
            IUriNode pred = g.CreateUriNode(new Uri("http://example.org/predicate"));

            g.Assert(subj, pred, (12).ToLiteral(g));
            g.Assert(subj, pred, g.CreateLiteralNode("12"));
            g.Assert(subj, pred, g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeNonNegativeInteger)));
            g.Assert(subj, pred, g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeNonPositiveInteger)));
            g.Assert(subj, pred, g.CreateLiteralNode("1200", new Uri(XmlSpecsHelper.XmlSchemaDataTypeByte)));
            g.Assert(subj, pred, ((byte)50).ToLiteral(g));
            g.Assert(subj, pred, g.CreateLiteralNode("-50", new Uri(XmlSpecsHelper.XmlSchemaDataTypeByte)));
            g.Assert(subj, pred, g.CreateLiteralNode("-50", new Uri(XmlSpecsHelper.XmlSchemaDataTypeUnsignedByte)));
            g.Assert(subj, pred, g.CreateUriNode(new Uri("http://example.org")));

            TripleStore store = new TripleStore();
            store.Add(g);

            SparqlQueryParser parser = new SparqlQueryParser();
            SparqlQuery q = parser.ParseFromString("SELECT ?obj (IsNumeric(?obj) AS ?IsNumeric) WHERE { ?s ?p ?obj }");

            Object results = store.ExecuteQuery(q);

            Assert.IsTrue(results is SparqlResultSet, "Result should be a SPARQL Result Set");
            TestTools.ShowResults(results);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:27,代码来源:SparqlNewFunctions.cs

示例4: WritingCollectionCompressionNamedListNodes3

        public void WritingCollectionCompressionNamedListNodes3()
        {
            Graph g = new Graph();
            INode data1 = g.CreateBlankNode();
            g.Assert(data1, g.CreateUriNode(new Uri("http://property")), g.CreateLiteralNode("test1"));
            INode data2 = g.CreateBlankNode();
            g.Assert(data2, g.CreateUriNode(new Uri("http://property")), g.CreateLiteralNode("test2"));

            INode listEntry1 = g.CreateUriNode(new Uri("http://test/1"));
            INode rdfFirst = g.CreateUriNode(new Uri(RdfSpecsHelper.RdfListFirst));
            INode rdfRest = g.CreateUriNode(new Uri(RdfSpecsHelper.RdfListRest));
            INode rdfNil = g.CreateUriNode(new Uri(RdfSpecsHelper.RdfListNil));
            g.Assert(listEntry1, rdfFirst, data1);
            g.Assert(listEntry1, rdfRest, rdfNil);

            INode listEntry2 = g.CreateUriNode(new Uri("http://test/2"));
            g.Assert(listEntry2, rdfFirst, data2);
            g.Assert(listEntry2, rdfRest, listEntry1);

            INode root = g.CreateUriNode(new Uri("http://root"));
            g.Assert(root, g.CreateUriNode(new Uri("http://list")), listEntry2);

            NTriplesFormatter formatter = new NTriplesFormatter();
            Console.WriteLine("Original Graph");
            foreach (Triple t in g.Triples)
            {
                Console.WriteLine(t.ToString(formatter));
            }
            Console.WriteLine();

            CompressingTurtleWriterContext context = new CompressingTurtleWriterContext(g, Console.Out);
            WriterHelper.FindCollections(context);
            Console.WriteLine(context.Collections.Count + " Collections Found");
            Console.WriteLine();

            System.IO.StringWriter strWriter = new System.IO.StringWriter();
            CompressingTurtleWriter writer = new CompressingTurtleWriter();
            writer.CompressionLevel = WriterCompressionLevel.High;
            writer.Save(g, strWriter);

            Console.WriteLine("Compressed Turtle");
            Console.WriteLine(strWriter.ToString());
            Console.WriteLine();

            Graph h = new Graph();
            TurtleParser parser = new TurtleParser();
            StringParser.Parse(h, strWriter.ToString());
            Console.WriteLine("Graph after Round Trip to Compressed Turtle");
            foreach (Triple t in h.Triples)
            {
                Console.WriteLine(t.ToString(formatter));
            }

            Assert.AreEqual(g, h, "Graphs should be equal");
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:55,代码来源:CollectionCompressionTests.cs

示例5: WritingCollectionCompressionNamedListNodes2

        public void WritingCollectionCompressionNamedListNodes2()
        {
            Graph g = new Graph();
            g.NamespaceMap.AddNamespace("ex", new Uri("http://example.org/"));
            INode n = g.CreateUriNode("ex:listRoot");
            INode m = g.CreateUriNode("ex:listItem");
            INode rdfType = g.CreateUriNode("rdf:type");
            INode rdfFirst = g.CreateUriNode("rdf:first");
            INode rdfRest = g.CreateUriNode("rdf:rest");
            INode rdfNil = g.CreateUriNode("rdf:nil");

            g.Assert(g.CreateUriNode("ex:subj"), g.CreateUriNode("ex:pred"), n);
            g.Assert(n, rdfFirst, g.CreateLiteralNode("first"));
            g.Assert(n, rdfRest, m);
            g.Assert(m, rdfFirst, g.CreateLiteralNode("second"));
            g.Assert(m, rdfRest, rdfNil);

            CompressingTurtleWriterContext context = new CompressingTurtleWriterContext(g, Console.Out);
            WriterHelper.FindCollections(context);

            Assert.AreEqual(0, context.Collections.Count, "Expected no collections to be found");

            this.CheckCompressionRoundTrip(g);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:24,代码来源:CollectionCompressionTests.cs

示例6: WritingTripleFormatting

        public void WritingTripleFormatting()
        {
            try
            {
                //Create the Graph and define an additional namespace
                Graph g = new Graph();
                g.NamespaceMap.AddNamespace("ex", new Uri("http://example.org/"));

                //Create URIs used for datatypes
                Uri dtInt = new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger);
                Uri dtFloat = new Uri(XmlSpecsHelper.XmlSchemaDataTypeFloat);
                Uri dtDouble = new Uri(XmlSpecsHelper.XmlSchemaDataTypeDouble);
                Uri dtDecimal = new Uri(XmlSpecsHelper.XmlSchemaDataTypeDecimal);
                Uri dtBoolean = new Uri(XmlSpecsHelper.XmlSchemaDataTypeBoolean);
                Uri dtUnknown = new Uri("http://example.org/unknownType");

                //Create Nodes used for our test Triples
                IBlankNode subjBnode = g.CreateBlankNode();
                IUriNode subjUri = g.CreateUriNode(new Uri("http://example.org/subject"));
                IUriNode predUri = g.CreateUriNode(new Uri("http://example.org/predicate"));
                IUriNode predType = g.CreateUriNode(new Uri(RdfSpecsHelper.RdfType));
                IBlankNode objBnode = g.CreateBlankNode();
                IUriNode objUri = g.CreateUriNode(new Uri("http://example.org/object"));
                ILiteralNode objString = g.CreateLiteralNode("This is a literal");
                ILiteralNode objStringLang = g.CreateLiteralNode("This is a literal with a language specifier", "en");
                ILiteralNode objInt = g.CreateLiteralNode("123", dtInt);
                ILiteralNode objFloat = g.CreateLiteralNode("12.3e4", dtFloat);
                ILiteralNode objDouble = g.CreateLiteralNode("12.3e4", dtDouble);
                ILiteralNode objDecimal = g.CreateLiteralNode("12.3", dtDecimal);
                ILiteralNode objTrue = g.CreateLiteralNode("true", dtBoolean);
                ILiteralNode objFalse = g.CreateLiteralNode("false", dtBoolean);
                ILiteralNode objUnknown = g.CreateLiteralNode("This is a literal with an unknown type", dtUnknown);

                List<ITripleFormatter> formatters = new List<ITripleFormatter>()
                {
                    new NTriplesFormatter(),
                    new UncompressedTurtleFormatter(),
                    new UncompressedNotation3Formatter(),
                    new TurtleFormatter(g),
                    new Notation3Formatter(g),
                    new CsvFormatter(),
                    new TsvFormatter()
                };
                List<INode> subjects = new List<INode>()
                {
                    subjBnode,
                    subjUri
                };
                List<INode> predicates = new List<INode>()
                {
                    predUri,
                    predType
                };
                List<INode> objects = new List<INode>()
                {
                    objBnode,
                    objUri,
                    objString,
                    objStringLang,
                    objInt,
                    objFloat,
                    objDouble,
                    objDecimal,
                    objTrue,
                    objFalse,
                    objUnknown
                };
                List<Triple> testTriples = new List<Triple>();
                foreach (INode s in subjects)
                {
                    foreach (INode p in predicates)
                    {
                        foreach (INode o in objects)
                        {
                            testTriples.Add(new Triple(s, p, o));
                        }
                    }
                }

                foreach (Triple t in testTriples)
                {
                    Console.WriteLine("Raw Triple:");
                    Console.WriteLine(t.ToString());
                    Console.WriteLine();
                    foreach (ITripleFormatter f in formatters)
                    {
                        Console.WriteLine(f.GetType().ToString());
                        Console.WriteLine(f.Format(t));
                        Console.WriteLine();
                    }
                    Console.WriteLine();
                }
            }
            catch (Exception ex)
            {
                TestTools.ReportError("Error", ex, true);
            }       
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:98,代码来源:FormattingTests.cs

示例7: NodesNullNodeEquality

        public void NodesNullNodeEquality()
        {
            UriNode nullUri = null;
            LiteralNode nullLiteral = null;
            BlankNode nullBNode = null;

            Graph g = new Graph();
            IUriNode someUri = g.CreateUriNode(new Uri("http://example.org"));
            ILiteralNode someLiteral = g.CreateLiteralNode("A Literal");
            IBlankNode someBNode = g.CreateBlankNode();

            Assert.AreEqual(nullUri, nullUri, "Null URI Node should be equal to self");
            Assert.AreEqual(nullUri, null, "Null URI Node should be equal to a null");
            Assert.AreEqual(null, nullUri, "Null should be equal to a Null URI Node");
            Assert.IsTrue(nullUri == nullUri, "Null URI Node should be equal to self");
            Assert.IsTrue(nullUri == null, "Null URI Node should be equal to a null");
            Assert.IsTrue(null == nullUri, "Null should be equal to a Null URI Node");
            Assert.IsFalse(nullUri != nullUri, "Null URI Node should be equal to self");
            Assert.IsFalse(nullUri != null, "Null URI Node should be equal to a null");
            Assert.IsFalse(null != nullUri, "Null should be equal to a Null URI Node");
            Assert.AreNotEqual(nullUri, someUri, "Null URI Node should not be equal to an actual URI Node");
            Assert.AreNotEqual(someUri, nullUri, "Null URI Node should not be equal to an actual URI Node");
            Assert.IsFalse(nullUri == someUri, "Null URI Node should not be equal to an actual URI Node");
            Assert.IsFalse(someUri == nullUri, "Null URI Node should not be equal to an actual URI Node");

            Assert.AreEqual(nullLiteral, nullLiteral, "Null Literal Node should be equal to self");
            Assert.AreEqual(nullLiteral, null, "Null Literal Node should be equal to a null");
            Assert.AreEqual(null, nullLiteral, "Null should be equal to a Null Literal Node");
            Assert.IsTrue(nullLiteral == nullLiteral, "Null Literal Node should be equal to self");
            Assert.IsTrue(nullLiteral == null, "Null Literal Node should be equal to a null");
            Assert.IsTrue(null == nullLiteral, "Null should be equal to a Null Literal Node");
            Assert.IsFalse(nullLiteral != nullLiteral, "Null Literal Node should be equal to self");
            Assert.IsFalse(nullLiteral != null, "Null Literal Node should be equal to a null");
            Assert.IsFalse(null != nullLiteral, "Null should be equal to a Null Literal Node");
            Assert.AreNotEqual(nullLiteral, someLiteral, "Null Literal Node should not be equal to an actual Literal Node");
            Assert.AreNotEqual(someLiteral, nullLiteral, "Null Literal Node should not be equal to an actual Literal Node");
            Assert.IsFalse(nullLiteral == someLiteral, "Null Literal Node should not be equal to an actual Literal Node");
            Assert.IsFalse(someLiteral == nullLiteral, "Null Literal Node should not be equal to an actual Literal Node");

            Assert.AreEqual(nullBNode, nullBNode, "Null BNode Node should be equal to self");
            Assert.AreEqual(nullBNode, null, "Null BNode Node should be equal to a null");
            Assert.AreEqual(null, nullBNode, "Null should be equal to a Null BNode Node");
            Assert.IsTrue(nullBNode == nullBNode, "Null BNode Node should be equal to self");
            Assert.IsTrue(nullBNode == null, "Null BNode Node should be equal to a null");
            Assert.IsTrue(null == nullBNode, "Null should be equal to a Null BNode Node");
            Assert.IsFalse(nullBNode != nullBNode, "Null BNode Node should be equal to self");
            Assert.IsFalse(nullBNode != null, "Null BNode Node should be equal to a null");
            Assert.IsFalse(null != nullBNode, "Null should be equal to a Null BNode Node");
            Assert.AreNotEqual(nullBNode, someBNode, "Null BNode Node should not be equal to an actual BNode Node");
            Assert.AreNotEqual(someBNode, nullBNode, "Null BNode Node should not be equal to an actual BNode Node");
            Assert.IsFalse(nullBNode == someBNode, "Null BNode Node should not be equal to an actual BNode Node");
            Assert.IsFalse(someBNode == nullBNode, "Null BNode Node should not be equal to an actual BNode Node");
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:53,代码来源:BasicTests1.cs

示例8: NodesSortingSparqlOrder

        public void NodesSortingSparqlOrder()
        {
            SparqlOrderingComparer comparer = new SparqlOrderingComparer();

            //Stream for Output
            Console.WriteLine("## Sorting Test");
            Console.WriteLine("NULLs < Blank Nodes < URI Nodes < Untyped Literals < Typed Literals");
            Console.WriteLine();

            //Create a Graph
            Graph g = new Graph();
            g.BaseUri = new Uri("http://example.org/");
            g.NamespaceMap.AddNamespace("", new Uri("http://example.org/"));

            //Create a list of various Nodes
            List<INode> nodes = new List<INode>();
            nodes.Add(g.CreateUriNode(":someUri"));
            nodes.Add(g.CreateBlankNode());
            nodes.Add(null);
            nodes.Add(g.CreateBlankNode());
            nodes.Add(g.CreateLiteralNode("cheese"));
            nodes.Add(g.CreateLiteralNode("aardvark"));
            nodes.Add(g.CreateLiteralNode(DateTime.Now.AddDays(-25).ToString(XmlSpecsHelper.XmlSchemaDateTimeFormat), new Uri(XmlSpecsHelper.XmlSchemaDataTypeDateTime)));
            nodes.Add(g.CreateLiteralNode("duck"));
            nodes.Add(g.CreateUriNode(":otherUri"));
            nodes.Add(g.CreateLiteralNode("1.5", new Uri(XmlSpecsHelper.XmlSchemaDataTypeDouble)));
            nodes.Add(g.CreateUriNode(new Uri("http://www.google.com")));
            nodes.Add(g.CreateLiteralNode(DateTime.Now.AddYears(3).ToString(XmlSpecsHelper.XmlSchemaDateTimeFormat), new Uri(XmlSpecsHelper.XmlSchemaDataTypeDateTime)));
            nodes.Add(g.CreateLiteralNode("23", new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger)));
            nodes.Add(g.CreateLiteralNode("M43d", new Uri(XmlSpecsHelper.XmlSchemaDataTypeBase64Binary)));
            nodes.Add(g.CreateUriNode(new Uri("http://www.dotnetrdf.org")));
            nodes.Add(g.CreateLiteralNode("12", new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger)));
            nodes.Add(g.CreateBlankNode("monkey"));
            nodes.Add(g.CreateBlankNode());
            nodes.Add(g.CreateLiteralNode("chaese"));
            nodes.Add(g.CreateLiteralNode("1.0456345", new Uri(XmlSpecsHelper.XmlSchemaDataTypeDouble)));
            nodes.Add(g.CreateLiteralNode("cheese"));
            nodes.Add(g.CreateLiteralNode(Convert.ToBase64String(new byte[] { Byte.Parse("32") }), new Uri(XmlSpecsHelper.XmlSchemaDataTypeBase64Binary)));
            nodes.Add(g.CreateLiteralNode("TA==", new Uri(XmlSpecsHelper.XmlSchemaDataTypeBase64Binary)));
            nodes.Add(g.CreateLiteralNode("-45454", new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger)));
            nodes.Add(g.CreateLiteralNode(DateTime.Now.ToString(XmlSpecsHelper.XmlSchemaDateTimeFormat), new Uri(XmlSpecsHelper.XmlSchemaDataTypeDateTime)));
            nodes.Add(g.CreateLiteralNode("-3", new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger)));
            nodes.Add(g.CreateLiteralNode("242344.3456435", new Uri(XmlSpecsHelper.XmlSchemaDataTypeDouble)));
            nodes.Add(g.CreateLiteralNode("true", new Uri(XmlSpecsHelper.XmlSchemaDataTypeBoolean)));
            nodes.Add(g.CreateUriNode(":what"));
            nodes.Add(null);
            nodes.Add(g.CreateLiteralNode("false", new Uri(XmlSpecsHelper.XmlSchemaDataTypeBoolean)));
            nodes.Add(g.CreateLiteralNode("invalid-value", new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger)));

            nodes.Sort(comparer);

            //Output the Results
            foreach (INode n in nodes)
            {
                if (n == null)
                {
                    Console.WriteLine("NULL");
                }
                else
                {
                    Console.WriteLine(n.ToString());
                }
            }

            Console.WriteLine();
            Console.WriteLine("Now in reverse...");
            Console.WriteLine();

            nodes.Reverse();

            //Output the Results
            foreach (INode n in nodes)
            {
                if (n == null)
                {
                    Console.WriteLine("NULL");
                }
                else
                {
                    Console.WriteLine(n.ToString());
                }
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:83,代码来源:BasicTests1.cs

示例9: RemoveFavorClick

    protected void RemoveFavorClick(object sender, EventArgs e)
    {
        GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;
        int index = gvRow.RowIndex;
        DataTable dt2Datas = (DataTable)ViewState["dt2Datas"];

        //delete from rdf
        Graph g = new Graph();
        FileLoader.Load(g, path_user + Session["UserId"].ToString() + ".rdf");

        string Title = dt2Datas.Rows[index]["Title"].ToString();
        string Name = dt2Datas.Rows[index]["Name"].ToString();
        string Surname = dt2Datas.Rows[index]["Surname"].ToString();
        string Email = dt2Datas.Rows[index]["E-mail"].ToString();
        Email = "mailto:" + Email;
        string Phone = dt2Datas.Rows[index]["Phone"].ToString();
        Phone = "tel:" + Phone;
        string dataid = dt2Datas.Rows[index]["dataid"].ToString();
        string Comments = dt2Datas.Rows[index]["Comments"].ToString();
        string Faculty = dt2Datas.Rows[index]["Faculty"].ToString();

        g.NamespaceMap.AddNamespace("foaf", new Uri("http://xmlns.com/foaf/0.1/"));
        g.NamespaceMap.AddNamespace("rdfs", new Uri("http://www.w3.org/2000/01/rdf-schema#"));
        g.NamespaceMap.AddNamespace("v", new Uri("http://www.w3.org/2006/vcard/ns#"));

        IUriNode person = g.CreateUriNode(UriFactory.Create(dataid));
        IUriNode ITitle = g.CreateUriNode("foaf:title");
        IUriNode IName = g.CreateUriNode("foaf:name");
        IUriNode ISurname = g.CreateUriNode("foaf:familyName");
        IUriNode IEmail = g.CreateUriNode("foaf:mbox");
        IUriNode IPhone = g.CreateUriNode("foaf:phone");
        IUriNode IFaculty = g.CreateUriNode("rdfs:label");
        IUriNode IComments = g.CreateUriNode("rdfs:comment");
        IUriNode rdftype = g.CreateUriNode("rdf:type");//FOAFPERSON
        IUriNode foafPerson = g.CreateUriNode("foaf:Person");//FOAFPERSON

           // IUriNode NPhone = g.CreateUriNode(UriFactory.Create("tel:" + Session["Snumber"].ToString()));
          //  IUriNode NEmail = g.CreateUriNode(UriFactory.Create("mailto:" + Session["Semail"].ToString().Split('>')[1].Split('<')[0].ToString()));

        g.Retract(person, ITitle, g.CreateLiteralNode(Title));
        g.Retract(person, IName, g.CreateLiteralNode(Name));
        g.Retract(person, ISurname, g.CreateLiteralNode(Surname));
        g.Retract(person, IEmail, g.CreateUriNode(UriFactory.Create((Email))));
        g.Retract(person, IPhone, g.CreateUriNode(UriFactory.Create((Phone))));
        g.Retract(person, IComments, g.CreateLiteralNode(Comments));
        g.Retract(person, IFaculty, g.CreateLiteralNode(Faculty));
        g.Retract(new Triple(person, rdftype, foafPerson));//FOAFPERSON

        RdfXmlWriter rdfxmlwriter = new RdfXmlWriter();
        rdfxmlwriter.Save(g, path_user + Session["UserId"].ToString() + ".rdf");

        //remove from datatable
        dt2Datas.Rows[index].Delete();
        dt2Datas.AcceptChanges();
        GridView2.DataSource = dt2Datas;
        GridView2.DataBind();

        /*    if (faculty.Equals("&nbsp;"))
            faculty = "";
        else if (faculty.Contains("&amp;"))
            faculty = faculty.Replace("&amp;", "&");
        */
        if (GridView1.Enabled)
        {

            for (int rows = 0; rows < GridView1.Rows.Count; rows++)
            {
                //System.Diagnostics.Debug.WriteLine("AHA! AHAAAAAAAAA" + Phone + "=" + GridView1.Rows[rows].Cells[4].Text + "=" + GridView1.Rows[rows].Cells[5].Text.Replace("&nbsp;", ""));
                if ((Title == GridView1.Rows[rows].Cells[0].Text) &&//title
                  (Name == GridView1.Rows[rows].Cells[1].Text) && //name
                 (Surname == GridView1.Rows[rows].Cells[2].Text) &&//surname
                 (Phone.Split(':')[1] == GridView1.Rows[rows].Cells[4].Text) &&    //phone
                    (Email == GridView1.Rows[rows].Cells[3].Text.Split('=')[1].Split('>')[0]) &&//email
                    ((Faculty == GridView1.Rows[rows].Cells[5].Text.Replace("&amp;", "&")) ||
                    (Faculty == GridView1.Rows[rows].Cells[5].Text.Replace("&nbsp;", "")) ) //faculty */
                  )
                {
                   // System.Diagnostics.Debug.WriteLine("AHA! AHAAAAAAAAA" + rows);
                    (GridView1.Rows[rows].FindControl("btnAddFavor")  as Button).Enabled = true;
                }
            }
        }
    }
开发者ID:pc3g11,项目名称:phonebook,代码行数:83,代码来源:Search.aspx.cs

示例10: NodesLiteralNodeEquality

        public void NodesLiteralNodeEquality()
        {
            try
            {
                Graph g = new Graph();

                //Strict Mode Tests
                Console.WriteLine("Doing a load of Strict Literal Equality Tests");
                Options.LiteralEqualityMode = LiteralEqualityMode.Strict;

                //Test Literals with Language Tags
                ILiteralNode hello, helloEn, helloEnUS, helloAgain;
                hello = g.CreateLiteralNode("hello");
                helloEn = g.CreateLiteralNode("hello", "en");
                helloEnUS = g.CreateLiteralNode("hello", "en-US");
                helloAgain = g.CreateLiteralNode("hello");

                Assert.AreNotEqual(hello, helloEn, "Identical Literals with differing Language Tags are non-equal");
                Assert.AreNotEqual(hello, helloEnUS, "Identical Literals with differing Language Tags are non-equal");
                Assert.AreNotEqual(helloEn, helloEnUS, "Identical Literals with differing Language Tags are non-equal");
                Assert.AreNotEqual(helloEn, helloAgain, "Identical Literals with differing Language Tags are non-equal");
                Assert.AreNotEqual(helloEnUS, helloAgain, "Identical Literals with differing Language Tags are non-equal");

                Assert.AreEqual(hello, helloAgain, "Identical Literals with the same Language Tag are equal");

                //Test Plain Literals
                ILiteralNode plain1, plain2, plain3, plain4;
                plain1 = g.CreateLiteralNode("plain literal");
                plain2 = g.CreateLiteralNode("another plain literal");
                plain3 = g.CreateLiteralNode("Plain Literal");
                plain4 = g.CreateLiteralNode("plain literal");

                Assert.AreNotEqual(plain1, plain2, "Literals with non-identical lexical values are non-equal");
                Assert.AreNotEqual(plain1, plain3, "Literals with non-identical lexical values are non-equal even if they differ only in case");
                Assert.AreEqual(plain1, plain4, "Literals with identical lexical values are equal");
                Assert.AreNotEqual(plain2, plain3, "Literals with non-identical lexical values are non-equal");
                Assert.AreNotEqual(plain2, plain4, "Literals with non-identical lexical values are non-equal");
                Assert.AreNotEqual(plain3, plain4, "Literals with non-identical lexical values are non-equal even if they differ only in case");

                //Typed Literals
                Uri intType = new Uri(XmlSpecsHelper.XmlSchemaDataTypeInteger);
                Uri boolType = new Uri(XmlSpecsHelper.XmlSchemaDataTypeBoolean);

                ILiteralNode one1, one2, one3, one4;
                one1 = g.CreateLiteralNode("1");
                one2 = g.CreateLiteralNode("1", intType);
                one3 = g.CreateLiteralNode("0001", intType);
                one4 = g.CreateLiteralNode("1", intType);

                Assert.AreNotEqual(one1, one2, "Literals with identical lexical values but non-identical data types are non-equal");
                Assert.AreNotEqual(one1, one3, "Literals with identical lexical values but non-identical data types are non-equal");
                Assert.AreNotEqual(one1, one4, "Literals with identical lexical values but non-identical data types are non-equal");
                Assert.AreNotEqual(one2, one3, "Literals with equivalent values represented as different lexical values are non-equal even when they're data types are equal");
                Assert.AreEqual(one2, one4, "Literals with identical lexical values and identical data types are equal");
                Assert.AreNotEqual(one3, one4, "Literals with equivalent values represented as different lexical values are non-equal even when they're data types are equal");

                Assert.AreNotEqual(0, one1.CompareTo(one2), "Using the Comparer for Literal Nodes which is used for sorting Literals with identical lexical values but non-identical data types are still non-equal");
                Assert.AreEqual(0, one2.CompareTo(one3), "Using the Comparer for Literal Nodes which is used for sorting Literals with equivalent non-identical lexical values are considered equal when their data types are equal");
                Assert.AreEqual(0, one3.CompareTo(one2), "Using the Comparer for Literal Nodes which is used for sorting Literals with equivalent non-identical lexical values are considered equal when their data types are equal");
                Assert.AreEqual(0, one3.CompareTo(one4), "Using the Comparer for Literal Nodes which is used for sorting Literals with equivalent non-identical lexical values are considered equal when their data types are equal");

                ILiteralNode t, f, one5;
                t = g.CreateLiteralNode("true", boolType);
                f = g.CreateLiteralNode("false", boolType);
                one5 = g.CreateLiteralNode("1", boolType);

                Assert.AreNotEqual(t, f, "Literals with different lexical values but identical data types are non-equal");
                Assert.AreEqual(t, t, "Literals with identical lexical values and identical data types are equal");
                Assert.AreEqual(f, f, "Literals with identical lexical values and identical data types are equal");

                Assert.AreNotEqual(t, one5, "Literals with different data types are non-equal even if their lexical values when cast to that type may be equivalent");

                //Loose Mode Tests
                Console.WriteLine("Doing a load of Loose Equality Tests");
                Options.LiteralEqualityMode = LiteralEqualityMode.Loose;

                Assert.AreEqual(one2, one3, "Literals with equivalent lexical values and identical data types can be considered equal under Loose Equality Mode");
                Assert.AreEqual(one3, one4, "Literals with equivalent lexical values and identical data types can be considered equal under Loose Equality Mode");
                Assert.AreNotEqual(t, one5, "Literals with equivalent lexical values (but which are not in the recognized lexical space of the type i.e. require a cast) and identical data types are still non-equal under Loose Equality Mode");

            }
            catch (Exception ex)
            {
                //Reset Literal Equality Mode
                Options.LiteralEqualityMode = LiteralEqualityMode.Strict;

                TestTools.ReportError("Error", ex, true);
            }
            finally
            {
                //Reset Literal Equality Mode
                Options.LiteralEqualityMode = LiteralEqualityMode.Strict;
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:94,代码来源:BasicTests1.cs

示例11: NodesHashCodes

        public void NodesHashCodes()
        {
            Console.WriteLine("Tests that Literal and URI Nodes produce different Hashes");
            Console.WriteLine();

            //Create the Nodes
            Graph g = new Graph();
            IUriNode u = g.CreateUriNode(new Uri("http://www.google.com"));
            ILiteralNode l = g.CreateLiteralNode("http://www.google.com/");

            Console.WriteLine("Created a URI and Literal Node both referring to 'http://www.google.com'");
            Console.WriteLine("String form of URI Node is:");
            Console.WriteLine(u.ToString());
            Console.WriteLine("String form of Literal Node is:");
            Console.WriteLine(l.ToString());
            Console.WriteLine("Hash Code of URI Node is " + u.GetHashCode());
            Console.WriteLine("Hash Code of Literal Node is " + l.GetHashCode());
            Console.WriteLine("Hash Codes are Equal? " + u.GetHashCode().Equals(l.GetHashCode()));
            Console.WriteLine("Nodes are equal? " + u.Equals(l));

            Assert.AreNotEqual(u.GetHashCode(), l.GetHashCode());
            Assert.AreNotEqual(u, l);

            //Create some plain and typed literals which may have colliding Hash Codes
            ILiteralNode plain = g.CreateLiteralNode("test^^http://example.org/type");
            ILiteralNode typed = g.CreateLiteralNode("test", new Uri("http://example.org/type"));

            Console.WriteLine();
            Console.WriteLine("Created a Plain and Typed Literal where the String representations are identical");
            Console.WriteLine("Plain Literal String form is:");
            Console.WriteLine(plain.ToString());
            Console.WriteLine("Typed Literal String from is:");
            Console.WriteLine(typed.ToString());
            Console.WriteLine("Hash Code of Plain Literal is " + plain.GetHashCode());
            Console.WriteLine("Hash Code of Typed Literal is " + typed.GetHashCode());
            Console.WriteLine("Hash Codes are Equal? " + plain.GetHashCode().Equals(typed.GetHashCode()));
            Console.WriteLine("Nodes are equal? " + plain.Equals(typed));

            Assert.AreNotEqual(plain.GetHashCode(), typed.GetHashCode());
            Assert.AreNotEqual(plain, typed);

            //Create Triples
            IBlankNode b = g.CreateBlankNode();
            IUriNode type = g.CreateUriNode("rdf:type");
            Triple t1, t2;
            t1 = new Triple(b, type, u);
            t2 = new Triple(b, type, l);

            Console.WriteLine();
            Console.WriteLine("Created two Triples stating a Blank Node has rdf:type of the URI Nodes created earlier");
            Console.WriteLine("String form of Triple 1 (using URI Node) is:");
            Console.WriteLine(t1.ToString());
            Console.WriteLine("String form of Triple 2 (using Literal Node) is:");
            Console.WriteLine(t2.ToString());
            Console.WriteLine("Hash Code of Triple 1 is " + t1.GetHashCode());
            Console.WriteLine("Hash Code of Triple 2 is " + t2.GetHashCode());
            Console.WriteLine("Hash Codes are Equal? " + t1.GetHashCode().Equals(t2.GetHashCode()));
            Console.WriteLine("Triples are Equal? " + t1.Equals(t2));

            Assert.AreNotEqual(t1.GetHashCode(), t2.GetHashCode());
            Assert.AreNotEqual(t1, t2);

            //Create Triples from the earlier Literal Nodes
            t1 = new Triple(b, type, plain);
            t2 = new Triple(b, type, typed);

            Console.WriteLine();
            Console.WriteLine("Created two Triples stating a Blank Node has rdf:type of the Literal Nodes created earlier");
            Console.WriteLine("String form of Triple 1 (using Plain Literal) is:");
            Console.WriteLine(t1.ToString());
            Console.WriteLine("String form of Triple 2 (using Typed Literal) is:");
            Console.WriteLine(t2.ToString());
            Console.WriteLine("Hash Code of Triple 1 is " + t1.GetHashCode());
            Console.WriteLine("Hash Code of Triple 2 is " + t2.GetHashCode());
            Console.WriteLine("Hash Codes are Equal? " + t1.GetHashCode().Equals(t2.GetHashCode()));
            Console.WriteLine("Triples are Equal? " + t1.Equals(t2));

            Assert.AreNotEqual(t1.GetHashCode(), t2.GetHashCode());
            Assert.AreNotEqual(t1, t2);

        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:81,代码来源:BasicTests1.cs

示例12: GraphCreation2

        public void GraphCreation2()
        {
            //Create a new Empty Graph
            Graph g = new Graph();
            Assert.IsNotNull(g);

            //Define Namespaces
            g.NamespaceMap.AddNamespace("pets", new Uri("http://example.org/pets"));
            Assert.IsTrue(g.NamespaceMap.HasNamespace("pets"));

            //Create Uri Nodes
            IUriNode dog, fido, rob, owner, name, species, breed, lab;
            dog = g.CreateUriNode("pets:Dog");
            fido = g.CreateUriNode("pets:abc123");
            rob = g.CreateUriNode("pets:def456");
            owner = g.CreateUriNode("pets:hasOwner");
            name = g.CreateUriNode("pets:hasName");
            species = g.CreateUriNode("pets:isAnimal");
            breed = g.CreateUriNode("pets:isBreed");
            lab = g.CreateUriNode("pets:Labrador");

            //Assert Triples
            g.Assert(new Triple(fido, species, dog));
            g.Assert(new Triple(fido, owner, rob));
            g.Assert(new Triple(fido, name, g.CreateLiteralNode("Fido")));
            g.Assert(new Triple(rob, name, g.CreateLiteralNode("Rob")));
            g.Assert(new Triple(fido, breed, lab));

            Assert.IsTrue(g.Triples.Count == 5);

            //Attempt to output GraphViz
            try
            {
                Console.WriteLine("Writing GraphViz DOT file graph_building_example2.dot");
                GraphVizWriter gvzwriter = new GraphVizWriter();
                gvzwriter.Save(g, "graph_building_example2.dot");

                Console.WriteLine("Creating a PNG got this Graph called graph_building_example2.png");
                GraphVizGenerator gvzgen = new GraphVizGenerator("svg", "C:\\Program Files (x86)\\Graphviz2.20\\bin");
                gvzgen.Format = "png";
                gvzgen.Generate(g, "graph_building_example2.png", false);
            }
            catch (Exception ex)
            {
                TestTools.ReportError("Exception using GraphViz", ex, true);
            }
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:47,代码来源:BasicTests1.cs

示例13: GenerateChangeSet

        /// <summary>
        /// Takes lists of Triples added and removed and generates a ChangeSet Batch Graph for these
        /// </summary>
        /// <param name="additions">Triple added</param>
        /// <param name="removals">Triples removed</param>
        /// <returns>Null if there are no Changes to be persisted</returns>
        private IGraph GenerateChangeSet(IEnumerable<Triple> additions, IEnumerable<Triple> removals)
        {
            //Ensure there are no duplicates in the lists
            List<Triple> toAdd = (additions == null) ? new List<Triple>() : additions.Distinct().ToList();
            List<Triple> toRemove = (removals == null) ? new List<Triple>() : removals.Distinct().ToList();

            //Eliminate any additions that have also been retracted
            List<Triple> temp = new List<Triple>();
            foreach (Triple t in toAdd)
            {
                if (toRemove.Contains(t))
                {
                    temp.Add(t);
                }
            }
            //If it was in both lists we don't need to persist the Change as it has effectively not happened
            toAdd.RemoveAll(t => temp.Contains(t));
            toRemove.RemoveAll(t => temp.Contains(t));

            //Nothing to do if both lists are now empty
            if (toAdd.Count == 0 && toRemove.Count == 0) return null;

            //Now we need to build a ChangeSet Graph
            Graph g = new Graph();
            g.BaseUri = new Uri("http://www.dotnetrdf.org/");
            g.NamespaceMap.AddNamespace("cs", new Uri(TalisChangeSetNamespace));

            //Make all the Nodes we need
            IUriNode rdfType = g.CreateUriNode("rdf:type");
            IUriNode changeSet = g.CreateUriNode("cs:ChangeSet");
            IUriNode subjOfChange = g.CreateUriNode("cs:subjectOfChange");
            IUriNode createdDate = g.CreateUriNode("cs:createdDate");
            ILiteralNode now = g.CreateLiteralNode(DateTime.Now.ToString(XmlSpecsHelper.XmlSchemaDateTimeFormat));
            IUriNode creator = g.CreateUriNode("cs:creatorName");
            ILiteralNode dotNetRDF = g.CreateLiteralNode("dotNetRDF");
            IUriNode changeReason = g.CreateUriNode("cs:changeReason");
            ILiteralNode dotNetRDFUpdate = g.CreateLiteralNode("Updates to the store were requested by a dotNetRDF powered application");
            IUriNode precedingChangeset = g.CreateUriNode("cs:precedingChangeSet");
            IUriNode removal = g.CreateUriNode("cs:removal");
            IUriNode addition = g.CreateUriNode("cs:addition");
            IUriNode rdfStmt = g.CreateUriNode("rdf:Statement");
            IUriNode rdfSubj = g.CreateUriNode("rdf:subject");
            IUriNode rdfPred = g.CreateUriNode("rdf:predicate");
            IUriNode rdfObj = g.CreateUriNode("rdf:object");

            //Find the Distinct Subjects from the list
            IEnumerable<INode> subjects = (from t in toAdd select t.Subject).Concat(from t in toRemove select t.Subject).Distinct();
            foreach (INode subj in subjects)
            {
                //Create a ChangeSet for this Subject
                IUriNode report = g.CreateUriNode(new Uri(Tools.ResolveUri(subj.GetHashCode() + "/changes/" + DateTime.Now.ToString(TalisChangeSetIDFormat), g.BaseUri.ToString())));
                g.Assert(new Triple(report, rdfType, changeSet));
                g.Assert(new Triple(report, subjOfChange, Tools.CopyNode(subj, g)));
                g.Assert(new Triple(report, createdDate, now));
                g.Assert(new Triple(report, creator, dotNetRDF));
                g.Assert(new Triple(report, changeReason, dotNetRDFUpdate));

                //Add Additions to this ChangeSet
                foreach (Triple t in toAdd.Where(t2 => t2.Subject.Equals(subj)))
                {
                    IBlankNode b = g.CreateBlankNode();
                    g.Assert(new Triple(report, addition, b));
                    g.Assert(new Triple(b, rdfType, rdfStmt));
                    g.Assert(new Triple(b, rdfSubj, Tools.CopyNode(t.Subject, g)));
                    g.Assert(new Triple(b, rdfPred, Tools.CopyNode(t.Predicate, g)));
                    g.Assert(new Triple(b, rdfObj, Tools.CopyNode(t.Object, g)));
                }

                //Add Removals to this ChangeSet
                foreach (Triple t in toRemove.Where(t2 => t2.Subject.Equals(subj)))
                {
                    IBlankNode b = g.CreateBlankNode();
                    g.Assert(new Triple(report, removal, b));
                    g.Assert(new Triple(b, rdfType, rdfStmt));
                    g.Assert(new Triple(b, rdfSubj, Tools.CopyNode(t.Subject, g)));
                    g.Assert(new Triple(b, rdfPred, Tools.CopyNode(t.Predicate, g)));
                    g.Assert(new Triple(b, rdfObj, Tools.CopyNode(t.Object, g)));
                }
            }

            return g;
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:88,代码来源:TalisPlatformConnector.cs

示例14: StorageVirtuosoEncoding

        public void StorageVirtuosoEncoding()
        {
            //Get the Virtuoso Manager
            VirtuosoManager manager = new VirtuosoManager("DB", VirtuosoTestUsername, VirtuosoTestPassword);

            //Make the Test Graph
            Graph g = new Graph();
            g.BaseUri = new Uri("http://example.org/VirtuosoEncodingTest");
            IUriNode encodedString = g.CreateUriNode(new Uri("http://example.org/encodedString"));
            ILiteralNode encodedText = g.CreateLiteralNode("William Jørgensen");
            g.Assert(new Triple(g.CreateUriNode(), encodedString, encodedText));

            Console.WriteLine("Test Graph created OK");
            TestTools.ShowGraph(g);

            //Save to Virtuoso
            Console.WriteLine();
            Console.WriteLine("Saving to Virtuoso");
            manager.SaveGraph(g);

            //Load back from Virtuoso
            Console.WriteLine();
            Console.WriteLine("Retrieving from Virtuoso");
            Graph h = new Graph();
            manager.LoadGraph(h, new Uri("http://example.org/VirtuosoEncodingTest"));
            TestTools.ShowGraph(h);

            Assert.AreEqual(g, h, "Graphs should be equal");
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:29,代码来源:VirtuosoTest.cs

示例15: WritingCollectionCompressionCyclic3

        public void WritingCollectionCompressionCyclic3()
        {
            Graph g = new Graph();
            g.NamespaceMap.AddNamespace("ex", new Uri("http://example.org/"));
            g.NamespaceMap.AddNamespace("dnr", new Uri(ConfigurationLoader.ConfigurationNamespace));
            INode a = g.CreateBlankNode();
            INode b = g.CreateBlankNode();
            INode c = g.CreateBlankNode();
            INode d = g.CreateBlankNode();
            INode e = g.CreateBlankNode();

            INode pred = g.CreateUriNode("ex:pred");

            g.Assert(d, pred, a);
            g.Assert(d, pred, g.CreateLiteralNode("D"));
            g.Assert(a, pred, b);
            g.Assert(a, pred, g.CreateLiteralNode("A"));
            g.Assert(b, pred, c);
            g.Assert(b, pred, g.CreateLiteralNode("B"));
            g.Assert(c, pred, a);
            g.Assert(c, pred, g.CreateLiteralNode("C"));
            g.Assert(e, pred, g.CreateLiteralNode("E"));

            CompressingTurtleWriterContext context = new CompressingTurtleWriterContext(g, Console.Out);
            WriterHelper.FindCollections(context);

            Assert.AreEqual(3, context.Collections.Count, "Expected 3 collections (one should be eliminated to break the cycle)");

            this.CheckCompressionRoundTrip(g);
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:30,代码来源:CollectionCompressionTests.cs


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