Sophie

Sophie

distrib > Fedora > 14 > i386 > by-pkgid > 864d1c3c3cd8df4e3a2692faf8776e05 > files > 513

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

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>CachedIoAdapter Example</title>
    <link rel="stylesheet" type="text/css" href="../../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>CachedIoAdapter Example</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>Let's look on an example at the benefits of CachedIoAdapter.</p>

<p>We will use the following methods to initiate write and read
from a database file:</p>


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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">CachedIOExample.cs: <span class="fscMemberName">SetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58"><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(IConfiguration configuration)
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_69_885_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(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 id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_223_801_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"/>                DateTime dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Open_Text').style.display='inline';"/>          </span><span style="color: #0000FF;">for</span><span style="color: #000000;"> (</span><span style="color: #0000FF;">int</span><span style="color: #000000;"> i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">0</span><span style="color: #000000;">; i</span><span style="color: #000000;">&lt;</span><span style="color: #000000;"> </span><span style="color: #800080;">50000</span><span style="color: #000000;">; i</span><span style="color: #000000;">++</span><span style="color: #000000;">)</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_310_389_Open_Text"><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"/>            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;">Pilot #</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">+</span><span style="color: #000000;">i);
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            db.Set(pilot);
</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"/>          DateTime dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          TimeSpan  diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</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;">Time elapsed for setting objects =</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Commit(); ;
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">18</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</span><span style="color: #008080;">19</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;">Time elapsed for commit =</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</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"/>
</span><span style="color: #008080;">21</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;">22</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;">23</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_SetObjects_216_58_834_877_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">24</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close();
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>            }</span></span><span style="color: #000000;">       }</span></span></div></pre></div></div>

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">CachedIOExample.cs: <span class="fscMemberName">GetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58"><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(IConfiguration configuration)
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_69_660_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"/>            IObjectContainer db </span><span style="color: #000000;">=</span><span style="color: #000000;"> Db4oFactory.OpenFile(configuration, 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 id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_184_574_Open_Text"><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"/>                DateTime dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">07</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;">null</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"/>                DateTime dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow;
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                TimeSpan diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1;
</span><span style="color: #008080;">10</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;">Time elapsed for the query =</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</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"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Objects in the database: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> result.Count);
</span><span style="color: #008080;">12</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;">13</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;">14</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Open_Text').style.display='inline';"/>            </span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_GetObjects_278_58_607_650_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close();
</span><span style="color: #008080;">16</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;">17</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">CachedIOExample.vb: <span class="fscMemberName">SetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_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_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub SetObjects()</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_SetObjects_396_58_15_1120_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> SetObjects(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration)
</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(configuration, 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;"> dt1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</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;"> i </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: #800080;">0</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: #0000FF;">While</span><span style="color: #000000;"> i </span><span style="color: #000000;">&lt;</span><span style="color: #000000;"> </span><span style="color: #800080;">50000</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"/>                    </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;">Pilot #</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> i.ToString())
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    db.Set(pilot)
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    System.Math.Min(System.Threading.Interlocked.Increment(i), i </span><span style="color: #000000;">-</span><span style="color: #000000;"> </span><span style="color: #800080;">1</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"/>                </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">While</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;">Dim</span><span style="color: #000000;"> dt2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</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;">Dim</span><span style="color: #000000;"> diff </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TimeSpan </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</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;">Time elapsed for setting objects =</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                dt1 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Commit()
</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: #008080;">18</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                dt2 </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</span><span style="color: #008080;">19</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                diff </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</span><span style="color: #008080;">20</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;">Time elapsed for commit =</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</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;">Finally</span><span style="color: #000000;">
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">24</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>
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">CachedIOExample.vb: <span class="fscMemberName">GetObjects</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_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_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub GetObjects()</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_GetObjects_456_58_15_680_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> GetObjects(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> configuration </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration)
</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;"> 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;">03</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;">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;"> dt1 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</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;"> 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;">Nothing</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;"> dt2 </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> DateTime </span><span style="color: #000000;">=</span><span style="color: #000000;"> DateTime.UtcNow
</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;">Dim</span><span style="color: #000000;"> diff </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> TimeSpan </span><span style="color: #000000;">=</span><span style="color: #000000;"> dt2 </span><span style="color: #000000;">-</span><span style="color: #000000;"> dt1
</span><span style="color: #008080;">08</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;">Time elapsed for the query =</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> diff.TotalMilliseconds.ToString() </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;"> ms</span><span style="color: #800000;">&quot;</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"/>                Console.WriteLine(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Objects in the database: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> result.Count.ToString())
</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 src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                db.Close()
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">13</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>Try to execute the code with the default settings and write
down the results. Then configure CachedIoAdapter using the code below and test
the performance again:</p>


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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">CachedIOExample.cs: <span class="fscMemberName">ConfigureCache</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62"><div><!--

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

--><span style="color: #008080;">1</span><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Open_Text').style.display='inline';"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> IConfiguration ConfigureCache()</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdaptercachedIoCS.ZipsCachedIOExample.Cs_CachedIOExample.Cs_ConfigureCache_752_62_46_423_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">2</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 cached io adapter</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">);
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">//</span><span style="color: #008000;"> new cached IO adapter with 256 pages 1024 bytes each</span><span style="color: #008000;">
</span><span style="color: #008080;">4</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">        CachedIoAdapter adapter </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> CachedIoAdapter(</span><span style="color: #0000FF;">new</span><span style="color: #000000;"> RandomAccessFileAdapter(), </span><span style="color: #800080;">1024</span><span style="color: #000000;">, </span><span style="color: #800080;">256</span><span style="color: #000000;">);
</span><span style="color: #008080;">5</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;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        configuration.Io(adapter);
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">return</span><span style="color: #000000;"> configuration;
</span><span style="color: #008080;">8</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">CachedIOExample.vb: <span class="fscMemberName">ConfigureCache</span></span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62"><div><!--

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

--><span style="color: #008080;">1</span><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_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_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function ConfigureCache()</span><span id="ResourcesReferenceImplementation_StrategiesIO_AdapterCachedIoAdapterCachedIoVB.ZipsCachedIOExample.Vb_CachedIOExample.Vb_ConfigureCache_874_62_15_472_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> ConfigureCache() </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IConfiguration
</span><span style="color: #008080;">2</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 cached io adapter</span><span style="color: #800000;">&quot;</span><span style="color: #000000;">)
</span><span style="color: #008080;">3</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;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #008000;">'</span><span style="color: #008000;"> new cached IO adapter with 256 pages 1024 bytes each</span><span style="color: #008000;">
</span><span style="color: #008080;">5</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> adapter </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> CachedIoAdapter </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> CachedIoAdapter(</span><span style="color: #0000FF;">New</span><span style="color: #000000;"> RandomAccessFileAdapter, </span><span style="color: #800080;">1024</span><span style="color: #000000;">, </span><span style="color: #800080;">256</span><span style="color: #000000;">)
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            configuration.Io(adapter)
</span><span style="color: #008080;">7</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Return</span><span style="color: #000000;"> configuration
</span><span style="color: #008080;">8</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Function</span></span></div></pre></div></div>

</span>

<p>The performance delta will be more significant for more
objects and bigger cache memory.</p></div>
    </div>
    <div id="footer">
					This revision (8) was last Modified 2007-02-01T20:46:04 by Tetyana.
				</div>
  </body>
</html>