Example #1
0
        private async Task <AuctionData> GetAuctionFiles()
        {
            var i     = 1;
            var files = (await _fileService.GetStorage("RawData")).Select(x => new KeyValuePair <int, FileInfo>(i++, x)).ToList();

            files.ForEach(x =>
            {
                Console.WriteFormatted("{0}", Color.White, TypeDictionary.FormatInput(x.Key));
                Console.WriteLineFormatted(" - {0}", Color.White, TypeDictionary.FormatInput(x.Value.Name));
            });
            Console.WriteLine("");

            Console.WriteLine("");
            Console.WriteLine("Select a file:", "00CC66".ToColor());
            var key = Console.ReadLine();

            if (!files.Any(x => x.Key.ToString() == key || x.Value.Name == key))
            {
                Console.WriteLine("No such file found.. Exiting filestorage");
                return(null);
            }
            Console.WriteLine("");
            Console.WriteLine("Started loading file from storage..");
            return(await _fileService.LoadFromStorage <AuctionData>("RawData", files.First(x => x.Key.ToString() == key || x.Value.Name == key).Value.Name));

            return(null);
        }
Example #2
0
 public void PrintMethodList()
 {
     Console.WriteLine("Available methods:", "00CC66".ToColor());
     foreach (var declaringType in _methods.Select(x => x.Value.DeclaringType).Distinct())
     {
         Console.WriteLine("{0}:", declaringType.Name, "33FF99".ToColor());
         foreach (var method in _methods.Where(x => x.Value.DeclaringType == declaringType))
         {
             Console.WriteFormatted("{0}", Color.White, TypeDictionary.FormatInput(method.Key));
             Console.WriteLineFormatted(" - {0}", Color.White, TypeDictionary.FormatInput(GetMethodString(method.Value)));
         }
         Console.WriteLine("");
     }
     Console.WriteLineFormatted("Press {0} to exit", Color.White, new Formatter("ESC", "CC0066".ToColor()));
 }
Example #3
0
        private async Task PrintItemList()
        {
            await Task.Run(() =>
            {
                Console.WriteLine("");
                Console.WriteLine("Observed items", "00CC66".ToColor());

                foreach (var item in _observedItems)
                {
                    Console.WriteFormatted("{0}", Color.White, TypeDictionary.FormatInput(item.Key));
                    Console.WriteLineFormatted(" - {0}", Color.White, TypeDictionary.FormatInput(item.Value.Name));
                }
                Console.WriteLine("");
            });
        }
Example #4
0
 private async Task PrintStatistic(StatisticItem statisticItem)
 {
     await Task.Run(() =>
     {
         Console.WriteLine("");
         Console.WriteLineFormatted("Sum: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.Sum, 2)));
         Console.WriteLineFormatted("Count: {0}", Color.White, TypeDictionary.FormatInput(statisticItem.Count));
         Console.WriteLineFormatted("ArithmeticMean: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.ArithmeticMean, 2)));
         Console.WriteLineFormatted("Median: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.Median, 2)));
         Console.WriteLineFormatted("Minimum: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.Minimum, 2)));
         Console.WriteLineFormatted("Maxmimum: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.Maxmimum, 2)));
         Console.WriteLineFormatted("Range: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.Range, 2)));
         Console.WriteLineFormatted("Variance: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.Variance, 2)));
         Console.WriteLineFormatted("StandardDeviation: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.StandardDeviation, 2)));
         Console.WriteLineFormatted("SampleVariance: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.SampleVariance, 2)));
         Console.WriteLineFormatted("SampleStandardDeviation: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.SampleStandardDeviation, 2)));
         Console.WriteLineFormatted("LowerQuartile: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.LowerQuartile, 2)));
         Console.WriteLineFormatted("HigherQuartile: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.HigherQuartile, 2)));
         Console.WriteLineFormatted("QuartileDistance: {0}", Color.White, TypeDictionary.FormatInput(Math.Round(statisticItem.QuartileDistance, 2)));
         Console.WriteLine("");
     });
 }
Example #5
0
        private void ExecuteMethod(MethodInfo method)
        {
            var parameters = method.GetParameters();
            var values     = new object[parameters.Length];

            for (var i = 0; i < parameters.Length; i++)
            {
                var foundParam = false;
                Console.WriteFormatted("Insert the {0} variable", Color.White, TypeDictionary.FormatInput(parameters[i].GetTypeName()));
                Console.WriteFormatted(" '{0}':", Color.White, TypeDictionary.FormatInput(parameters[i].Name));
                while (!foundParam)
                {
                    var input = Console.ReadLine();
                    if (string.IsNullOrEmpty(input))
                    {
                        values[i]  = parameters[i].ParameterType.IsValueType ? Activator.CreateInstance(parameters[i].ParameterType) : null;
                        foundParam = true;
                    }
                    else if (parameters[i].GetType() == typeof(bool) && (input == "0" || input == "1"))
                    {
                        values[i]  = input == "1";
                        foundParam = true;
                    }
                    else if (parameters[i].GetType() == typeof(string))
                    {
                        values[i]  = input;
                        foundParam = true;
                    }
                    else
                    {
                        try
                        {
                            values[i]  = Convert.ChangeType(input, parameters[i].ParameterType);
                            foundParam = true;
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Input is invalid for {0}", parameters[i].GetTypeName());
                        }
                    }
                }
            }

            object target = this;

            foreach (var field in this.GetType().GetFields())
            {
                if (field.FieldType == method.DeclaringType)
                {
                    target = field.GetValue(this);
                }
            }
            if (method.ReturnType == typeof(Task))
            {
                ((Task)method.Invoke(target, values)).Wait();
            }
            else
            {
                method.Invoke(target, values);
            }

            Console.WriteLine("");
        }