System.Data.ProviderBase.SchemaMapping.GetMappedValues C# (CSharp) Method

GetMappedValues() private method

private GetMappedValues ( ) : object[]
return object[]
        private object[] GetMappedValues()
        { // mode 0
            if (null != _xmlMap)
            {
                for (int i = 0; i < _xmlMap.Length; ++i)
                {
                    if (0 != _xmlMap[i])
                    {
                        // get the string/SqlString xml value
                        string xml = _readerDataValues[i] as string;
                        if ((null == xml) && (_readerDataValues[i] is System.Data.SqlTypes.SqlString))
                        {
                            System.Data.SqlTypes.SqlString x = (System.Data.SqlTypes.SqlString)_readerDataValues[i];
                            if (!x.IsNull)
                            {
                                xml = x.Value;
                            }
                            else
                            {
                                switch (_xmlMap[i])
                                {
                                    case SqlXml:
                                        // map strongly typed SqlString.Null to SqlXml.Null
                                        _readerDataValues[i] = System.Data.SqlTypes.SqlXml.Null;
                                        break;
                                    default:
                                        _readerDataValues[i] = DBNull.Value;
                                        break;
                                }
                            }
                        }
                        if (null != xml)
                        {
                            switch (_xmlMap[i])
                            {
                                case SqlXml: // turn string into a SqlXml value for DataColumn
                                    System.Xml.XmlReaderSettings settings = new System.Xml.XmlReaderSettings();
                                    settings.ConformanceLevel = System.Xml.ConformanceLevel.Fragment;
                                    System.Xml.XmlReader reader = System.Xml.XmlReader.Create(new System.IO.StringReader(xml), settings, (string)null);
                                    _readerDataValues[i] = new System.Data.SqlTypes.SqlXml(reader);
                                    break;
                                case XmlDocument: // turn string into XmlDocument value for DataColumn
                                    System.Xml.XmlDocument document = new System.Xml.XmlDocument();
                                    document.LoadXml(xml);
                                    _readerDataValues[i] = document;
                                    break;
                            }
                            // default: let value fallthrough to DataSet which may fail with ArgumentException
                        }
                    }
                }
            }

            switch (_mappedMode)
            {
                default:
                case MapExactMatch:
                    Debug.Assert(0 == _mappedMode, "incorrect mappedMode");
                    Debug.Assert((null == _chapterMap) && (null == _indexMap) && (null == _mappedDataValues), "incorrect MappedValues");
                    return _readerDataValues;  // from reader to dataset
                case MapDifferentSize:
                    Debug.Assert((null == _chapterMap) && (null == _indexMap) && (null != _mappedDataValues), "incorrect MappedValues");
                    MappedValues();
                    break;
                case MapReorderedValues:
                    Debug.Assert((null == _chapterMap) && (null != _indexMap) && (null != _mappedDataValues), "incorrect MappedValues");
                    MappedIndex();
                    break;
                case MapChapters:
                    Debug.Assert((null != _chapterMap) && (null == _indexMap) && (null != _mappedDataValues), "incorrect MappedValues");
                    MappedChapter();
                    break;
                case MapChaptersReordered:
                    Debug.Assert((null != _chapterMap) && (null != _indexMap) && (null != _mappedDataValues), "incorrect MappedValues");
                    MappedChapterIndex();
                    break;
            }
            return _mappedDataValues;
        }