protected void SetupRenderers() { Array[] modelRow = ReplaceTroolean(_rs.ModelRow); Array[] modelRow2 = null; switch (_writeMode) { case StringWriteMode.HEAP: case StringWriteMode.PAD: modelRow2 = CopyModelRowReplaceStrings(modelRow, new int[2]); modelRow2 = CopyModelRowStripUnknowns(modelRow2, new byte[1]); // _rowSizeInBytes = ArrayFuncs.ComputeSize(CopyModelRowReplaceStrings(modelRow, new int[2])); _rowSizeInBytes = ArrayFuncs.ComputeSize(modelRow2); modelRow2 = CopyModelRowStripUnknowns(modelRow, new byte[1]); //myHeader = ManufactureHeader(modelRow, _rs.ColumnNames, _rs.TNULL, _rs.NRows); myHeader = ManufactureHeader(modelRow2, _rs.ColumnNames, _rs.TNULL, _rs.NRows); _stringArrayRenderer = ByteRenderer.STRING_ARRAY_RENDERER_HEAP; break; case StringWriteMode.TRUNCATE: modelRow2 = CopyModelRowReplaceStrings(modelRow, new String[] { new String(' ', _stringTruncationLength) }); modelRow2 = CopyModelRowStripUnknowns(modelRow2, new byte[1]); _rowSizeInBytes = ArrayFuncs.ComputeSize(modelRow2); myHeader = ManufactureHeader(modelRow2, _rs.ColumnNames, _rs.TNULL, _rs.NRows); _stringArrayRenderer = new ByteRenderer.StringArrayByteRendererTruncate(_stringTruncationLength, _padChar, _padLeft, false); break; } _hasStrings = false; for (int i = 0; i < _rs.ModelRow.Length; ++i) { _byteRenderers[i] = ByteRenderer.GetByteRenderer(_rs.ModelRow[i].GetType()); if (_rs.ModelRow[i] is String[]) { _byteRenderers[i] = _stringArrayRenderer; _hasStrings = true; } if (_byteRenderers[i].GetType() == typeof(ByteRenderer.NullByteRenderer)) { myHeader.AddComment("COLUMN " + (i + 1) + " NULL DUE TO UNKNOWN TYPE."); } } }
protected static Array[] CopyModelRowStripUnknowns(Array[] a, Array a2) { Array[] result = new Array[a.Length]; for (int i = 0; i < a.Length; ++i) { if (a[i] == null || (a[i].GetType() != typeof(String[]) && ByteRenderer.GetByteRenderer(a[i].GetType()).GetType() == typeof(ByteRenderer.NullByteRenderer))) { result[i] = a2; } else { result[i] = a[i]; } } return(result); }