Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 531

db4o-doc-7.4-2.fc13.i686.rpm

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>MemoryIoAdapter</title>
    <link rel="stylesheet" type="text/css" href="../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>MemoryIoAdapter</h1><script>
//We attach this function to a browser object as a variable so that if multiple of these blocks are
//present on the same page, then they will simply over-write eachother with the same function instead
//of generating a naming collision.
window.WikiCodeFormattingCopyToClipboard = function copyToClipboard(sID){
	var sContent = document.getElementById(sID).innerText;
	if( window.clipboardData && clipboardData.setData )
	{
		clipboardData.setData("Text", sContent);
	}
	else
	{
		alert("You must enable javascript access to your clipboard for this feature to work. Please referr to your browser documentation or Google search for instructions.");
	}
}
</script>

<p>One of the built-in db4o IoAdapters is MemoryIoAdapter. This adapter keeps the whole database&nbsp;in RAM instead of a hard-drive. Obviously such in-memory database has both advantages and disadvantages:</p>

<p>Pros:</p>

<ul>
<li>
it is a lot faster, as no disc access is necessary.</li>
</ul>

<p>
Cons:</p>

<ul>
<li>
it only works, if the database fits into RAM;</li>
</ul>

<ul>
<li>
all the data can be lost in case of a system failure.</li>
</ul>

<p>You can achieve the best results combining the usage of MemoryIoAdapter with the normal file adapter. Let's look, how MemoryIoAdapter should be used in your application.</p>

<p>First of all MemoryIoAdapter should be configured. The API gives you control over memory consumption with</p>



<span name="cs_wiki_filter" csw_filters="cs">

<p>c#:<code> MemoryIoAdapter#GrowBy(length) </code></p>
 
</span>

<span name="cs_wiki_filter" csw_filters="vb">

<p>VB:<code> MemoryIoAdapter#GrowBy(length) </code></p>
 
</span>

<p>method. Length defines the amount of bytes in memory that should be allocated, when no more free slots are found within the allocated file. Large value (100,000) will assure the best performance; small value (100) will keep the memory consumption at the lowest level. The default setting is 10,000.</p>

<p>MemoryIoAdaptor supplies methods to exchange data with the database from the filesystem.</p>



<span name="cs_wiki_filter" csw_filters="cs">

<p>c#: <code>MemoryIoAdapter#Put(filename, byte[]) </code></p>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<p>VB: <code>MemoryIoAdapter#Put(String, byte()) </code></p>

</span>

<p>This method allows you to put the contents of the stored database file (byte[]) into the memory database. </p>

<p>The opposite method:</p>



<span name="cs_wiki_filter" csw_filters="cs">

<p>c#: <code>  MemoryIoAdapter#Get(filename)</code></p>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<p>VB: <code>  MemoryIoAdapter#Get(filename) </code></p>

</span>

<p>returns the updated byte[] array of the database in memory, which can be saved to disc as a normal database file.</p>

<p>The filename can be used for all further access (#openFile, #openServer methods) like normal file name. Make sure that you close the database file on the disc after reading its contents into memory and writing it back.</p>

<p>The configured adapter should be assigned as db4o IO system:</p>



<span name="cs_wiki_filter" csw_filters="vb">

<p>VB:   <code>Db4o.Configure().Io(MemoryIoAdapter)</code> </p>

</span>
Let's create sample database on the disc:


<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IOExample.cs: <span class="fscMemberName">SetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> SetObjects()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_35_258_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      File.Delete(Db4oFileName);
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName);
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_139_215_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Pilot pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Rubens Barrichello</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Set(pilot);
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;"> 
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_SetObjects_2727_47_232_254_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IOExample.vb: <span class="fscMemberName">SetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub SetObjects()</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_SetObjects_2838_47_15_343_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> SetObjects()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            File.Delete(Db4oFileName)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(Db4oFileName)
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilot </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Rubens Barrichello</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Set(pilot)
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>Now we can read the database into the memory file and work in the memory using MemoryIoAdapter:</p>



<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IOExample.cs: <span class="fscMemberName">GetObjectsInMem</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> GetObjectsInMem()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_40_1429_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Setting up in-memory database</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      MemoryIoAdapter adapter </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MemoryIoAdapter();
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_167_429_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Sharpen.IO.RandomAccessFile raf </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Sharpen.IO.RandomAccessFile(Db4oFileName,</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">r</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">); 
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        adapter.GrowBy(</span><span style="color: #800080;">100</span><span style="color: #000000;">);
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        </span><span style="color: #0000FF;">int</span><span style="color: #000000;"> len </span><span style="color: #000000;">=</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">int</span><span style="color: #000000;">)raf.Length();
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        </span><span style="color: #0000FF;">byte</span><span style="color: #000000;">[] b </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> </span><span style="color: #0000FF;">byte</span><span style="color: #000000;">[len];
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        raf.Read(b,</span><span style="color: #800080;">0</span><span style="color: #000000;">,len);
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        adapter.Put(Db4oFileName, b);
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        raf.Close();
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;"> 
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">catch</span><span style="color: #000000;"> (Exception ex)
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_458_522_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Exception: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> ex.Message);
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IConfiguration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration();
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.Io(adapter);
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, Db4oFileName);
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_733_1006_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectSet result</span><span style="color: #000000;">=</span><span style="color: #000000;">db.Get(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Pilot));
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Read stored results through memory file</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">28</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        Pilot pilotNew </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Set(pilotNew);
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">New pilot added</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">31</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;"> 
</span><span style="color: #008080;">32</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">33</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1023_1045_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">34</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">35</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">36</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Writing the database back to disc</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">37</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">byte</span><span style="color: #000000;">[] dbstream </span><span style="color: #000000;">=</span><span style="color: #000000;"> adapter.Get(Db4oFileName);
</span><span style="color: #008080;">38</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">39</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1171_1325_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">40</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                Sharpen.IO.RandomAccessFile file </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Sharpen.IO.RandomAccessFile(Db4oFileName, </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">rw</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">41</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        file.Write(dbstream);
</span><span style="color: #008080;">42</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        file.Close();
</span><span style="color: #008080;">43</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;"> 
</span><span style="color: #008080;">44</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">catch</span><span style="color: #000000;"> (IOException ioex) 
</span><span style="color: #008080;">45</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjectsInMem_3059_52_1359_1425_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">46</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Exception: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> ioex.Message);
</span><span style="color: #008080;">47</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">48</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IOExample.vb: <span class="fscMemberName">GetObjectsInMem</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub GetObjectsInMem()</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjectsInMem_3175_52_15_1801_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> GetObjectsInMem()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Setting up in-memory database</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> adapter </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> MemoryIoAdapter </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> MemoryIoAdapter()
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> raf </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Sharpen.IO.RandomAccessFile </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Sharpen.IO.RandomAccessFile(Db4oFileName, </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">r</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                adapter.GrowBy(</span><span style="color: #800080;">100</span><span style="color: #000000;">)
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> </span><span style="color: #0000FF;">len</span><span style="color: #000000;"> </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(raf.Length(), </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;">)
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> b() </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Byte</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Byte</span><span style="color: #000000;">(</span><span style="color: #0000FF;">len</span><span style="color: #000000;">) {}
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                raf.Read(b, </span><span style="color: #800080;">0</span><span style="color: #000000;">, </span><span style="color: #0000FF;">len</span><span style="color: #000000;">)
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                adapter.Put(Db4oFileName, b)
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                raf.Close()
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Catch</span><span style="color: #000000;"> ex </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Exception
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Exception: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> ex.Message)
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration()
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.Io(adapter)
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, Db4oFileName)
</span><span style="color: #008080;">20</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot))
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Read stored results through memory file</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">23</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> pilotNew </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Pilot </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Pilot(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Michael Schumacher</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Set(pilotNew)
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">New pilot added</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">27</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">28</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Writing the database back to disc</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">31</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> dbstream() </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Byte</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> adapter.Get(Db4oFileName)
</span><span style="color: #008080;">32</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">33</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> file </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Sharpen.IO.RandomAccessFile </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Sharpen.IO.RandomAccessFile(Db4oFileName, </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">rw</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">34</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                file.Write(dbstream)
</span><span style="color: #008080;">35</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                file.Close()
</span><span style="color: #008080;">36</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Catch</span><span style="color: #000000;"> ioex </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IOException
</span><span style="color: #008080;">37</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Exception: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> ioex.Message)
</span><span style="color: #008080;">38</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">39</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>Well, the changes are made and written to the disc. Let's check, if all the data are in place.&nbsp;We will need to switch back to the normal RandomAccessFileAdapter:</p>



<span name="cs_wiki_filter" csw_filters="cs">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IOExample.cs: <span class="fscMemberName">GetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> GetObjects()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_35_458_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IConfiguration configuration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration();
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.Io(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> RandomAccessFileAdapter());
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, Db4oFileName);
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> 
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_269_415_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        IObjectSet result</span><span style="color: #000000;">=</span><span style="color: #000000;">db.Get(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Pilot));
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Read stored results through disc file</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        ListResult(result);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;"> 
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> 
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosCS.ZipsIOExample.Cs_IOExample.Cs_GetObjects_3472_47_432_454_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        db.Close();
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>      }</span></span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>    }</span></span></div></pre></div></div>

</span>

<span name="cs_wiki_filter" csw_filters="vb">

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IOExample.vb: <span class="fscMemberName">GetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47"><div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><span style="color: #008080;">01</span><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub GetObjects()</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapteriosVB.ZipsIOExample.Vb_IOExample.Vb_GetObjects_3583_47_15_545_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> GetObjects()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.NewConfiguration()
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.Io(</span><span style="color: #0000FF;">New</span><span style="color: #000000;"> RandomAccessFileAdapter())
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> db </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, Db4oFileName)
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> db.Get(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Pilot))
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                System.Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Read stored results through disc file</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span>

<p>So, switching between disc and memory database is quite easy. It can be used to&nbsp;increase performance on certain operations. More flexibility can be reached writing&nbsp;your own IoAdapter implementation.</p></div>
    </div>
    <div id="footer">
					This revision (12) was last Modified 2006-11-13T14:51:09 by Tetyana.
				</div>
  </body>
</html>