private IBatch MapBatchAndLogs(Batch batch, Queue<ILog> logs)
        {
            if (Configuration.MappingRules == null)
            {
                int logCount = 0;
                var batchLogs = new List<ILog>();
                while (logs.Any())
                {
                    batchLogs.Add(logs.Dequeue());
                    logCount++;
                    if (Configuration.MaxBatchLength.HasValue && logCount > Configuration.MaxBatchLength.Value) break;
                }
                if (logCount > 0)
                {
                    batch.Logs = batchLogs;
                    return batch;
                }
            }
            else
            {
                IDictionary<string, object> data = Configuration.MappingRules.Map(batch).FirstOrDefault();
                if (data != null)
                {
                    int logCount = 0;
                    var mappedLogs = new List<ILog>();
                    while (logs.Any())
                    {
                        var log = logs.Dequeue();
                        var mappedLogsData = Configuration.MappingRules.Map(log).ToList();
                        if (mappedLogsData.Any())
                        {
                            foreach (var logData in mappedLogsData)
                            {
                                var mappedLog = new MappedLog(log, logData);
                                if (ServerTimeOffset.HasValue)
                                {
                                    mappedLog.TimeStamp = mappedLog.TimeStamp.Add(ServerTimeOffset.Value);
                                }
                                mappedLogs.Add(mappedLog);
                            }
                            logCount++;
                            if (Configuration.MaxBatchLength.HasValue && logCount > Configuration.MaxBatchLength.Value) break;
                        }
                    }

                    if (logCount > 0)
                    {
                        var result = new MappedBatch(batch, data, mappedLogs);
                        if (ServerTimeOffset.HasValue)
                        {
                            result.TimeStamp = result.TimeStamp.Add(ServerTimeOffset.Value);
                        }
                        return result;
                    }
                }
            }
            return null;
        }
        private IBatch MapBatchAndLogs(Batch batch, Queue <ILog> logs)
        {
            if (Configuration.MappingRules == null)
            {
                int logCount  = 0;
                var batchLogs = new List <ILog>();
                while (logs.Any())
                {
                    batchLogs.Add(logs.Dequeue());
                    logCount++;
                    if (Configuration.MaxBatchLength.HasValue && logCount > Configuration.MaxBatchLength.Value)
                    {
                        break;
                    }
                }
                if (logCount > 0)
                {
                    batch.Logs = batchLogs;
                    return(batch);
                }
            }
            else
            {
                IDictionary <string, object> data = Configuration.MappingRules.Map(batch).FirstOrDefault();
                if (data != null)
                {
                    int logCount   = 0;
                    var mappedLogs = new List <ILog>();
                    while (logs.Any())
                    {
                        var log            = logs.Dequeue();
                        var mappedLogsData = Configuration.MappingRules.Map(log).ToList();
                        if (mappedLogsData.Any())
                        {
                            foreach (var logData in mappedLogsData)
                            {
                                var mappedLog = new MappedLog(log, logData);
                                if (ServerTimeOffset.HasValue)
                                {
                                    mappedLog.TimeStamp = mappedLog.TimeStamp.Add(ServerTimeOffset.Value);
                                }
                                mappedLogs.Add(mappedLog);
                            }
                            logCount++;
                            if (Configuration.MaxBatchLength.HasValue && logCount > Configuration.MaxBatchLength.Value)
                            {
                                break;
                            }
                        }
                    }

                    if (logCount > 0)
                    {
                        var result = new MappedBatch(batch, data, mappedLogs);
                        if (ServerTimeOffset.HasValue)
                        {
                            result.TimeStamp = result.TimeStamp.Add(ServerTimeOffset.Value);
                        }
                        return(result);
                    }
                }
            }
            return(null);
        }