Esempio n. 1
0
        private DataAcquirerPost ParsePostFromReader(CsvReader csvreader)
        {
            var builder = new PostBuilder(_attributes.DateTimeFormatString)
                          .AddSource()
                          .PopulateFixed(_attributes.FixedValues);

            foreach (var(k, index) in _attributes.Indices)
            {
                if (csvreader.TryGetField <string>(index, out var value))
                {
                    builder.PopulateField(k, value);
                }
            }

            return(builder.Build());
        }
Esempio n. 2
0
        private DataAcquirerPost ParsePostFromLine(string line)
        {
            var settings = new JsonSerializerSettings()
            {
                DateParseHandling = DateParseHandling.None
            };
            var readPost = JsonConvert.DeserializeObject <JObject>(line, settings);

            var builder = new PostBuilder(_attributes.DateTimeFormatString)
                          .AddSource()
                          .PopulateFixed(_attributes.FixedValues);

            foreach (var(k, element) in _attributes.Elements)
            {
                if (readPost.TryGetValue(element, out var valueToken))
                {
                    var value = valueToken.Value <string>();
                    builder.PopulateField(k, value);
                }
            }

            return(builder.Build());
        }