Example #1
0
        internal static void WriteToFile(WriteToStream callback, string path, bool append = false)
        {
            using (var writer = new StreamWriter(path, append))
            {
#if DEBUG
                writer.AutoFlush = true; // To look at intermediate output at certain breakpoints
#endif
                callback(writer);
            }
        }
        static WriteToStream <T> GetStreamDelegate <T>()
        {
            WriteToStream <T> lw = null;

            lock (_StreamCached)
            {
                Delegate untyped;
                if (_StreamCached.TryGetValue(typeof(T), out untyped))
                {
                    lw = (WriteToStream <T>)untyped;
                }
            }

            return(lw ?? CacheStreamDelegate <T>());
        }
Example #3
0
        private async Task <IEnumerable <object> > IndexAndQueryBestMatch(Envelope <MessageContext, DemographicsDocument> envelope)
        {
            var database    = _redisConnection.GetDatabase();
            var transaction = database.CreateTransaction();

            var document = envelope.Body;

            var essenceId = await MatchingHandlers.GetOrCreateEssence(document, transaction);

            var matchedEvent = new DemographicsMatched(document.DocumentId, essenceId);
            var eventId      = EventId.Create(envelope.Header.EventId);
            var writeEvent   = new WriteToStream(eventId, "matched", matchedEvent);

            return(new[] { writeEvent });
        }
Example #4
0
        internal static void WriteToConsole(WriteToStream callback)
        {
            // Point the stream to standard output
            var writer = new StreamWriter(Console.OpenStandardOutput());

            writer.AutoFlush = true;
            Console.SetOut(writer);

            // Call the abstract method
            callback(writer);

            // Recover the standard output stream
            var standardOutput = new StreamWriter(Console.OpenStandardOutput());

            standardOutput.AutoFlush = true;
            Console.SetOut(standardOutput);
        }