public static void Write(Stream stream, Dictionary <string, List <Place> > entries) { var barEntries = new List <Bar.Entry> { new Bar.Entry { Name = "tmp", Stream = new MemoryStream() } }; foreach (var placeGroup in entries) { var memoryStream = new MemoryStream(); Write(memoryStream, placeGroup.Value); barEntries.Add(new Bar.Entry { Name = placeGroup.Key, Stream = memoryStream, Type = Bar.EntryType.List }); } ; Bar.Write(stream, barEntries); foreach (var barEntry in barEntries) { barEntry.Stream.Dispose(); } }
public Stream toStream() { Stream stream = new MemoryStream(); Bar.Entry MotionEntry = new Bar.Entry(); MotionEntry.Type = Bar.EntryType.Motion; MotionEntry.Index = MotionIndex; MotionEntry.Name = MotionName; MotionEntry.Stream = MotionFile.toStream(); Bar.Entry TriggerEntry = new Bar.Entry(); TriggerEntry.Type = Bar.EntryType.MotionTriggers; TriggerEntry.Index = TriggerIndex; TriggerEntry.Name = TriggerName; TriggerEntry.Stream = (MotionTriggerFile != null) ? MotionTriggerFile.toStream() : new MemoryStream(); Bar.Write(stream, new List <Bar.Entry> { MotionEntry, TriggerEntry }); stream.Position = 0; return(stream); }