Exemplo n.º 1
0
        private void ResolveMappings(XmlReader reader, MetadataFile file)
        {
            if (reader.ReadState == ReadState.Initial)
            {
                reader.Read();
            }

            if (reader.NodeType != XmlNodeType.Element)
            {
                throw new InvalidOperationException("The reader position is invalid.");
            }

            int depth = reader.Depth;

            while (reader.Read() && reader.Depth > depth)
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                MetadataMapping mapping = null;

                var conceptName = reader.GetAttribute(XML_ENTITY_ATTRIBUTE, XML_CONCEPT_NAMESPACE_URI);
                var storageName = reader.GetAttribute(XML_ENTITY_ATTRIBUTE, XML_STORAGE_NAMESPACE_URI);

                if (conceptName != null && storageName != null)
                {
                    mapping = new MetadataMappingEntity(file, conceptName, storageName);
                    this.ResolveEntityMapping(reader, (MetadataMappingEntity)mapping);
                }
                else
                {
                    conceptName = reader.GetAttribute(XML_COMMAND_ATTRIBUTE, XML_CONCEPT_NAMESPACE_URI);
                    storageName = reader.GetAttribute(XML_COMMAND_ATTRIBUTE, XML_STORAGE_NAMESPACE_URI);

                    if (conceptName != null && storageName != null)
                    {
                        mapping = new MetadataMappingCommand(file, conceptName, storageName);
                        this.ResolveCommandMapping(reader, (MetadataMappingCommand)mapping);
                    }
                }

                if (mapping == null)
                {
                    throw new MetadataException(string.Format("Invalid mapping element in this '{0}' file.", file.Url));
                }

                file.Mappings.Add(mapping);
            }
        }
Exemplo n.º 2
0
        private void ResolveEntityMapping(XmlReader reader, MetadataMappingEntity mapping)
        {
            if (reader.ReadState == ReadState.Initial)
            {
                reader.Read();
            }

            int depth = reader.Depth;

            while (reader.Read() && reader.Depth > depth)
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                switch (reader.Name)
                {
                case XML_PROPERTY_ELEMENT:
                    var property = new MetadataMappingEntityProperty(
                        reader.GetAttribute(XML_NAME_ATTRIBUTE),
                        reader.GetAttribute(XML_FIELD_ATTRIBUTE));

                    mapping.Properties.Add(property);
                    break;

                case XML_DELETE_ELEMENT:
                    mapping.DeleteCommand = this.ResolveEntityCommand(reader, mapping);
                    break;

                case XML_INSERT_ELEMENT:
                    mapping.InsertCommand = this.ResolveEntityCommand(reader, mapping);
                    break;

                case XML_UPDATE_ELEMENT:
                    mapping.UpdateCommand = this.ResolveEntityCommand(reader, mapping);
                    break;

                case XML_SELECT_ELEMENT:
                    mapping.SelectCommand = this.ResolveEntityCommand(reader, mapping);
                    break;

                default:
                    this.ProcessUnrecognizedElement(reader, null, mapping);
                    break;
                }
            }
        }
Exemplo n.º 3
0
 internal CommandElement(MetadataMappingEntity mapping, string qualifiedName)
 {
     _mapping       = mapping;
     _qualifiedName = qualifiedName;
     _parameters    = new CommandParameterElementCollection(this);
 }
Exemplo n.º 4
0
        private MetadataMappingEntity.CommandElement ResolveEntityCommand(XmlReader reader, MetadataMappingEntity mapping)
        {
            var commandElement = mapping.CreateCommandElement(reader.GetAttribute(XML_NAME_ATTRIBUTE));

            int depth = reader.Depth;

            while (reader.Read() && reader.Depth > depth)
            {
                if (reader.NodeType != XmlNodeType.Element)
                {
                    continue;
                }

                if (reader.Name == XML_PARAMETER_ELEMENT)
                {
                    commandElement.Parameters.Add(new MetadataMappingEntity.CommandParameterElement(reader.GetAttribute(XML_NAME_ATTRIBUTE), reader.GetAttribute(XML_MAPPEDTO_ATTRIBUTE)));
                }
                else
                {
                    this.ProcessUnrecognizedElement(reader, null, commandElement);
                }
            }

            return(commandElement);
        }
Exemplo n.º 5
0
 public MetadataMappingEntityPropertyCollection(MetadataMappingEntity mapping) : base(mapping)
 {
 }