public CompuTrainerTXTFileProvider(SourcedStream sourced)
        {
            this.input = new StreamReader(sourced.Stream, Encoding.ASCII, true);

            ParseStartTimeFromFileName(sourced.Source);
            ReadHeaderInfomation();
        }
Esempio n. 2
0
        public static ILeMondDataProvider Create(SourcedStream sourcedStream)
        {
            var parser = new TextFieldParser(sourcedStream.Stream);

            parser.TextFieldType = FieldType.Delimited;
            parser.Delimiters    = new[] { "," };
            if (parser.EndOfData)
            {
                throw new Exception(string.Format("The file {0} does not seem to be a valid LeMond .csv file because it is empty.", sourcedStream.Source));
            }

            var row = parser.ReadFields();

            if (!(row.Length >= 1 && row[0] == "LeMond"))
            {
                throw new Exception(string.Format("The file {0} does not seem to be a valid LeMond .csv file because it doesn't say 'LeMond' in the first field.", sourcedStream.Source));
            }


            if (row.Length >= 4 && row[3] == "gforce")
            {
                return(new LeMondGForceCsvDataProvider(sourcedStream.Source, parser, row));
            }
            if (row.Length >= 4 && row[3] == "STN")
            {
                return(new LeMondGForceSTNCsvDataProvider(sourcedStream.Source, parser, row));
            }
            else if (row.Length >= 2 && row[1] == "Revolution")
            {
                return(new LeMondRevolutionCsvDataProvider(sourcedStream.Source, parser, row));
            }

            throw new Exception(string.Format("Not a recognized LeMond device. Header = '{0}'", string.Join(",", row)));
        }
        public static ILeMondDataProvider Create(SourcedStream sourcedStream)
        {
            
            var parser = new TextFieldParser(sourcedStream.Stream);
            parser.TextFieldType = FieldType.Delimited;
            parser.Delimiters = new[] { "," };
            if (parser.EndOfData)
            {
                throw new Exception(string.Format("The file {0} does not seem to be a valid LeMond .csv file because it is empty.", sourcedStream.Source));
            }

            var row = parser.ReadFields();
            if (!(row.Length >= 1 && row[0] == "LeMond"))
            {
                throw new Exception(string.Format("The file {0} does not seem to be a valid LeMond .csv file because it doesn't say 'LeMond' in the first field.", sourcedStream.Source));
            }


            if (row.Length >= 4 && row[3] == "gforce")
            {
                return new LeMondGForceCsvDataProvider(sourcedStream.Source, parser, row);
            }
            if (row.Length >= 4 && row[3] == "STN")
            {
                return new LeMondGForceSTNCsvDataProvider(sourcedStream.Source, parser, row);
            }
            else if (row.Length >= 2 && row[1] == "Revolution")
            {
                return new LeMondRevolutionCsvDataProvider(sourcedStream.Source, parser, row);
            }

            throw new Exception(string.Format("Not a recognized LeMond device. Header = '{0}'", string.Join(",", row)));
            
        }
        public static XtrainerDataProvider Create(SourcedStream sourcedStream)
        {
            
            var parser = new TextFieldParser(sourcedStream.Stream)
                {
                    TextFieldType = FieldType.Delimited,
                    Delimiters = new[] {","}
                };
            if (parser.EndOfData)
            {
                throw new Exception(string.Format("The file {0} does not seem to be a valid xtrainer .csvx file because it is empty.", sourcedStream.Source));
            }

            var rows = parser.ReadFields();
            if (!(rows.Length >= 1 && rows[0] == "ver"))
            {
                throw new Exception(string.Format("The file {0} does not seem to be a valid xtrainer .csvx file because it doesn't say 'ver' in the first field.", sourcedStream.Source));
            }
            rows = parser.ReadFields();
            int dummy;
            if (rows.Length == 5 && int.TryParse(rows[0], out dummy))
            {
                var startDateTime = new DateTime(int.Parse(rows[0]), int.Parse(rows[1]), int.Parse(rows[2]),
                                                      int.Parse(rows[3]), int.Parse(rows[4]), 0);
                parser.ReadFields();
                return new XtrainerDataProvider(parser,startDateTime);
            }
            return new XtrainerDataProvider(parser);
        }
 public LeMondConcreateProviderCtorHelper(SourcedStream reader)
 {
     SourceName = reader.Source;
     Parser = new TextFieldParser(reader.Stream);
     Parser.TextFieldType = FieldType.Delimited;
     Parser.Delimiters = new[] { "," };
     FirstRow = Parser.ReadFields();
 }
Esempio n. 6
0
        public ITcxData Create(SourcedStream reader)
        {
            string extension = Path.GetExtension(reader.Source);
            if (extension.Equals(".csv", StringComparison.OrdinalIgnoreCase))
            {
                // LeMond
                return lemond(reader);
            }
            else if (extension.Equals(".3dp", StringComparison.OrdinalIgnoreCase))
            {
                // CompuTrainer .3DP
                return computrainer3DP(reader);
            }
            else if (reader.Source.EndsWith(".cdf.txt", StringComparison.OrdinalIgnoreCase))
            {
                return computrainerTXT(reader);
            }

            throw new Exception(string.Format("The extension '{0}' is not a supported file type", extension));
        }
Esempio n. 7
0
        public ITcxData Create(SourcedStream reader)
        {
            string extension = Path.GetExtension(reader.Source);

            if (extension.Equals(".csv", StringComparison.OrdinalIgnoreCase))
            {
                // LeMond
                return(lemond(reader));
            }
            else if (extension.Equals(".3dp", StringComparison.OrdinalIgnoreCase))
            {
                // CompuTrainer .3DP
                return(computrainer3DP(reader));
            }
            else if (reader.Source.EndsWith(".cdf.txt", StringComparison.OrdinalIgnoreCase))
            {
                return(computrainerTXT(reader));
            }

            throw new Exception(string.Format("The extension '{0}' is not a supported file type", extension));
        }
Esempio n. 8
0
        public ITcxData Create(SourcedStream reader)
        {
            string extension = Path.GetExtension(reader.Source);
            if (extension == null) throw new ArgumentNullException("extension");
            if (extension.Equals(".csv", StringComparison.OrdinalIgnoreCase))
            {
                // LeMond
                return _lemond(reader);
            }
            else if (extension.Equals(".3dp", StringComparison.OrdinalIgnoreCase))
            {
                // CompuTrainer
                return _computrainer(reader);
            }
            else if (extension.Equals(".csvx", StringComparison.OrdinalIgnoreCase))
            {
                // XTrainer
                return _xtrainer(reader);
            }

            throw new Exception(string.Format("The extension '{0}' is not a supported file type", extension));
        }
        public CompuTrainer3DPFileProvider(SourcedStream sourced)
        {
            this.input = new BinaryReader(sourced.Stream, Encoding.ASCII);

            ReadHeaderInfomation(sourced.Source);
        }
        CompuTrainerTXTFileProvider CreateProvider(string source)
        {
            SourcedStream stream = new SourcedStream()
            {
                Stream = Util.CreateStream(""),
                Source = source

            };
            return new CompuTrainerTXTFileProvider(stream);
        }
Esempio n. 11
0
        public CompuTrainer3DPFileProvider(SourcedStream sourced)
        {
            this.input = new BinaryReader(sourced.Stream, Encoding.ASCII);

            ReadHeaderInfomation(sourced.Source);
        }