[ResourceConsumption(ResourceScope.Assembly | ResourceScope.Machine)] // MappedRootType constructor call.
 internal MappedTable(MappedMetaModel model, TableMapping mapping, Type rowType) {
     this.model = model;
     this.mapping = mapping;
     this.rowType = new MappedRootType(model, this, mapping.RowType, rowType);
 }
        private static TableMapping ReadTableMapping(XmlReader reader) {
            System.Diagnostics.Debug.Assert(reader.NodeType == XmlNodeType.Element);
            if (!IsInNamespace(reader) || reader.LocalName != XmlMappingConstant.Table) {
                throw Error.UnexpectedElement(XmlMappingConstant.Table, String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}{1}{2}", reader.Prefix, String.IsNullOrEmpty(reader.Prefix) ? "" : "/", reader.LocalName));
            }

            ValidateAttributes(reader, new[] { 
                                               XmlMappingConstant.Name, 
                                               XmlMappingConstant.Member
                                           });

            TableMapping tm = new TableMapping();
            tm.TableName = OptionalAttribute(reader, XmlMappingConstant.Name);
            tm.Member = OptionalAttribute(reader, XmlMappingConstant.Member);

            if (!reader.IsEmptyElement) {
                reader.ReadStartElement();
                reader.MoveToContent();
                while (reader.NodeType != XmlNodeType.EndElement) {
                    if (reader.NodeType == XmlNodeType.Whitespace || !IsInNamespace(reader)) {
                        reader.Skip();
                        continue;
                    }

                    switch (reader.LocalName) {
                        case XmlMappingConstant.Type:
                            if (tm.RowType != null) {
                                goto default;
                            }
                            tm.RowType = ReadTypeMapping(null, reader);
                            break;
                        default:
                            throw Error.UnrecognizedElement(String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}{1}{2}", reader.Prefix, String.IsNullOrEmpty(reader.Prefix) ? "" : "/", reader.LocalName));
                    }
                    reader.MoveToContent();
                }
                
                if (reader.LocalName != XmlMappingConstant.Table) {
                    throw Error.UnexpectedElement(XmlMappingConstant.Table, String.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}{1}{2}", reader.Prefix, String.IsNullOrEmpty(reader.Prefix) ? "" : "/", reader.LocalName));
                } 
                
                reader.ReadEndElement();
            }
            else {
                System.Diagnostics.Debug.Assert(false, "Table has no content");
                reader.Skip();
            }

            return tm;
        }