1 /*-
2  * Copyright (c) 2009, 2020 Oracle and/or its affiliates.  All rights reserved.
3  *
4  * See the file EXAMPLES-LICENSE for license information.
5  *
6  */
7 using System;
8 using System.Collections.Generic;
9 using System.Collections;
10 using System.Diagnostics;
11 using System.IO;
12 using System.Runtime.Serialization.Formatters.Binary;
13 using System.Text;
14 using BerkeleyDB;
15 
16 namespace excs_getting_started {
17     [Serializable]
18     public class Vendor {
19         public string City;             /* City */
20         public string PhoneNumber;      /* Vendor phone number */
21         public string Name;             /* Vendor name */
22         public string SalesRep;         /* Name of sales rep */
23         public string SalesRepPhone;    /* Sales rep's phone number */
24         public string State;            /* Two-digit US state code */
25         public string Street;           /* Street name and number */
26         public string Zipcode;          /* US zipcode */
27 
28         /*
29          * Marshall class data members into a single
30          * contiguous memory location for the purpose of
31          * storing the data in a database.
32          */
GetBytes()33         public byte[] GetBytes () {
34             MemoryStream memStream = new MemoryStream();
35             BinaryFormatter formatter = new BinaryFormatter();
36             formatter.Serialize(memStream, this);
37             byte [] bytes = memStream.GetBuffer();
38             memStream.Close();
39             return bytes;
40         }
41     }
42 }
43