Example #1
0
            public string Run <TInd, TVal>(IGenericInvoker2 source, object arg)
                where TInd : IComparable <TInd>
            {
                var f = (IEnumerableFeed <TInd, TVal>)source;

                var sb = new StringBuilder();

                foreach (TVal v in f.Stream())
                {
                    sb.Append(v);
                    sb.Append("\n");
                }
                return(sb.Length == 0 ? "(empty)" : sb.ToString());
            }
            /// <summary>
            ///   This method will be called with TInd and TVal properly set to what they are in a file
            /// </summary>
            public long Run <TInd, TVal>(IGenericInvoker2 source, string destinationFile)
                where TInd : IComparable <TInd>
            {
                // The source is the binary file object on which RunGenericMethod() was called
                var src = (IEnumerableFeed <TInd, TVal>)source;

                // Create BinSeriesFile as it is easier to set up than a compressed one
                using (var dst = new BinSeriesFile <TInd, TVal>(destinationFile))
                {
                    // Initialize new file
                    dst.InitializeNewFile();

                    // Copy the entire content of the source file into the destination file
                    dst.AppendData(src.StreamSegments());

                    // Dump content of the new file to the console
                    Console.WriteLine("Destination file\n{0}", Utils.DumpFeed(dst));

                    // Return item count (not supported for compressed files)
                    return(dst.Count);
                }
            }
Example #3
0
 public static string DumpFeed(IGenericInvoker2 f)
 {
     return(f.RunGenericMethod(new DumpHelper(), null));
 }