Beispiel #1
0
        private List <WeatherForecast> CreateForecast()
        {
            var      rng       = RandomWrapperFactory.Create();
            DateTime startDate = DateTime.Now;

            int min          = 0;
            int max          = 0;
            int?temperatureC = null;

            return(Enumerable.Range(1, 15).Select(index => {
                var day = startDate.AddDays(index);
                if (day.Month - startDate.AddDays(index - 1).Month != 0 || temperatureC == null)
                {
                    min = temperatureStatistic[day.Month - 1].Item1;
                    max = temperatureStatistic[day.Month - 1].Item2;
                    temperatureC = rng.Next(min, max);
                }
                else
                {
                    temperatureC = temperatureC + rng.Next(-3, 3);
                    temperatureC = Math.Max(temperatureC.Value, min);
                    temperatureC = Math.Min(temperatureC.Value, max);
                }
                int weatherTypes = rng.NextDouble() < 0.5 ? 0 : (rng.NextDouble() < 0.5 ? 1 : rng.NextDouble() < 0.5 ? 2 : 3);
                double feelTemper = temperatureC.Value - (weatherTypes - 1) * 3;
                return new WeatherForecast {
                    Date = day,
                    TemperatureC = temperatureC.Value,
                    Precipitation = rng.NextDouble() < weatherTypes * 0.3,
                    CloudCover = CloudCover[weatherTypes],
                    Forecast = ConditionsForForecast.First(c => c.Item1 <= feelTemper).Item2
                };
            }).ToList());
        }
        static IEnumerable <DataPoint> GenerateDataSource()
        {
            var    rng = RandomWrapperFactory.Create();
            double x, y;

            for (int i = 0; i < 20; i++)
            {
                x = Random(5, 15);
                y = Random(5, 15);

                yield return(new(x, y));

                x = Random(5, 15);
                y = Random(-15, -5);

                yield return(new(x, y));

                x = Random(-15, -5);
                y = Random(5, 15);

                yield return(new(x, y));

                x = Random(-15, -5);
                y = Random(-15, -5);

                yield return(new(x, y));
            }
            double Random(double min, double max) => rng.NextDouble() * (max - min + 1) + min;
        }
        public static List <BalanceSheetDataItem> GetData()
        {
            IRandomWrapper random             = RandomWrapperFactory.Create(2147483);
            List <BalanceSheetDataItem> items = new List <BalanceSheetDataItem>();

            items.AddRange(FillItems(random));
            return(items);
        }
        static DeterministicRandom()
        {
            IRandomWrapper random = RandomWrapperFactory.Create(randomCount);

            deterministicRandomNumbers = new int[randomCount];
            for (int i = 0; i < randomCount; i++)
            {
                deterministicRandomNumbers[i] = random.Next(randomCount);
            }
        }
Beispiel #5
0
        private List <WeatherForecast> CreateDetailedForecast()
        {
            var      rng       = RandomWrapperFactory.Create();
            DateTime startDate = DateTime.Now.Date;

            return(Enumerable.Range(1, 15).SelectMany(day => {
                var dayDate = startDate.AddDays(day);
                int avgTemp = rng.Next(-20, 55);
                int minTemp = Math.Max(-20, avgTemp - 10);
                int maxTemp = Math.Min(55, avgTemp + 10);
                return Enumerable.Range(0, 24).Select(hour => new WeatherForecast {
                    Date = dayDate.AddHours(hour),
                    TemperatureC = rng.Next(minTemp, maxTemp),
                    Forecast = ConditionsForForecast[rng.Next(ConditionsForForecast.Length)].Item2,
                    CloudCover = CloudCover[rng.Next(CloudCover.Length)],
                    Precipitation = rng.Next(100) < 30
                });
            }).ToList());
        }