Exemple #1
0
        private void ReadRelationships()
        {
            if (_reader.LocalName == "relationships")
            {
                string elem = ReadNextElement();
                while (elem == "relationship")
                {
                    var id      = ReadId("id");
                    var deleted = ReadAttribute("deleted", false);
                    if (deleted == "true")
                    {
                        var cmd = new Hyperstore.Modeling.Commands.RemoveRelationshipCommand(_domain, id, false);
                        Session.Current.Execute(cmd);
                        elem = ReadNextElement();
                        continue;
                    }
                    var metadata = ReadAttribute("schema");
                    var schema   = GetSchemaFromMoniker(metadata) as ISchemaRelationship;
                    if (schema == null)
                    {
                        throw new MetadataNotFoundException(String.Format("Invalid metadata {0} for relationship {1}", metadata, id));
                    }

                    var startId = ReadId("start");
                    var endId   = ReadId("end");
                    IModelRelationship entity = null;
                    if (_allowElementOverriding)
                    {
                        entity = _domain.GetRelationship(id);
                    }

                    if (entity == null)
                    {
                        entity = _domain.CreateRelationship(schema, startId, endId, id);
                    }

                    elem = ReadProperties(entity, schema);
                }
            }
        }