/// <summary> /// Convert non-serializable DataRow, DataView, DataRowView, DataRowCollection to a DataTable /// and send it to <see cref="StreamSerializer.ObjectToStream(Stream, object)"/> to create a /// serializable Stream. /// </summary> /// <param name="target"></param> /// <param name="outgoingData"></param> public override void GetData(object target, Stream outgoingData) { if (target != null) { ///////////// DataRow /////////////////////// if (target is DataRow) { DataRow row = target as DataRow; DataTable table; if (row.Table == null) { table = new DataTable("DataRowDebuggerTableObjectSource"); for (int i = 0; i < row.ItemArray.Length; i++) { table.Columns.Add(string.Format("Col{o}", i.ToString()), typeof(string)); } } else { table = row.Table.Clone(); } } ///////////// DataView /////////////////////// else if (target is DataView) { DataView view = target as DataView; DataTable table; table = view.Table.Clone(); foreach (DataRow row in view.Table.Rows) { table.LoadDataRow(row.ItemArray, true); } StreamSerializer.ObjectToStream(outgoingData, table); } ///////////// DataRowView /////////////////////// else if (target is DataRowView) { DataRowView view = target as DataRowView; DataTable table = table = view.Row.Table.Clone(); table.LoadDataRow(view.Row.ItemArray, true); StreamSerializer.ObjectToStream(outgoingData, table); } ///////////// DataRowCollection /////////////////////// else if (target is DataRowCollection) { DataRowCollection rows = target as DataRowCollection; DataTable table = null; if (rows != null && rows.Count > 0) { if (rows[0].Table == null) { table = new DataTable("DataRowDebuggerTableObjectSource"); for (int i = 0; i < rows[0].ItemArray.Length; i++) { table.Columns.Add(string.Format("Col{o}", i.ToString()), typeof(string)); } } else { table = rows[0].Table.Clone(); } foreach (DataRow row in rows) { table.LoadDataRow(row.ItemArray, true); } } StreamSerializer.ObjectToStream(outgoingData, table); } // else if } // if (target == null) } // getdata