コード例 #1
0
ファイル: Program copy.cs プロジェクト: paillave/Etl.Net
 private static void DefineProcess20(ISingleStream <Stream> contextStream)
 {
     // System.Text.Json.JsonSerializer
     // Newtonsoft.Json.JsonSerializer
     contextStream
     .Select("Create file value", i => FileValue.Create(i, i is FileStream fileStream ? fileStream.Name : "fileName.csv", "from stream"))
     .CrossApply <IFileValue, Person>("parse file", (fileValue, dependencyResolver, cancellationToken, push) =>
     {
         var parsedFile = Newtonsoft.Json.Linq.JObject.Parse(new StreamReader(fileValue.GetContent()).ReadToEnd());
         var jPeople    = parsedFile["people"] as JArray;
         foreach (var jPerson in jPeople)
         {
             if (cancellationToken.IsCancellationRequested)
             {
                 return;
             }
             push(new Person
             {
                 FirstName = (string)jPerson["TheFirstName"],
                 LastName  = (string)jPerson["TheLastName"],
                 Email     = (string)jPerson["TheEmail"],
             });
         }
     })
     .Do("write to console", i => Console.WriteLine(i.Email));
 }
コード例 #2
0
        protected IFileValue ProcessValueToOutput(IList <TIn> value)
        {
            MemoryStream stream      = new MemoryStream();
            var          excelReader = Args.Mapping.GetExcelReader();

            value.WriteExcelListInStream(excelReader, stream);
            return(FileValue.Create(stream, this.Args.FileName, new ExcelFileValueMetadata
            {
                Map = excelReader.GetTextMapping()
            }));
        }