internal override void Input(ref DateTime Value) { Value = DateType.FromObject(this.ParseInputString(ref this.InputStr())); }
internal override void PutObject(object Value, long RecordNumber = 0L, bool ContainedInVariant = true) { this.ValidateWriteable(); if (Value == null) { this.PutEmpty(RecordNumber); } else { Type enumType = Value.GetType(); if (enumType == null) { throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_UnsupportedIOType1", new string[] { "Empty" })), 5); } if (enumType.IsArray) { this.PutDynamicArray(RecordNumber, (Array)Value, true, -1); } else { if (enumType.IsEnum) { enumType = Enum.GetUnderlyingType(enumType); } switch (Type.GetTypeCode(enumType)) { case TypeCode.DBNull: this.PutShort(RecordNumber, 1, false); return; case TypeCode.Boolean: this.PutBoolean(RecordNumber, BooleanType.FromObject(Value), ContainedInVariant); return; case TypeCode.Char: this.PutChar(RecordNumber, Microsoft.VisualBasic.CompilerServices.CharType.FromObject(Value), ContainedInVariant); return; case TypeCode.Byte: this.PutByte(RecordNumber, ByteType.FromObject(Value), ContainedInVariant); return; case TypeCode.Int16: this.PutShort(RecordNumber, ShortType.FromObject(Value), ContainedInVariant); return; case TypeCode.Int32: this.PutInteger(RecordNumber, IntegerType.FromObject(Value), ContainedInVariant); return; case TypeCode.Int64: this.PutLong(RecordNumber, LongType.FromObject(Value), ContainedInVariant); return; case TypeCode.Single: this.PutSingle(RecordNumber, SingleType.FromObject(Value), ContainedInVariant); return; case TypeCode.Double: this.PutDouble(RecordNumber, DoubleType.FromObject(Value), ContainedInVariant); return; case TypeCode.Decimal: this.PutDecimal(RecordNumber, DecimalType.FromObject(Value), ContainedInVariant); return; case TypeCode.DateTime: this.PutDate(RecordNumber, DateType.FromObject(Value), ContainedInVariant); return; case TypeCode.String: this.PutVariantString(RecordNumber, Value.ToString()); return; } if (enumType == typeof(Missing)) { throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_UnsupportedIOType1", new string[] { "Missing" })), 5); } if (enumType.IsValueType && !ContainedInVariant) { this.PutRecord(RecordNumber, (ValueType)Value); } else { if (ContainedInVariant && enumType.IsValueType) { throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_PutObjectOfValueType1", new string[] { Utils.VBFriendlyName(enumType, Value) })), 5); } throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_UnsupportedIOType1", new string[] { Utils.VBFriendlyName(enumType, Value) })), 5); } } } }
public bool Callback(FieldInfo field_info, ref object vValue) { bool flag; string str; Type fieldType = field_info.FieldType; if (fieldType == null) { throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_UnsupportedFieldType2", new string[] { field_info.Name, "Empty" })), 5); } if (fieldType.IsArray) { VBFixedArrayAttribute attribute; int fixedStringLength = -1; object[] objArray = field_info.GetCustomAttributes(typeof(VBFixedArrayAttribute), false); if ((objArray != null) && (objArray.Length != 0)) { attribute = (VBFixedArrayAttribute)objArray[0]; } else { attribute = null; } Type elementType = fieldType.GetElementType(); if (elementType == typeof(string)) { objArray = field_info.GetCustomAttributes(typeof(VBFixedStringAttribute), false); if ((objArray == null) || (objArray.Length == 0)) { fixedStringLength = -1; } else { fixedStringLength = ((VBFixedStringAttribute)objArray[0]).Length; } } if (attribute == null) { this.m_oFile.PutDynamicArray(0L, (Array)vValue, false, fixedStringLength); return(flag); } this.m_oFile.PutFixedArray(0L, (Array)vValue, elementType, fixedStringLength, attribute.FirstBound, attribute.SecondBound); return(flag); } switch (Type.GetTypeCode(fieldType)) { case TypeCode.DBNull: throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_UnsupportedFieldType2", new string[] { field_info.Name, "DBNull" })), 5); case TypeCode.Boolean: this.m_oFile.PutBoolean(0L, BooleanType.FromObject(vValue), false); return(flag); case TypeCode.Char: this.m_oFile.PutChar(0L, Microsoft.VisualBasic.CompilerServices.CharType.FromObject(vValue), false); return(flag); case TypeCode.Byte: this.m_oFile.PutByte(0L, ByteType.FromObject(vValue), false); return(flag); case TypeCode.Int16: this.m_oFile.PutShort(0L, ShortType.FromObject(vValue), false); return(flag); case TypeCode.Int32: this.m_oFile.PutInteger(0L, IntegerType.FromObject(vValue), false); return(flag); case TypeCode.Int64: this.m_oFile.PutLong(0L, LongType.FromObject(vValue), false); return(flag); case TypeCode.Single: this.m_oFile.PutSingle(0L, SingleType.FromObject(vValue), false); return(flag); case TypeCode.Double: this.m_oFile.PutDouble(0L, DoubleType.FromObject(vValue), false); return(flag); case TypeCode.Decimal: this.m_oFile.PutDecimal(0L, DecimalType.FromObject(vValue), false); return(flag); case TypeCode.DateTime: this.m_oFile.PutDate(0L, DateType.FromObject(vValue), false); return(flag); case TypeCode.String: if (vValue == null) { str = null; break; } str = vValue.ToString(); break; default: if (fieldType == typeof(object)) { this.m_oFile.PutObject(vValue, 0L, true); return(flag); } if (fieldType == typeof(Exception)) { throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_UnsupportedFieldType2", new string[] { field_info.Name, "Exception" })), 5); } if (fieldType == typeof(Missing)) { throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_UnsupportedFieldType2", new string[] { field_info.Name, "Missing" })), 5); } throw ExceptionUtils.VbMakeException(new ArgumentException(Utils.GetResourceString("Argument_UnsupportedFieldType2", new string[] { field_info.Name, fieldType.Name })), 5); } object[] customAttributes = field_info.GetCustomAttributes(typeof(VBFixedStringAttribute), false); if ((customAttributes == null) || (customAttributes.Length == 0)) { this.m_oFile.PutStringWithLength(0L, str); return(flag); } VBFixedStringAttribute attribute2 = (VBFixedStringAttribute)customAttributes[0]; int length = attribute2.Length; if (length == 0) { length = -1; } this.m_oFile.PutFixedLengthString(0L, str, length); return(flag); }