Ejemplo n.º 1
0
            public Resource Persist(Resource r)
            {
                if (!(r is BNode) || !sparql.AllowPersistBNodes)
                {
                    return(r);
                }
                if (!(source is SupportsPersistableBNodes))
                {
                    return(r);
                }
                SupportsPersistableBNodes spb = (SupportsPersistableBNodes)source;
                string guid = spb.GetStoreGuid();

                if (guid == null)
                {
                    return(r);
                }
                string id = spb.GetNodeId((BNode)r);

                if (id == null)
                {
                    return(r);
                }
                return(new Entity(Sparql.BNodePersistUri + guid + ":" + id));
            }
Ejemplo n.º 2
0
            public Resource Depersist(Resource r)
            {
                if (r.Uri == null || !sparql.AllowPersistBNodes)
                {
                    return(r);
                }
                if (!(source is SupportsPersistableBNodes))
                {
                    return(r);
                }
                if (!r.Uri.StartsWith(Sparql.BNodePersistUri))
                {
                    return(r);
                }

                SupportsPersistableBNodes spb = (SupportsPersistableBNodes)source;
                string uri  = r.Uri;
                string guid = uri.Substring(Sparql.BNodePersistUri.Length);
                int    c    = guid.IndexOf(':');

                if (c > 0)
                {
                    string id = guid.Substring(c + 1);
                    guid = guid.Substring(0, c);
                    if (spb.GetStoreGuid() != null && guid == spb.GetStoreGuid())
                    {
                        BNode node = spb.GetNodeFromId(id);
                        if (node != null)
                        {
                            return(node);
                        }
                    }
                }

                return(r);
            }