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


C# Graph.Retract方法代码示例

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


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

示例1: CompareResultGraphs

 private void CompareResultGraphs(string results, string expectedResultsPath, bool reduced)
 {
     var expectedResultGraph = new Graph();
     FileLoader.Load(expectedResultGraph, expectedResultsPath);
     var resultSet = expectedResultGraph.GetUriNode(new Uri("http://www.w3.org/2001/sw/DataAccess/tests/result-set#ResultSet"));
     if (resultSet != null)
     {
         var rdfParser = new SparqlRdfParser();
         var xmlParser = new SparqlXmlParser();
         var actualResultSet = new SparqlResultSet();
         var expectedResultSet = new SparqlResultSet();
         using (var tr = new StringReader(results))
         {
             xmlParser.Load(actualResultSet, tr);
         }
         rdfParser.Load(expectedResultSet, expectedResultsPath);
         var bnodeMap = new Dictionary<string, string>();
         CompareSparqlResults(actualResultSet, expectedResultSet, reduced, bnodeMap);
     }
     else
     {
         // This is a constructed graph
         var actualGraph = new Graph();
         actualGraph.LoadFromString(results);
         var toReplace = actualGraph.Triples.Where(
             t => IsGenid(t.Subject) || IsGenid(t.Predicate) || IsGenid(t.Object)).ToList();
         foreach (var t in toReplace)
         {
             var mapped = MapGenidToBlank(t);
             actualGraph.Retract(t);
             actualGraph.Assert(mapped);
         }
         CompareTripleCollections(actualGraph.Triples, expectedResultGraph.Triples, reduced);
     }
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:35,代码来源:ManifestEvaluation.cs

示例2: Split

        public static IDictionary<Uri, IGraph> Split(Uri originalUri, IGraph originalGraph)
        {
            IList<Uri> resources = GraphSplitting.GetResources(originalGraph);

            IDictionary<string, Uri> replacements = CreateReplacements(originalUri, resources);

            ISet<string> exclude = new HashSet<string>();
            exclude.Add(originalUri.ToString());

            IGraph modified = GraphSplitting.ReplaceResourceUris(originalGraph, replacements);

            IDictionary<Uri, IGraph> graphs = new Dictionary<Uri, IGraph>();

            IGraph parent = new Graph();

            foreach (Triple triple in modified.Triples)
            {
                triple.CopyTriple(parent);
                parent.Assert(triple);
            }

            foreach (Uri uri in replacements.Values)
            {
                INode subject = modified.CreateUriNode(uri);

                IGraph cutGraph = new Graph();
                GraphSplitting.Collect(modified, subject, cutGraph, exclude);

                foreach (Triple triple in cutGraph.Triples)
                {
                    triple.CopyTriple(parent);
                    parent.Retract(triple);
                }

                IGraph rebasedGraph = new Graph();
                GraphSplitting.Rebase(cutGraph, rebasedGraph, originalUri, uri);

                graphs.Add(uri, rebasedGraph);
            }

            graphs.Add(originalUri, parent);

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

示例3: GraphSubGraphMatching

        public void GraphSubGraphMatching()
        {
            Graph parent = new Graph();
            FileLoader.Load(parent, "InferenceTest.ttl");
            Graph subgraph = new Graph();
            subgraph.NamespaceMap.Import(parent.NamespaceMap);
            subgraph.Assert(parent.GetTriplesWithSubject(parent.CreateUriNode("eg:FordFiesta")));

            //Check method calls
            Dictionary<INode, INode> mapping;
            Console.WriteLine("Doing basic sub-graph matching with no BNode tests");
            Assert.IsTrue(parent.HasSubGraph(subgraph, out mapping), "Failed to match the sub-graph as expected");
            Assert.IsFalse(parent.IsSubGraphOf(subgraph, out mapping), "Parent should not be a sub-graph of the sub-graph");
            Assert.IsFalse(subgraph.HasSubGraph(parent, out mapping), "Sub-graph should not have parent as its sub-graph");
            Assert.IsTrue(subgraph.IsSubGraphOf(parent, out mapping), "Failed to match the sub-graph as expected");
            Console.WriteLine("OK");
            Console.WriteLine();

            //Add an extra triple into the Graph which will cause it to no longer be a sub-graph
            Console.WriteLine("Adding an extra Triple so the sub-graph is no longer such");
            subgraph.Assert(new Triple(subgraph.CreateUriNode("eg:Rocket"), subgraph.CreateUriNode("rdf:type"), subgraph.CreateUriNode("eg:AirVehicle")));
            Assert.IsFalse(parent.HasSubGraph(subgraph, out mapping), "Sub-graph should no longer be considered a sub-graph");
            Assert.IsFalse(subgraph.IsSubGraphOf(parent, out mapping), "Sub-graph should no longer be considered a sub-graph");
            Console.WriteLine("OK");
            Console.WriteLine();

            //Reset the sub-graph
            Console.WriteLine("Resetting the sub-graph");
            subgraph = new Graph();
            subgraph.NamespaceMap.Import(parent.NamespaceMap);
            subgraph.Assert(parent.GetTriplesWithSubject(parent.CreateUriNode("eg:FordFiesta")));
            Console.WriteLine("Adding additional information to the parent Graph, this should not affect the fact that the sub-graph is a sub-graph of it");
            Assert.IsTrue(parent.HasSubGraph(subgraph, out mapping), "Failed to match the sub-graph as expected");
            Assert.IsFalse(parent.IsSubGraphOf(subgraph, out mapping), "Parent should not be a sub-graph of the sub-graph");
            Assert.IsFalse(subgraph.HasSubGraph(parent, out mapping), "Sub-graph should not have parent as its sub-graph");
            Assert.IsTrue(subgraph.IsSubGraphOf(parent, out mapping), "Failed to match the sub-graph as expected");
            Console.WriteLine("OK");
            Console.WriteLine();

            //Remove stuff from parent graph so it won't match any more
            Console.WriteLine("Removing stuff from parent graph so that it won't have the sub-graph anymore");
            parent.Retract(parent.GetTriplesWithSubject(parent.CreateUriNode("eg:FordFiesta")));
            Assert.IsFalse(parent.HasSubGraph(subgraph, out mapping), "Parent should no longer contian the sub-graph");
            Assert.IsFalse(subgraph.IsSubGraphOf(parent, out mapping), "Parent should no longer contain the sub-graph");
            Console.WriteLine("OK");
            Console.WriteLine();
        }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:47,代码来源:BasicTests2.cs

示例4: GraphSubGraphMatchingWithBNodes

        public void GraphSubGraphMatchingWithBNodes()
        {
            Graph parent = new Graph();
            FileLoader.Load(parent, "Turtle.ttl");
            Graph subgraph = new Graph();
            subgraph.Assert(parent.Triples.Where(t => !t.IsGroundTriple));

            //Check method calls
            Dictionary<INode, INode> mapping;
            Console.WriteLine("Doing basic sub-graph matching with BNode tests");
            Assert.IsTrue(parent.HasSubGraph(subgraph, out mapping), "Failed to match the sub-graph as expected");
            Assert.IsFalse(parent.IsSubGraphOf(subgraph, out mapping), "Parent should not be a sub-graph of the sub-graph");
            Assert.IsFalse(subgraph.HasSubGraph(parent, out mapping), "Sub-graph should not have parent as its sub-graph");
            Assert.IsTrue(subgraph.IsSubGraphOf(parent, out mapping), "Failed to match the sub-graph as expected");
            Console.WriteLine("OK");
            Console.WriteLine();

            //Eliminate some of the Triples from the sub-graph
            Console.WriteLine("Eliminating some Triples from the sub-graph and seeing if the mapping still computes OK");
            subgraph.Retract(subgraph.Triples.Skip(2).Take(5));
            Assert.IsTrue(parent.HasSubGraph(subgraph, out mapping), "Failed to match the sub-graph as expected");
            Assert.IsFalse(parent.IsSubGraphOf(subgraph, out mapping), "Parent should not be a sub-graph of the sub-graph");
            Assert.IsFalse(subgraph.HasSubGraph(parent, out mapping), "Sub-graph should not have parent as its sub-graph");
            Assert.IsTrue(subgraph.IsSubGraphOf(parent, out mapping), "Failed to match the sub-graph as expected");
            Console.WriteLine("OK");
            Console.WriteLine();

            Console.WriteLine("Eliminating Blank Nodes from the parent Graph to check that the sub-graph is no longer considered as such afterwards");
            parent.Retract(parent.Triples.Where(t => !t.IsGroundTriple));
            Assert.IsFalse(parent.HasSubGraph(subgraph), "Sub-graph should no longer be considered as such");
            Assert.IsFalse(subgraph.IsSubGraphOf(parent), "Sub-graph should no longer be considered as such");

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

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

示例6: GV2_RowUpdating

    protected void GV2_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow row = GridView2.Rows[e.RowIndex];
        string UpdatedComments = ((TextBox)(row.Cells[7].Controls[0])).Text;

        if (UpdatedComments.Length > 30)
        {
            string script = "alert(\"Please use fewer than 30 letters for your comments\");";
            ScriptManager.RegisterStartupScript(this, this.GetType(),
                          "ServerControlScript", script, true);
            return;
        }

        Graph g = new Graph();
        FileLoader.Load(g, path_user + Session["UserId"].ToString() + ".rdf");
        //Retrieve the table from the session object.
        DataTable dt2Datas = (DataTable)ViewState["dt2Datas"];

        //Update the values.

        dt2Datas.Rows[row.DataItemIndex]["Comments"] = ((TextBox)(row.Cells[7].Controls[0])).Text;

        //RDF
        string Title = Session["STitle"].ToString();
        string Name = Session["SName"].ToString();
        string Surname = Session["SSurname"].ToString();
        string Email = Session["SE-mail"].ToString();
        Email = "mailto:" + Email;
        string Phone = Session["SPhone"].ToString();
        Phone = "tel:" + Phone;
        string dataid = Session["Sdataid"].ToString();
        string Comments = Session["SComments"].ToString();
        string Faculty = Session["SFaculty"].ToString();

        //System.Diagnostics.Debug.WriteLine(" Comments1=" + Comments);

        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

        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(person, rdftype, foafPerson); //FOAFPERSON

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

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

        g.Assert(person, IComments, g.CreateLiteralNode(UpdatedComments));
           // System.Diagnostics.Debug.WriteLine(" Comments2=" + UpdatedComments);
        rdfxmlwriter.Save(g, path_user + Session["UserId"].ToString() + ".rdf");
        LoadPersonalData();
        //END RDF

        //Reset the edit index.
        GridView2.EditIndex = -1;
        GridView2.DataSource = dt2Datas;
        //Bind data to the GridView control.
        GridView2.DataBind();
        //ViewState["dt2Datas"] = dt2Datas;
    }
开发者ID:pc3g11,项目名称:phonebook,代码行数:84,代码来源:Search.aspx.cs

示例7: ProcessIncludes

 private static void ProcessIncludes(Graph g)
 {
     var includeTriple =
         g.GetTriplesWithPredicate(new Uri("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include")).
             FirstOrDefault();
     while(includeTriple != null) {
         if (includeTriple.Object.NodeType == NodeType.Blank)
         {
             ProcessList(includeTriple.Object, g, ProcessInclude);
         }
         else
         {
             ProcessInclude(includeTriple.Object, g);
         }
         g.Retract(includeTriple);
         includeTriple = g.GetTriplesWithPredicate(new Uri("http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#include")).
             FirstOrDefault();
     }
 }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:19,代码来源:TestManifest.cs


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