/// <summary>
		/// Copy the content of one appender to another. The bytestreams will be identical.
		/// Use AddEvents(appender, events) to compress the bytestreams.
		/// </summary>
		/// <param name="source"></param>
		/// <param name="to"></param>
		/// <param name="version"></param>
        public static void CopyAppender(this IAppendOnlyStore source, IAppendOnlyStore to, int version)
        {
            var serializer = new BinaryFormatterSerializer();

            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (to == null)
            {
                throw new ArgumentNullException("to");
            }

            var versions = new Dictionary<string, int>();

            foreach (var record in source.ReadRecords(0, version))
            {
                if (!versions.ContainsKey(record.Name))
                {
                    versions[record.Name] = 0;
                }

                var events = serializer.DeserializeEvent(record.Data);
                to.Append(record.Name, record.Data, versions[record.Name]);
                versions[record.Name]++;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Copy the content of one appender to another. The bytestreams will be identical.
        /// Use AddEvents(appender, events) to compress the bytestreams.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="to"></param>
        /// <param name="version"></param>
        public static void CopyAppender(this IAppendOnlyStore source, IAppendOnlyStore to, int version)
        {
            var serializer = new BinaryFormatterSerializer();

            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            if (to == null)
            {
                throw new ArgumentNullException("to");
            }

            var versions = new Dictionary <string, int>();

            foreach (var record in source.ReadRecords(0, version))
            {
                if (!versions.ContainsKey(record.Name))
                {
                    versions[record.Name] = 0;
                }

                var events = serializer.DeserializeEvent(record.Data);
                to.Append(record.Name, record.Data, versions[record.Name]);
                versions[record.Name]++;
            }
        }