31            Console.WriteLine(
"Adapter Exercise");
 
   37                    uint memoryBlockSize = dataReaderWriter.MemoryBlockByteSize;
 
   38                    byte[] readData = dataReaderWriter.Read(0, memoryBlockSize);
 
   39                    string dataDump = dataReaderWriter.BufferToString(readData, memoryBlockSize, 2);
 
   40                    Console.WriteLine(
"  Initial memory block contents:{0}{1}", Environment.NewLine, dataDump);
 
   45                    byte[] writeData = 
new byte[dataSize];
 
   46                    for (
int index = 0; index < dataSize; ++index)
 
   48                        writeData[index] = (byte)(index + 1);
 
   52                    dataDump = dataReaderWriter.BufferToString(writeData, dataSize, 2);
 
   53                    Console.WriteLine(
"  Data to be written to memory block:{0}{1}", Environment.NewLine, dataDump);
 
   55                    Console.WriteLine(
"  Writing data to byte offset {0}...", byteOffset);
 
   57                    dataReaderWriter.Write(byteOffset, writeData, dataSize);
 
   59                    Console.WriteLine(
"  Reading back the memory block...");
 
   61                    readData = dataReaderWriter.Read(0, memoryBlockSize);
 
   65                    dataDump = dataReaderWriter.BufferToString(readData, memoryBlockSize, 2);
 
   66                    Console.WriteLine(
"  Current memory block contents:{0}{1}", Environment.NewLine, dataDump);
 
   72                Console.WriteLine(
"Error with startup or shutdown! {0}", e.Message);
 
   76                Console.WriteLine(
"Error with reading or writing! {0}", e.Message);
 
   78            Console.WriteLine(
"  Done.");
 
Example of using the Adapter Pattern in C#.
void Run()
Executes the example for the Adapter Pattern in C#.
Represents an error that occurred when reading or writing data in the Data reader/writer.
Represents a data reader/writer to a caller.
MemoryBlockNumber
Represents the memory blocks that can be accessed. Hides how memory blocks are actually identified.
Represents an error that occurred during initialization or shut down of the Data reader/writer.
The namespace containing all Design Pattern Examples implemented in C#.