void RoundTripSingleValue(int numValues)
        {
            var pocos  = new List <SingleValuePoco>();
            var random = new Random(123);

            for (int i = 0; i < numValues; i++)
            {
                decimal wholePortion   = random.Next() % 99999;     //14-9
                decimal decimalPortion = random.Next() % 999999999; //9
                decimal value          = wholePortion + decimalPortion / 1000000000m;
                pocos.Add(new SingleValuePoco {
                    Value = value
                });
            }

            var configuration = new SerializationConfiguration()
                                .ConfigureType <SingleValuePoco>()
                                .ConfigureProperty(x => x.Value, x => { x.DecimalPrecision = 14; x.DecimalScale = 9; })
                                .Build();

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer, configuration);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new DecimalReader(stripeStreams, 1);
            var results       = reader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Value, results[i]);
            }
        }
Esempio n. 2
0
        public void ReadColumn1_ShouldProduceExpectedResults()
        {
            var stripeStreams = GetStripeStreamCollection();
            var decimalReader = new DecimalReader(stripeStreams, 1);
            var results       = decimalReader.Read().ToArray();

            Assert.Equal(6000, results.Length);
            for (int i = 0; i < results.Length; i++)
            {
                decimal?expected;
                if (i < 2000)
                {
                    var decimalPortion = 5 + i;
                    var wholePortion   = -1000 + i;
                    expected = decimal.Parse($"{wholePortion}.{decimalPortion}");
                }
                else if (i < 4000)
                {
                    expected = null;
                }
                else
                {
                    var decimalPortion = (i - 4000) + 1;
                    var wholePortion   = (i - 4000);
                    expected = decimal.Parse($"{wholePortion}.{decimalPortion}");
                }
                Assert.Equal(expected, results[i]);
            }
        }
Esempio n. 3
0
        void RoundTripSingleValue(int numValues)
        {
            var pocos  = new List <SingleValuePoco>();
            var random = new Random(123);

            for (int i = 0; i < numValues; i++)
            {
                pocos.Add(new SingleValuePoco {
                    Value = (decimal)random.Next() / (decimal)Math.Pow(10, random.Next() % 10)
                });
            }

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new DecimalReader(stripeStreams, 1);
            var results       = reader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Value, results[i]);
            }
        }
Esempio n. 4
0
        public void Run()
        {
            DecimalReader decReader = new DecimalReader();
            IntReader     intReader = new IntReader();

            decimal costOfPowerPerWStation    = decReader.ReadRange("Введiть вартiсть пiдключення живлення на одну робочу станцiю вiд {0} до {1}: ", 10, 10000);
            decimal costOfInternetPerWStation = decReader.ReadRange("Введiть вартiсть пiдключення iнтернету на одну робочу станцiю вiд {0} до {1}: ", 10, 10000);
            decimal numberOfWStation          = intReader.ReadRange("Введiть число робочих станцiй вiд {0} до {1}: ", 1, 100);

            //калькуляцiя заходу
            decimal costOfAccess = (costOfInternetPerWStation + costOfPowerPerWStation) * numberOfWStation;

            //виведення результату
            Console.WriteLine("Загальна вартiсть заходу: {0}", costOfAccess);
        }
        void RoundTripNulls(int numValues)
        {
            var pocos = new List <NullableSingleValuePoco>();

            for (int i = 0; i < numValues; i++)
            {
                pocos.Add(new NullableSingleValuePoco());
            }

            var    stream = new MemoryStream();
            Footer footer;

            StripeStreamHelper.Write(stream, pocos, out footer);
            var stripeStreams = StripeStreamHelper.GetStripeStreams(stream, footer);
            var reader        = new DecimalReader(stripeStreams, 1);
            var results       = reader.Read().ToArray();

            for (int i = 0; i < numValues; i++)
            {
                Assert.Equal(pocos[i].Value, results[i]);
            }
        }
Esempio n. 6
0
		internal ContentTypeReader[] LoadAssetReaders()
        {
#pragma warning disable 0219, 0649
            // Trick to prevent the linker removing the code, but not actually execute the code
            if (falseflag)
            {
                // Dummy variables required for it to work on iDevices ** DO NOT DELETE ** 
                // This forces the classes not to be optimized out when deploying to iDevices
                var hByteReader = new ByteReader();
                var hSByteReader = new SByteReader();
                var hDateTimeReader = new DateTimeReader();
                var hDecimalReader = new DecimalReader();
                var hBoundingSphereReader = new BoundingSphereReader();
                var hBoundingFrustumReader = new BoundingFrustumReader();
                var hRayReader = new RayReader();
                var hCharListReader = new ListReader<Char>();
                var hRectangleListReader = new ListReader<Rectangle>();
                var hVector3ListReader = new ListReader<Vector3>();
                var hStringListReader = new ListReader<StringReader>();
                var hSpriteFontReader = new SpriteFontReader();
                var hTexture2DReader = new Texture2DReader();
                var hCharReader = new CharReader();
                var hRectangleReader = new RectangleReader();
                var hStringReader = new StringReader();
                var hVector2Reader = new Vector2Reader();
                var hVector3Reader = new Vector3Reader();
                var hVector4Reader = new Vector4Reader();
                var hCurveReader = new CurveReader();
                var hIndexBufferReader = new IndexBufferReader();
                var hBoundingBoxReader = new BoundingBoxReader();
                var hMatrixReader = new MatrixReader();
                var hBasicEffectReader = new BasicEffectReader();
                var hVertexBufferReader = new VertexBufferReader();
                var hAlphaTestEffectReader = new AlphaTestEffectReader();
            }
#pragma warning restore 0219, 0649

            int numberOfReaders;
			
            // The first content byte i read tells me the number of content readers in this XNB file
            numberOfReaders = _reader.Read7BitEncodedInt();
            contentReaders = new ContentTypeReader[numberOfReaders];
		
            // For each reader in the file, we read out the length of the string which contains the type of the reader,
            // then we read out the string. Finally we instantiate an instance of that reader using reflection
            for (int i = 0; i < numberOfReaders; i++)
            {
                // This string tells us what reader we need to decode the following data
                // string readerTypeString = reader.ReadString();
				string originalReaderTypeString = _reader.ReadString();
 
				// Need to resolve namespace differences
				string readerTypeString = originalReaderTypeString;
								
				readerTypeString = PrepareType(readerTypeString);

				Type l_readerType = Type.GetType(readerTypeString);
				
            	if(l_readerType !=null)
					contentReaders[i] = (ContentTypeReader)Activator.CreateInstance(l_readerType,true);
            	else
					throw new ContentLoadException("Could not find matching content reader of type " + originalReaderTypeString + " (" + readerTypeString + ")");
				
				// I think the next 4 bytes refer to the "Version" of the type reader,
                // although it always seems to be zero
                int typeReaderVersion = _reader.ReadInt32();
            }

            return contentReaders;
        }
		internal ContentTypeReader[] LoadAssetReaders()
        {
#pragma warning disable 0219, 0649
            // Trick to prevent the linker removing the code, but not actually execute the code
            if (falseflag)
            {
                // Dummy variables required for it to work on iDevices ** DO NOT DELETE ** 
                // This forces the classes not to be optimized out when deploying to iDevices
                var hByteReader = new ByteReader();
                var hSByteReader = new SByteReader();
                var hDateTimeReader = new DateTimeReader();
                var hDecimalReader = new DecimalReader();
                var hBoundingSphereReader = new BoundingSphereReader();
                var hBoundingFrustumReader = new BoundingFrustumReader();
                var hRayReader = new RayReader();
                var hCharListReader = new ListReader<Char>();
                var hRectangleListReader = new ListReader<Rectangle>();
                var hRectangleArrayReader = new ArrayReader<Rectangle>();
                var hVector3ListReader = new ListReader<Vector3>();
                var hStringListReader = new ListReader<StringReader>();
				var hIntListReader = new ListReader<Int32>();
                var hSpriteFontReader = new SpriteFontReader();
                var hTexture2DReader = new Texture2DReader();
                var hCharReader = new CharReader();
                var hRectangleReader = new RectangleReader();
                var hStringReader = new StringReader();
                var hVector2Reader = new Vector2Reader();
                var hVector3Reader = new Vector3Reader();
                var hVector4Reader = new Vector4Reader();
                var hCurveReader = new CurveReader();
                var hIndexBufferReader = new IndexBufferReader();
                var hBoundingBoxReader = new BoundingBoxReader();
                var hMatrixReader = new MatrixReader();
                var hBasicEffectReader = new BasicEffectReader();
                var hVertexBufferReader = new VertexBufferReader();
                var hAlphaTestEffectReader = new AlphaTestEffectReader();
                var hEnumSpriteEffectsReader = new EnumReader<Graphics.SpriteEffects>();
                var hArrayFloatReader = new ArrayReader<float>();
                var hArrayVector2Reader = new ArrayReader<Vector2>();
                var hListVector2Reader = new ListReader<Vector2>();
                var hArrayMatrixReader = new ArrayReader<Matrix>();
                var hEnumBlendReader = new EnumReader<Graphics.Blend>();
                var hNullableRectReader = new NullableReader<Rectangle>();
				var hEffectMaterialReader = new EffectMaterialReader();
				var hExternalReferenceReader = new ExternalReferenceReader();
                var hSoundEffectReader = new SoundEffectReader();
                var hSongReader = new SongReader();
            }
#pragma warning restore 0219, 0649

            int numberOfReaders;
			
            // The first content byte i read tells me the number of content readers in this XNB file
            numberOfReaders = _reader.Read7BitEncodedInt();
            contentReaders = new ContentTypeReader[numberOfReaders];
		
            // For each reader in the file, we read out the length of the string which contains the type of the reader,
            // then we read out the string. Finally we instantiate an instance of that reader using reflection
            for (int i = 0; i < numberOfReaders; i++)
            {
                // This string tells us what reader we need to decode the following data
                // string readerTypeString = reader.ReadString();
				string originalReaderTypeString = _reader.ReadString();

                Func<ContentTypeReader> readerFunc;
                if (typeCreators.TryGetValue(originalReaderTypeString, out readerFunc))
                {
                    contentReaders[i] = readerFunc();
                }
                else
                {
                    //System.Diagnostics.Debug.WriteLine(originalReaderTypeString);

    				// Need to resolve namespace differences
    				string readerTypeString = originalReaderTypeString;

    				readerTypeString = PrepareType(readerTypeString);

    				var l_readerType = Type.GetType(readerTypeString);
                    if (l_readerType != null)
                    {
                        try
                        {
                            contentReaders[i] = l_readerType.GetDefaultConstructor().Invoke(null) as ContentTypeReader;
                        }
                        catch (TargetInvocationException ex)
                        {
                            // If you are getting here, the Mono runtime is most likely not able to JIT the type.
                            // In particular, MonoTouch needs help instantiating types that are only defined in strings in Xnb files. 
                            throw new InvalidOperationException(
                                "Failed to get default constructor for ContentTypeReader. To work around, add a creation function to ContentTypeReaderManager.AddTypeCreator() " +
                                "with the following failed type string: " + originalReaderTypeString);
                        }
                    }
                    else
                        throw new ContentLoadException(
                                "Could not find ContentTypeReader Type. Please ensure the name of the Assembly that contains the Type matches the assembly in the full type name: " + 
                                originalReaderTypeString + " (" + readerTypeString + ")");
                }

				// I think the next 4 bytes refer to the "Version" of the type reader,
                // although it always seems to be zero
                int typeReaderVersion = _reader.ReadInt32();
            }

            return contentReaders;
        }
Esempio n. 8
0
        internal ContentTypeReader[] LoadAssetReaders(ContentReader reader)
        {
            #pragma warning disable 0219, 0649
            /* Trick to prevent the linker removing the code, but not actually execute the code
             * FIXME: Do we really need this in FNA?
             */
            if (falseflag)
            {
                /* Dummy variables required for it to work on iDevices ** DO NOT DELETE **
                 * This forces the classes not to be optimized out when deploying to iDevices
                 */
                ByteReader hByteReader = new ByteReader();
                SByteReader hSByteReader = new SByteReader();
                DateTimeReader hDateTimeReader = new DateTimeReader();
                DecimalReader hDecimalReader = new DecimalReader();
                BoundingSphereReader hBoundingSphereReader = new BoundingSphereReader();
                BoundingFrustumReader hBoundingFrustumReader = new BoundingFrustumReader();
                RayReader hRayReader = new RayReader();
                ListReader<char> hCharListReader = new ListReader<Char>();
                ListReader<Rectangle> hRectangleListReader = new ListReader<Rectangle>();
                ArrayReader<Rectangle> hRectangleArrayReader = new ArrayReader<Rectangle>();
                ListReader<Vector3> hVector3ListReader = new ListReader<Vector3>();
                ListReader<StringReader> hStringListReader = new ListReader<StringReader>();
                ListReader<int> hIntListReader = new ListReader<Int32>();
                SpriteFontReader hSpriteFontReader = new SpriteFontReader();
                Texture2DReader hTexture2DReader = new Texture2DReader();
                CharReader hCharReader = new CharReader();
                RectangleReader hRectangleReader = new RectangleReader();
                StringReader hStringReader = new StringReader();
                Vector2Reader hVector2Reader = new Vector2Reader();
                Vector3Reader hVector3Reader = new Vector3Reader();
                Vector4Reader hVector4Reader = new Vector4Reader();
                CurveReader hCurveReader = new CurveReader();
                IndexBufferReader hIndexBufferReader = new IndexBufferReader();
                BoundingBoxReader hBoundingBoxReader = new BoundingBoxReader();
                MatrixReader hMatrixReader = new MatrixReader();
                BasicEffectReader hBasicEffectReader = new BasicEffectReader();
                VertexBufferReader hVertexBufferReader = new VertexBufferReader();
                AlphaTestEffectReader hAlphaTestEffectReader = new AlphaTestEffectReader();
                EnumReader<Microsoft.Xna.Framework.Graphics.SpriteEffects> hEnumSpriteEffectsReader = new EnumReader<Graphics.SpriteEffects>();
                ArrayReader<float> hArrayFloatReader = new ArrayReader<float>();
                ArrayReader<Vector2> hArrayVector2Reader = new ArrayReader<Vector2>();
                ListReader<Vector2> hListVector2Reader = new ListReader<Vector2>();
                ArrayReader<Matrix> hArrayMatrixReader = new ArrayReader<Matrix>();
                EnumReader<Microsoft.Xna.Framework.Graphics.Blend> hEnumBlendReader = new EnumReader<Graphics.Blend>();
                NullableReader<Rectangle> hNullableRectReader = new NullableReader<Rectangle>();
                EffectMaterialReader hEffectMaterialReader = new EffectMaterialReader();
                ExternalReferenceReader hExternalReferenceReader = new ExternalReferenceReader();
                SoundEffectReader hSoundEffectReader = new SoundEffectReader();
                SongReader hSongReader = new SongReader();
            }
            #pragma warning restore 0219, 0649

            /* The first content byte i read tells me the number of
             * content readers in this XNB file.
             */
            int numberOfReaders = reader.Read7BitEncodedInt();
            ContentTypeReader[] newReaders = new ContentTypeReader[numberOfReaders];
            BitArray needsInitialize = new BitArray(numberOfReaders);
            contentReaders = new Dictionary<Type, ContentTypeReader>(numberOfReaders);

            /* Lock until we're done allocating and initializing any new
             * content type readers... this ensures we can load content
             * from multiple threads and still cache the readers.
             */
            lock (locker)
            {
                /* For each reader in the file, we read out the
                 * length of the string which contains the type
                 * of the reader, then we read out the string.
                 * Finally we instantiate an instance of that
                 * reader using reflection.
                 */
                for (int i = 0; i < numberOfReaders; i += 1)
                {
                    /* This string tells us what reader we
                     * need to decode the following data.
                     */
                    string originalReaderTypeString = reader.ReadString();

                    Func<ContentTypeReader> readerFunc;
                    if (typeCreators.TryGetValue(originalReaderTypeString, out readerFunc))
                    {
                        newReaders[i] = readerFunc();
                        needsInitialize[i] = true;
                    }
                    else
                    {
                        // Need to resolve namespace differences
                        string readerTypeString = originalReaderTypeString;
                        readerTypeString = PrepareType(readerTypeString);

                        Type l_readerType = Type.GetType(readerTypeString);
                        if (l_readerType != null)
                        {
                            ContentTypeReader typeReader;
                            if (!contentReadersCache.TryGetValue(l_readerType, out typeReader))
                            {
                                try
                                {
                                    typeReader = l_readerType.GetDefaultConstructor().Invoke(null) as ContentTypeReader;
                                }
                                catch (TargetInvocationException ex)
                                {
                                    /* If you are getting here, the Mono runtime
                                     * is most likely not able to JIT the type.
                                     * In particular, MonoTouch needs help
                                     * instantiating types that are only defined
                                     * in strings in Xnb files.
                                     */
                                    throw new InvalidOperationException(
                                        "Failed to get default constructor for ContentTypeReader. " +
                                        "To work around, add a creation function to ContentTypeReaderManager.AddTypeCreator() " +
                                        "with the following failed type string: " + originalReaderTypeString,
                                        ex
                                    );
                                }

                                needsInitialize[i] = true;

                                contentReadersCache.Add(l_readerType, typeReader);
                            }

                            newReaders[i] = typeReader;
                        }
                        else
                        {
                            throw new ContentLoadException(
                                    "Could not find ContentTypeReader Type. " +
                                    "Please ensure the name of the Assembly that " +
                                    "contains the Type matches the assembly in the full type name: " +
                                    originalReaderTypeString + " (" + readerTypeString + ")"
                            );
                        }
                    }

                    contentReaders.Add(newReaders[i].TargetType, newReaders[i]);

                    /* I think the next 4 bytes refer to the "Version" of the type reader,
                     * although it always seems to be zero.
                     */
                    reader.ReadInt32();
                }

                // Initialize any new readers.
                for (int i = 0; i < newReaders.Length; i += 1)
                {
                    if (needsInitialize.Get(i))
                    {
                        newReaders[i].Initialize(this);
                    }
                }
            } // lock (locker)

            return newReaders;
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            if (args.Length != 1)
            {
                Console.WriteLine("Usage: <FILENAME>");
                return;
            }

            var filename = args[0];
            var stream   = new FileStream(filename, FileMode.Open, FileAccess.Read);
            var fileTail = new FileTail(stream);

            foreach (var stripe in fileTail.Stripes)
            {
                Console.WriteLine($"Reading stripe with {stripe.NumRows} rows");
                var stripeStreamCollection = stripe.GetStripeStreamCollection();

                if (fileTail.Footer.Types[0].Kind != ColumnTypeKind.Struct)
                {
                    throw new InvalidDataException($"The base type must be {nameof(ColumnTypeKind.Struct)}");
                }
                var names = fileTail.Footer.Types[0].FieldNames;

                for (int columnId = 1; columnId < fileTail.Footer.Types.Count; columnId++)
                {
                    var columnType = fileTail.Footer.Types[columnId];
                    var columnName = names[columnId - 1];

                    switch (columnType.Kind)
                    {
                    case ColumnTypeKind.Long:
                    case ColumnTypeKind.Int:
                    case ColumnTypeKind.Short:
                    {
                        Console.WriteLine($"Reading longs from column {columnId} ({columnName})");
                        var reader = new LongReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} longs");
                        break;
                    }

                    case ColumnTypeKind.Byte:
                    {
                        Console.WriteLine($"Reading bytes from column {columnId} ({columnName})");
                        var reader = new ByteReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} bytes");
                        break;
                    }

                    case ColumnTypeKind.Boolean:
                    {
                        Console.WriteLine($"Reading bools from column {columnId} ({columnName})");
                        var reader = new BooleanReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} bools");
                        break;
                    }

                    case ColumnTypeKind.Float:
                    {
                        Console.WriteLine($"Reading floats from column {columnId} ({columnName})");
                        var reader = new FloatReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} floats");
                        break;
                    }

                    case ColumnTypeKind.Double:
                    {
                        Console.WriteLine($"Reading doubles from column {columnId} ({columnName})");
                        var reader = new DoubleReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} doubles");
                        break;
                    }

                    case ColumnTypeKind.Binary:
                    {
                        Console.WriteLine($"Reading binary from column {columnId} ({columnName})");
                        var reader = new ColumnTypes.BinaryReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} binaries");
                        break;
                    }

                    case ColumnTypeKind.Decimal:
                    {
                        Console.WriteLine($"Reading decimals from column {columnId} ({columnName})");
                        var reader = new DecimalReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} decimals");
                        break;
                    }

                    case ColumnTypeKind.Timestamp:
                    {
                        Console.WriteLine($"Reading timestamps from column {columnId} ({columnName})");
                        var reader = new TimestampReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} timestamps");
                        break;
                    }

                    case ColumnTypeKind.Date:
                    {
                        Console.WriteLine($"Reading dates from column {columnId} ({columnName})");
                        var reader = new DateReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} dates");
                        break;
                    }

                    case ColumnTypeKind.String:
                    {
                        Console.WriteLine($"Reading strings from column {columnId} ({columnName})");
                        var reader = new ColumnTypes.StringReader(stripeStreamCollection, (uint)columnId);
                        var count  = reader.Read().Count();
                        Console.WriteLine($"Done reading {count} strings");
                        break;
                    }

                    default:
                        throw new NotImplementedException();
                    }
                }

                Console.WriteLine("Done reading stripe");
            }
        }
Esempio n. 10
0
        // Add some non-zero constants to the mix.
        public void AddConstantsToTDB(RandoopConfiguration config)
        {
            foreach (SimpleTypeValues vs in config.simpleTypeValues)
            {
                Type type = Type.GetType(vs.simpleType);

                if (type == null)
                {
                    throw new Common.RandoopBareExceptions.InternalError("invalid simple type in XML config file.");
                }

                foreach (FileName fn in vs.fileNames)
                {
                    string fileName = fn.fileName;
                    if (!File.Exists(fileName))
                    {
                        throw new Common.RandoopBareExceptions.InvalidUserParamsException("Configuration file does not exist: " + fileName);
                    }

                    if (type.Equals(typeof(sbyte)))
                    {
                        SByteReader r = new SByteReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(sbyte), o));
                    }
                    else if (type.Equals(typeof(byte)))
                    {
                        ByteReader r = new ByteReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(byte), o));
                    }
                    else if (type.Equals(typeof(short)))
                    {
                        ShortReader r = new ShortReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(short), o));
                    }
                    else if (type.Equals(typeof(ushort)))
                    {
                        UshortReader r = new UshortReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(ushort), o));
                    }
                    else if (type.Equals(typeof(int)))
                    {
                        IntReader r = new IntReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(int), o));
                    }
                    else if (type.Equals(typeof(uint)))
                    {
                        UintReader r = new UintReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(uint), o));
                    }
                    else if (type.Equals(typeof(long)))
                    {
                        LongReader r = new LongReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(long), o));
                    }
                    else if (type.Equals(typeof(ulong)))
                    {
                        UlongReader r = new UlongReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(ulong), o));
                    }
                    else if (type.Equals(typeof(char)))
                    {
                        CharReader r = new CharReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(char), o));
                    }
                    else if (type.Equals(typeof(float)))
                    {
                        FloatReader r = new FloatReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(float), o));
                    }
                    else if (type.Equals(typeof(double)))
                    {
                        DoubleReader r = new DoubleReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(double), o));
                    }
                    else if (type.Equals(typeof(bool)))
                    {
                        BoolReader r = new BoolReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(bool), o));
                    }
                    else if (type.Equals(typeof(decimal)))
                    {
                        DecimalReader r = new DecimalReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(decimal), o));
                    }
                    else
                    {
                        if (!type.Equals(typeof(string)))
                        {
                            throw new Common.RandoopBareExceptions.InternalError("invalid simple type in XML config file.");
                        }
                        Common.StringReader r = new Common.StringReader();
                        foreach (object o in r.Read(fileName))
                            this.AddPlan(Plan.Constant(typeof(string), o));
                    }
                }
            }
        }
		internal ContentTypeReader[] LoadAssetReaders(ContentReader reader)
        {
#pragma warning disable 0219, 0649
            // Trick to prevent the linker removing the code, but not actually execute the code
            if (falseflag)
            {
                // Dummy variables required for it to work on iDevices ** DO NOT DELETE ** 
                // This forces the classes not to be optimized out when deploying to iDevices
                var hByteReader = new ByteReader();
                var hSByteReader = new SByteReader();
                var hDateTimeReader = new DateTimeReader();
                var hDecimalReader = new DecimalReader();
                var hBoundingSphereReader = new BoundingSphereReader();
                var hBoundingFrustumReader = new BoundingFrustumReader();
                var hRayReader = new RayReader();
                var hCharListReader = new ListReader<Char>();
                var hRectangleListReader = new ListReader<Rectangle>();
                var hRectangleArrayReader = new ArrayReader<Rectangle>();
                var hVector3ListReader = new ListReader<Vector3>();
                var hStringListReader = new ListReader<StringReader>();
				var hIntListReader = new ListReader<Int32>();
                var hSpriteFontReader = new SpriteFontReader();
                var hTexture2DReader = new Texture2DReader();
                var hCharReader = new CharReader();
                var hRectangleReader = new RectangleReader();
                var hStringReader = new StringReader();
                var hVector2Reader = new Vector2Reader();
                var hVector3Reader = new Vector3Reader();
                var hVector4Reader = new Vector4Reader();
                var hCurveReader = new CurveReader();
                var hIndexBufferReader = new IndexBufferReader();
                var hBoundingBoxReader = new BoundingBoxReader();
                var hMatrixReader = new MatrixReader();
                var hBasicEffectReader = new BasicEffectReader();
                var hVertexBufferReader = new VertexBufferReader();
                var hAlphaTestEffectReader = new AlphaTestEffectReader();
                var hEnumSpriteEffectsReader = new EnumReader<Graphics.SpriteEffects>();
                var hArrayFloatReader = new ArrayReader<float>();
                var hArrayVector2Reader = new ArrayReader<Vector2>();
                var hListVector2Reader = new ListReader<Vector2>();
                var hArrayMatrixReader = new ArrayReader<Matrix>();
                var hEnumBlendReader = new EnumReader<Graphics.Blend>();
                var hNullableRectReader = new NullableReader<Rectangle>();
				var hEffectMaterialReader = new EffectMaterialReader();
				var hExternalReferenceReader = new ExternalReferenceReader();
                var hSoundEffectReader = new SoundEffectReader();
                var hSongReader = new SongReader();
                var hModelReader = new ModelReader();
                var hInt32Reader = new Int32Reader();

                // At the moment the Video class doesn't exist
                // on all platforms... Allow it to compile anyway.
#if ANDROID || IOS || MONOMAC || (WINDOWS && !OPENGL) || (WINRT && !WINDOWS_PHONE)
                var hVideoReader = new VideoReader();
#endif
            }
#pragma warning restore 0219, 0649

		    // The first content byte i read tells me the number of content readers in this XNB file
            var numberOfReaders = reader.Read7BitEncodedInt();
            var contentReaders = new ContentTypeReader[numberOfReaders];
            var needsInitialize = new BitArray(numberOfReaders);
            _contentReaders = new Dictionary<Type, ContentTypeReader>(numberOfReaders);

            // Lock until we're done allocating and initializing any new
            // content type readers...  this ensures we can load content
            // from multiple threads and still cache the readers.
            lock (_locker)
            {
                // For each reader in the file, we read out the length of the string which contains the type of the reader,
                // then we read out the string. Finally we instantiate an instance of that reader using reflection
                for (var i = 0; i < numberOfReaders; i++)
                {
                    // This string tells us what reader we need to decode the following data
                    // string readerTypeString = reader.ReadString();
                    string originalReaderTypeString = reader.ReadString();

                    Func<ContentTypeReader> readerFunc;
                    if (typeCreators.TryGetValue(originalReaderTypeString, out readerFunc))
                    {
                        contentReaders[i] = readerFunc();
                        needsInitialize[i] = true;
                    }
                    else
                    {
                        //System.Diagnostics.Debug.WriteLine(originalReaderTypeString);

                        // Need to resolve namespace differences
                        string readerTypeString = originalReaderTypeString;

                        readerTypeString = PrepareType(readerTypeString);

                        var l_readerType = Type.GetType(readerTypeString);
                        if (l_readerType != null)
                        {
                            ContentTypeReader typeReader;
                            if (!_contentReadersCache.TryGetValue(l_readerType, out typeReader))
                            {
                                try
                                {
                                    typeReader = l_readerType.GetDefaultConstructor().Invoke(null) as ContentTypeReader;
                                }
                                catch (TargetInvocationException ex)
                                {
                                    // If you are getting here, the Mono runtime is most likely not able to JIT the type.
                                    // In particular, MonoTouch needs help instantiating types that are only defined in strings in Xnb files. 
                                    throw new InvalidOperationException(
                                        "Failed to get default constructor for ContentTypeReader. To work around, add a creation function to ContentTypeReaderManager.AddTypeCreator() " +
                                        "with the following failed type string: " + originalReaderTypeString, ex);
                                }

                                needsInitialize[i] = true;

                                _contentReadersCache.Add(l_readerType, typeReader);
                            }

                            contentReaders[i] = typeReader;
                        }
                        else
                            throw new ContentLoadException(
                                    "Could not find ContentTypeReader Type. Please ensure the name of the Assembly that contains the Type matches the assembly in the full type name: " +
                                    originalReaderTypeString + " (" + readerTypeString + ")");
                    }

                    var targetType = contentReaders[i].TargetType;
                    if (targetType != null)
                      _contentReaders.Add(targetType, contentReaders[i]);

                    // I think the next 4 bytes refer to the "Version" of the type reader,
                    // although it always seems to be zero
                    reader.ReadInt32();
                }

                // Initialize any new readers.
                for (var i = 0; i < contentReaders.Length; i++)
                {
                    if (needsInitialize.Get(i))
                        contentReaders[i].Initialize(this);
                }

            } // lock (_locker)

		    return contentReaders;
        }
 public void Dispose()
 {
     _sentTexts = null;
     _sut       = null;
 }
Esempio n. 13
0
        private Action <object> CreateReader(PropertyInfo column, Dictionary <Type, Func <BinaryReader, object> > customReaders)
        {
            // Column didn't exist when write occurred.
            if (_columnStream == null)
            {
                return o => { }
            }
            ;

            if (customReaders.ContainsKey(column.PropertyType))
            {
                var reader = customReaders[column.PropertyType];

                return(o => column.SetValue(o, reader(_columnReader)));
            }

            var paramObject = Expression.Parameter(typeof(object), "o");
            var typedObject = Expression.Convert(paramObject, column.DeclaringType);

            if (column.PropertyType == typeof(bool))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean()));
            }
            if (column.PropertyType == typeof(bool?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadBoolean() : (bool?)null));
            }
            if (column.PropertyType == typeof(byte))
            {
                return(o => column.SetValue(o, _columnReader.ReadByte()));
            }
            if (column.PropertyType == typeof(byte?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadByte() : (byte?)null));
            }
            if (column.PropertyType == typeof(sbyte))
            {
                return(o => column.SetValue(o, _columnReader.ReadSByte()));
            }
            if (column.PropertyType == typeof(sbyte?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadSByte() : (sbyte?)null));
            }
            if (column.PropertyType == typeof(short))
            {
                return(o => column.SetValue(o, _columnReader.ReadInt16()));
            }
            if (column.PropertyType == typeof(short?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadInt16() : (short?)null));
            }
            if (column.PropertyType == typeof(ushort))
            {
                return(o => column.SetValue(o, _columnReader.ReadUInt16()));
            }
            if (column.PropertyType == typeof(ushort?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadUInt16() : (ushort?)null));
            }
            if (column.PropertyType == typeof(int))
            {
                return(o => column.SetValue(o, _columnReader.ReadInt32()));
            }
            if (column.PropertyType == typeof(int?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadInt32() : (int?)null));
            }
            if (column.PropertyType == typeof(uint))
            {
                return(o => column.SetValue(o, _columnReader.ReadUInt32()));
            }
            if (column.PropertyType == typeof(uint?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadUInt32() : (uint?)null));
            }
            if (column.PropertyType == typeof(long))
            {
                return(o => column.SetValue(o, _columnReader.ReadInt64()));
            }
            if (column.PropertyType == typeof(long?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadInt64() : (long?)null));
            }
            if (column.PropertyType == typeof(ulong))
            {
                return(o => column.SetValue(o, _columnReader.ReadUInt64()));
            }
            if (column.PropertyType == typeof(ulong?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadUInt64() : (ulong?)null));
            }
            if (column.PropertyType == typeof(Guid))
            {
                return(o => column.SetValue(o, new Guid(_columnReader.ReadBytes(16))));
            }
            if (column.PropertyType == typeof(Guid?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? new Guid(_columnReader.ReadBytes(16)) : (Guid?)null));
            }
            if (column.PropertyType == typeof(decimal))
            {
                var reader     = new DecimalReader(_columnStream);
                var paramValue = Expression.Parameter(typeof(decimal), "d");
                var call       = Expression.Call(typedObject, column.GetSetMethod(), paramValue);

                var setter = Expression.Lambda <Action <object, decimal> >(call, paramObject, paramValue).Compile();

                return(o => setter(o, reader.ReadDecimal(0)));
            }
            if (column.PropertyType == typeof(decimal?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadDecimal() : (decimal?)null));
            }
            if (column.PropertyType == typeof(double))
            {
                return(o => column.SetValue(o, _columnReader.ReadDouble()));
            }
            if (column.PropertyType == typeof(double?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? _columnReader.ReadDouble() : (double?)null));
            }
            if (column.PropertyType == typeof(DateTime))
            {
                return(o => column.SetValue(o, new DateTime(_columnReader.ReadInt64())));
            }
            if (column.PropertyType == typeof(DateTime?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? new DateTime(_columnReader.ReadInt64()) : (DateTime?)null));
            }
            if (column.PropertyType == typeof(DateTimeOffset))
            {
                return(o => column.SetValue(o, new DateTimeOffset(_columnReader.ReadInt64(), new TimeSpan(_columnReader.ReadInt64()))));
            }
            if (column.PropertyType == typeof(DateTimeOffset?))
            {
                return(o => column.SetValue(o, _columnReader.ReadBoolean() ? new DateTimeOffset(_columnReader.ReadInt64(), new TimeSpan(_columnReader.ReadInt64())) : (DateTimeOffset?)null));
            }
            if (column.PropertyType == typeof(string))
            {
                return(o => column.SetValue(o, _columnReader.ReadString()));
            }
            if (column.PropertyType.IsEnum)
            {
                var underlyingType = Enum.GetUnderlyingType(column.PropertyType);

                if (underlyingType == typeof(byte))
                {
                    return(o => column.SetValue(o, _columnReader.ReadByte()));
                }

                if (underlyingType == typeof(short))
                {
                    return(o => column.SetValue(o, _columnReader.ReadInt16()));
                }

                if (underlyingType == typeof(int))
                {
                    return(o => column.SetValue(o, _columnReader.ReadInt32()));
                }

                throw new NotSupportedException("Unsupported underlying enum type: " + underlyingType.FullName);
            }
            if (Nullable.GetUnderlyingType(column.PropertyType)?.IsEnum == true)
            {
                var underlyingType = Enum.GetUnderlyingType(Nullable.GetUnderlyingType(column.PropertyType));

                if (underlyingType == typeof(byte))
                {
                    return(o => column.SetValue(o, _columnReader.ReadBoolean() ? (object)_columnReader.ReadByte() : null));
                }

                if (underlyingType == typeof(short))
                {
                    return(o => column.SetValue(o, _columnReader.ReadBoolean() ? (object)_columnReader.ReadInt16() : null));
                }

                if (underlyingType == typeof(int))
                {
                    return(o => column.SetValue(o, _columnReader.ReadBoolean() ? (object)_columnReader.ReadInt32() : null));
                }

                throw new NotSupportedException("Unsupported underlying enum type: " + underlyingType.FullName);
            }
            if (column.PropertyType.IsArray)
            {
                var reader = new TypeReaderFactory(_path + column.Name + ".", column.PropertyType.GetElementType(), customReaders);
                return(o =>
                {
                    var isNonNull = _columnReader.ReadBoolean();

                    if (!isNonNull)
                    {
                        column.SetValue(o, null);
                    }
                    else
                    {
                        var length = _columnReader.ReadUInt16();
                        var array = (Array)Activator.CreateInstance(column.PropertyType, length);

                        for (int i = 0; i < length; i++)
                        {
                            array.SetValue(reader.ReadNew(), i);
                        }

                        column.SetValue(o, array);
                    }
                });
            }
            if (!column.PropertyType.IsValueType)
            {
                var reader = new TypeReaderFactory(_path + column.Name + ".", column.PropertyType, customReaders);
                return(o =>
                {
                    var isNonNull = _columnReader.ReadBoolean();
                    column.SetValue(o, isNonNull ? reader.ReadNew() : null);
                });
            }

            throw new Exception("Unsupported column type " + column.PropertyType.Name);
        }
        public void should_not_validate_non_decimals(string input)
        {
            var actual = DecimalReader.Validate(input);

            actual.Should().Be(new Option <decimal>());
        }
        public void should_validate_decimal(string input, decimal expected)
        {
            var actual = DecimalReader.Validate(input);

            actual.Should().Be((Option <decimal>)expected);
        }
Esempio n. 16
0
 internal ContentTypeReader[] LoadAssetReaders()
 {
   if (ContentTypeReaderManager.falseflag)
   {
     ByteReader byteReader = new ByteReader();
     SByteReader sbyteReader = new SByteReader();
     DateTimeReader dateTimeReader = new DateTimeReader();
     DecimalReader decimalReader = new DecimalReader();
     BoundingSphereReader boundingSphereReader = new BoundingSphereReader();
     BoundingFrustumReader boundingFrustumReader = new BoundingFrustumReader();
     RayReader rayReader = new RayReader();
     ListReader<char> listReader1 = new ListReader<char>();
     ListReader<Rectangle> listReader2 = new ListReader<Rectangle>();
     ArrayReader<Rectangle> arrayReader1 = new ArrayReader<Rectangle>();
     ListReader<Vector3> listReader3 = new ListReader<Vector3>();
     ListReader<StringReader> listReader4 = new ListReader<StringReader>();
     ListReader<int> listReader5 = new ListReader<int>();
     SpriteFontReader spriteFontReader = new SpriteFontReader();
     Texture2DReader texture2Dreader = new Texture2DReader();
     CharReader charReader = new CharReader();
     RectangleReader rectangleReader = new RectangleReader();
     StringReader stringReader = new StringReader();
     Vector2Reader vector2Reader = new Vector2Reader();
     Vector3Reader vector3Reader = new Vector3Reader();
     Vector4Reader vector4Reader = new Vector4Reader();
     CurveReader curveReader = new CurveReader();
     IndexBufferReader indexBufferReader = new IndexBufferReader();
     BoundingBoxReader boundingBoxReader = new BoundingBoxReader();
     MatrixReader matrixReader = new MatrixReader();
     BasicEffectReader basicEffectReader = new BasicEffectReader();
     VertexBufferReader vertexBufferReader = new VertexBufferReader();
     AlphaTestEffectReader testEffectReader = new AlphaTestEffectReader();
     EnumReader<SpriteEffects> enumReader1 = new EnumReader<SpriteEffects>();
     ArrayReader<float> arrayReader2 = new ArrayReader<float>();
     ArrayReader<Vector2> arrayReader3 = new ArrayReader<Vector2>();
     ListReader<Vector2> listReader6 = new ListReader<Vector2>();
     ArrayReader<Matrix> arrayReader4 = new ArrayReader<Matrix>();
     EnumReader<Blend> enumReader2 = new EnumReader<Blend>();
     NullableReader<Rectangle> nullableReader = new NullableReader<Rectangle>();
     EffectMaterialReader effectMaterialReader = new EffectMaterialReader();
     ExternalReferenceReader externalReferenceReader = new ExternalReferenceReader();
   }
   int length = this._reader.Read7BitEncodedInt();
   this.contentReaders = new ContentTypeReader[length];
   for (int index = 0; index < length; ++index)
   {
     string str = this._reader.ReadString();
     Func<ContentTypeReader> func;
     if (ContentTypeReaderManager.typeCreators.TryGetValue(str, out func))
     {
       this.contentReaders[index] = func();
     }
     else
     {
       string typeName = ContentTypeReaderManager.PrepareType(str);
       Type type = Type.GetType(typeName);
       if (type != (Type) null)
       {
         try
         {
           this.contentReaders[index] = ContentExtensions.GetDefaultConstructor(type).Invoke((object[]) null) as ContentTypeReader;
         }
         catch (TargetInvocationException ex)
         {
           throw new InvalidOperationException("Failed to get default constructor for ContentTypeReader. To work around, add a creation function to ContentTypeReaderManager.AddTypeCreator() with the following failed type string: " + str);
         }
       }
       else
         throw new ContentLoadException("Could not find matching content reader of type " + str + " (" + typeName + ")");
     }
     this._reader.ReadInt32();
   }
   return this.contentReaders;
 }
Esempio n. 17
0
        // Add some non-zero constants to the mix.
        public void AddConstantsToTDB(RandoopConfiguration config)
        {
            foreach (SimpleTypeValues vs in config.simpleTypeValues)
            {
                Type type = Type.GetType(vs.simpleType);

                if (type == null)
                {
                    throw new Common.RandoopBareExceptions.InternalError("invalid simple type in XML config file.");
                }

                foreach (FileName fn in vs.fileNames)
                {
                    string fileName = fn.fileName;
                    if (!File.Exists(fileName))
                    {
                        throw new Common.RandoopBareExceptions.InvalidUserParamsException("Configuration file does not exist: " + fileName);
                    }

                    if (type.Equals(typeof(sbyte)))
                    {
                        SByteReader r = new SByteReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(sbyte), o));
                        }
                    }
                    else if (type.Equals(typeof(byte)))
                    {
                        ByteReader r = new ByteReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(byte), o));
                        }
                    }
                    else if (type.Equals(typeof(short)))
                    {
                        ShortReader r = new ShortReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(short), o));
                        }
                    }
                    else if (type.Equals(typeof(ushort)))
                    {
                        UshortReader r = new UshortReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(ushort), o));
                        }
                    }
                    else if (type.Equals(typeof(int)))
                    {
                        IntReader r = new IntReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(int), o));
                        }
                    }
                    else if (type.Equals(typeof(uint)))
                    {
                        UintReader r = new UintReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(uint), o));
                        }
                    }
                    else if (type.Equals(typeof(long)))
                    {
                        LongReader r = new LongReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(long), o));
                        }
                    }
                    else if (type.Equals(typeof(ulong)))
                    {
                        UlongReader r = new UlongReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(ulong), o));
                        }
                    }
                    else if (type.Equals(typeof(char)))
                    {
                        CharReader r = new CharReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(char), o));
                        }
                    }
                    else if (type.Equals(typeof(float)))
                    {
                        FloatReader r = new FloatReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(float), o));
                        }
                    }
                    else if (type.Equals(typeof(double)))
                    {
                        DoubleReader r = new DoubleReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(double), o));
                        }
                    }
                    else if (type.Equals(typeof(bool)))
                    {
                        BoolReader r = new BoolReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(bool), o));
                        }
                    }
                    else if (type.Equals(typeof(decimal)))
                    {
                        DecimalReader r = new DecimalReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(decimal), o));
                        }
                    }
                    else
                    {
                        if (!type.Equals(typeof(string)))
                        {
                            throw new Common.RandoopBareExceptions.InternalError("invalid simple type in XML config file.");
                        }
                        Common.StringReader r = new Common.StringReader();
                        foreach (object o in r.Read(fileName))
                        {
                            this.AddPlan(Plan.Constant(typeof(string), o));
                        }
                    }
                }
            }
        }
 public DecimalReaderTest()
 {
     _sentTexts = new List <string>();
     _sut       = new DecimalReader((text) => { _sentTexts.Add(text); }, () => "42");
 }