Beispiel #1
0
        public Record CloneViaReserialise()
        {
            // Do it via a re-serialization
            // It's a cheat, but it works...
            byte[] b = Serialize();
            using (MemoryStream ms = new MemoryStream(b))
            {
                RecordInputStream rinp = new RecordInputStream(ms);
                rinp.NextRecord();

                Record[] r = RecordFactory.CreateRecord(rinp);
                if (r.Length != 1)
                {
                    throw new InvalidOperationException("Re-serialised a record to clone it, but got " + r.Length + " records back!");
                }
                return(r[0]);
            }
        }