Ejemplo n.º 1
0
        public static bool TryParse(string data, out MarketDay marketDay)
        {
            var pattern    = @"\d{4}-\d{2}-\d{2}(,\d+.\d+){5},\d+"; // yyyy-mm-dd , (123.456) --> 5 times , 789
            var expression = new Regex(pattern);

            if (expression.IsMatch(data))
            {
                var splitData = data.Split(",");
                marketDay = new MarketDay(
                    date: DateTime.ParseExact(splitData[0], "yyyy-MM-dd", null),
                    open: splitData[1].ParseDotComma(),
                    high: splitData[2].ParseDotComma(),
                    low: splitData[3].ParseDotComma(),
                    close: splitData[4].ParseDotComma(),
                    adjClose: splitData[5].ParseDotComma(),
                    volume: long.Parse(splitData[6])
                    );
                return(true);
            }
            else
            {
                marketDay = new MarketDay();
                return(false);
            }
        }
        public static List <MarketDay> Reader(string[] content)
        {
            MarketDay marketDay = new MarketDay();

            return((from dailyContent in content
                    where MarketDay.TryParse(dailyContent, out marketDay)
                    select marketDay)
                   .ToList());
        }
Ejemplo n.º 3
0
        public static bool TryParse(string data, out MarketDay marketDay)
        {
            /*
             *
             * Your code belongs here!
             *
             */

            throw new NotImplementedException();
        }