Exemplo n.º 1
0
        public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
        {
            FluentFile engine = FluentFile.For <UserFullRecord>();

            engine.HeaderText = "Id\tName\tAddress";
            using (FileEngine file = engine.To(filePath))
            {
                foreach (Row row in rows)
                {
                    file.Write(row.ToObject <UserFullRecord>());

                    //pass through rows if needed for another later operation
                    yield return(row);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes this operation
        /// </summary>
        /// <param name="rows">The rows.</param>
        /// <returns></returns>
        public override IEnumerable <Row> Execute(IEnumerable <Row> rows)
        {
            FluentFile engine = FluentFile.For <UserRecord>();

            engine.HeaderText = "Id\tName\tEmail";
            using (FileEngine file = engine.To("users.txt"))
            {
                foreach (Row row in rows)
                {
                    UserRecord record = new UserRecord();

                    record.Id    = (int)row["id"];
                    record.Name  = (string)row["name"];
                    record.Email = (string)row["email"];

                    file.Write(record);
                }
            }
            yield break;
        }
Exemplo n.º 3
0
        protected override async Task ExecuteYield(IAsyncEnumerable <Row> rows, AsyncEnumerator <Row> .Yield yield,
                                                   CancellationToken cancellationToken = default)
        {
            FluentFile engine = FluentFile.For <UserRecord>();

            engine.HeaderText = "Id\tName\tEmail";
            using (FileEngine file = engine.To("users.txt"))
            {
                await rows.ForEachAsync(row =>
                {
                    UserRecord record = new UserRecord();

                    record.Id    = (int)row["id"];
                    record.Name  = (string)row["name"];
                    record.Email = (string)row["email"];

                    file.Write(record);
                }, cancellationToken);
            }
            @yield.Break();
        }