Exemplo n.º 1
0
 /** <inheritdoc /> */
 public DateTime?[] ReadDateArray(bool local)
 {
     return(Read(r => PortableUtils.ReadDateArray(r, local)));
 }
Exemplo n.º 2
0
        /**
         * <summary>Static initializer.</summary>
         */
        static PortableSystemHandlers()
        {
            // 1. Primitives.

            ReadHandlers[PortableUtils.TypeBool] = new PortableSystemReader <bool>(s => s.ReadBool());

            WriteHandlers[typeof(sbyte)]         = WriteHndSbyte;
            ReadHandlers[PortableUtils.TypeByte] = new PortableSystemReader <byte>(s => s.ReadByte());

            WriteHandlers[typeof(ushort)]         = WriteHndUshort;
            ReadHandlers[PortableUtils.TypeShort] = new PortableSystemReader <short>(s => s.ReadShort());

            ReadHandlers[PortableUtils.TypeChar] = new PortableSystemReader <char>(s => s.ReadChar());

            WriteHandlers[typeof(uint)]         = WriteHndUint;
            ReadHandlers[PortableUtils.TypeInt] = new PortableSystemReader <int>(s => s.ReadInt());

            WriteHandlers[typeof(ulong)]         = WriteHndUlong;
            ReadHandlers[PortableUtils.TypeLong] = new PortableSystemReader <long>(s => s.ReadLong());

            ReadHandlers[PortableUtils.TypeFloat] = new PortableSystemReader <float>(s => s.ReadFloat());

            ReadHandlers[PortableUtils.TypeDouble] = new PortableSystemReader <double>(s => s.ReadDouble());

            ReadHandlers[PortableUtils.TypeDecimal] = new PortableSystemReader <decimal>(PortableUtils.ReadDecimal);

            // 2. Date.
            ReadHandlers[PortableUtils.TypeDate] =
                new PortableSystemReader <DateTime?>(s => PortableUtils.ReadDate(s, false));

            // 3. String.
            ReadHandlers[PortableUtils.TypeString] = new PortableSystemReader <string>(PortableUtils.ReadString);

            // 4. Guid.
            ReadHandlers[PortableUtils.TypeGuid] = new PortableSystemReader <Guid?>(PortableUtils.ReadGuid);

            // 5. Primitive arrays.
            ReadHandlers[PortableUtils.TypeArrayBool] = new PortableSystemReader <bool[]>(PortableUtils.ReadBooleanArray);

            WriteHandlers[typeof(sbyte[])]            = WriteHndSbyteArray;
            ReadHandlers[PortableUtils.TypeArrayByte] =
                new PortableSystemDualReader <byte[], sbyte[]>(PortableUtils.ReadByteArray, PortableUtils.ReadSbyteArray);

            WriteHandlers[typeof(ushort[])]            = WriteHndUshortArray;
            ReadHandlers[PortableUtils.TypeArrayShort] =
                new PortableSystemDualReader <short[], ushort[]>(PortableUtils.ReadShortArray,
                                                                 PortableUtils.ReadUshortArray);

            ReadHandlers[PortableUtils.TypeArrayChar] =
                new PortableSystemReader <char[]>(PortableUtils.ReadCharArray);

            WriteHandlers[typeof(uint[])]            = WriteHndUintArray;
            ReadHandlers[PortableUtils.TypeArrayInt] =
                new PortableSystemDualReader <int[], uint[]>(PortableUtils.ReadIntArray, PortableUtils.ReadUintArray);


            WriteHandlers[typeof(ulong[])]            = WriteHndUlongArray;
            ReadHandlers[PortableUtils.TypeArrayLong] =
                new PortableSystemDualReader <long[], ulong[]>(PortableUtils.ReadLongArray,
                                                               PortableUtils.ReadUlongArray);

            ReadHandlers[PortableUtils.TypeArrayFloat] =
                new PortableSystemReader <float[]>(PortableUtils.ReadFloatArray);

            ReadHandlers[PortableUtils.TypeArrayDouble] =
                new PortableSystemReader <double[]>(PortableUtils.ReadDoubleArray);

            ReadHandlers[PortableUtils.TypeArrayDecimal] =
                new PortableSystemReader <decimal[]>(PortableUtils.ReadDecimalArray);

            // 6. Date array.
            ReadHandlers[PortableUtils.TypeArrayDate] =
                new PortableSystemReader <DateTime?[]>(s => PortableUtils.ReadDateArray(s, false));

            // 7. String array.
            ReadHandlers[PortableUtils.TypeArrayString] = new PortableSystemGenericArrayReader <string>();

            // 8. Guid array.
            ReadHandlers[PortableUtils.TypeArrayGuid] = new PortableSystemGenericArrayReader <Guid?>();

            // 9. Array.
            ReadHandlers[PortableUtils.TypeArray] = new PortableSystemReader(ReadArray);

            // 10. Predefined collections.
            WriteHandlers[typeof(ArrayList)] = WriteArrayList;

            // 11. Predefined dictionaries.
            WriteHandlers[typeof(Hashtable)] = WriteHashtable;

            // 12. Arbitrary collection.
            ReadHandlers[PortableUtils.TypeCollection] = new PortableSystemReader(ReadCollection);

            // 13. Arbitrary dictionary.
            ReadHandlers[PortableUtils.TypeDictionary] = new PortableSystemReader(ReadDictionary);

            // 14. Map entry.
            WriteHandlers[typeof(DictionaryEntry)]   = WriteMapEntry;
            ReadHandlers[PortableUtils.TypeMapEntry] = new PortableSystemReader(ReadMapEntry);

            // 15. Portable.
            WriteHandlers[typeof(PortableUserObject)] = WritePortable;

            // 16. Enum.
            ReadHandlers[PortableUtils.TypeEnum]      = new PortableSystemReader <int>(PortableUtils.ReadEnum <int>);
            ReadHandlers[PortableUtils.TypeArrayEnum] = new PortableSystemReader(ReadEnumArray);
        }
Exemplo n.º 3
0
 /** <inheritdoc /> */
 public DateTime?[] ReadDateArray(string fieldName, bool local)
 {
     return(ReadField(fieldName, r => PortableUtils.ReadDateArray(r, local)));
 }