示例#1
0
        public void Merge(ResourceStatementCollection statements, ResourceMap map)
        {
            if (this == statements)
            {
                return;
            }

            Hashtable equivalentResources = new Hashtable();

            foreach (Resource resource in statements.ReferencedResources)
            {
                Resource internalResource = resource;

                foreach (GraphMember member in map.GetNodesDenoting(resource))
                {
                    if (HasResourceDenotedBy(member))
                    {
                        internalResource = GetResourceDenotedBy(member);
                        equivalentResources[resource] = internalResource;
                        break;
                    }

                    // Must be a new resource
                    // Remember this for when we're Adding statements
                    // TODO: move this outside the loop
                    equivalentResources[resource] = resource;
                }

                foreach (GraphMember member in map.GetNodesDenoting(resource))
                {
                    AddDenotation(member, internalResource);
                }
            }

            IEnumerator statementEnumerator = statements.GetStatementEnumerator();

            while (statementEnumerator.MoveNext())
            {
                ResourceStatement statement         = (ResourceStatement)statementEnumerator.Current;
                ResourceStatement internalStatement = new ResourceStatement((Resource)equivalentResources[statement.GetSubject()],
                                                                            (Resource)equivalentResources[statement.GetPredicate()],
                                                                            (Resource)equivalentResources[statement.GetObject()]);
                Add(internalStatement);
            }
        }