internal static long GetRowSizeForObjectCollection(SyncUtil.ObjectCollection row) { long num = 0L; foreach (object obj in row.EnumColumns()) { string s = obj as string; byte[] numArray = obj as byte[]; if (obj == null) { ++num; } else if (obj is Guid) { num += 16L; } else if (s != null) { num += (long)Encoding.Unicode.GetByteCount(s); } else if (numArray != null) { num += (long)numArray.Length; } else { num += SyncUtil.GetSizeForType(obj.GetType()); } } return(num); }
//internal static long GetRowSizeFromReader(IDataReader reader, DbDataReaderHandler readerHandler) //{ // long num = 0L; // for (int i = 0; i < reader.FieldCount; ++i) // { // if (!readerHandler.IsTombstone || readerHandler.IdAndMetadataColumns[i]) // { // Type fieldType = reader.GetFieldType(i); // if (reader.IsDBNull(i)) // num += 5L; // else if (fieldType == typeof(Guid)) // num += 16L; // else if (fieldType == typeof(byte[])) // num += reader.GetBytes(i, 0L, (byte[])null, 0, 0); // else if (fieldType == typeof(string)) // num += reader.GetChars(i, 0L, (char[])null, 0, 0) * 2L; // else // num += SyncUtil.GetSizeForType(fieldType); // } // } // return num; //} internal static long GetRowSizeFromDataRow(DataRow row) { bool flag = false; if (row.RowState == DataRowState.Deleted) { row.RejectChanges(); flag = true; } long num = 0L; foreach (object obj in row.ItemArray) { string s = obj as string; byte[] numArray = obj as byte[]; if (obj is DBNull) { num += 5L; } else if (obj is Guid) { num += 16L; } else if (s != null) { num += (long)Encoding.Unicode.GetByteCount(s); } else if (numArray != null) { num += (long)numArray.Length; } else { num += SyncUtil.GetSizeForType(obj.GetType()); } } if (flag) { row.Delete(); } return(num); }