Sophie

Sophie

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

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

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Ensuring Singletons</title>
    <link rel="stylesheet" type="text/css" href="../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Ensuring Singletons</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>

<span name="cs_wiki_filter" csw_filters="cs">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">Singleton.cs</span></div><div class="fscCode"><pre ID="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Open_Text').style.display='inline';"/><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_0_67_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;"> Copyright (C) 2004 - 2007 db4objects Inc. </span><span style="color: #008000; text-decoration: underline;">http://www.db4o.com</span><span style="color: #008000;"> </span><span style="color: #008000;">*/</span></span><span style="color: #000000;">
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">using</span><span style="color: #000000;"> System;
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">using</span><span style="color: #000000;"> Db4objects.Db4o;
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">using</span><span style="color: #000000;"> Db4objects.Db4o.Query;
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">using</span><span style="color: #000000;"> Sharpen.Lang;
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/>
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Semaphores
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Open_Text').style.display='inline';"/></span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_195_1986_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Open_Text').style.display='inline';"/>  </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_198_419_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;">*
</span><span style="color: #008080;">10</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>   * This class  demonstrates the use  of a  semaphore to ensure that only
</span><span style="color: #008080;">11</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>   * one instance of a  certain  class is stored to an IObjectContainer.
</span><span style="color: #008080;">12</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>   * 
</span><span style="color: #008080;">13</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>   * Caution  !!! The getSingleton method contains a commit()  call.  
</span><span style="color: #008080;">14</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>   </span><span style="color: #008000;">*/</span></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"/>  </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;">  Singleton 
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Open_Text').style.display='inline';"/>  </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_446_1983_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_450_596_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;">*
</span><span style="color: #008080;">18</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>     * returns  a singleton object of one  class for an  IObjectContainer.
</span><span style="color: #008080;">19</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>     * &lt;br&gt;&lt;b&gt;Caution !!!  This  method contains a commit() call.&lt;/b&gt; 
</span><span style="color: #008080;">20</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>     </span><span style="color: #008000;">*/</span></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;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;">  Object GetSingleton(IObjectContainer objectContainer, Type  clazz) 
</span><span style="color: #008080;">22</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_682_1558_Open_Text"><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"/>      Object obj </span><span style="color: #000000;">=</span><span style="color: #000000;">  queryForSingletonClass(objectContainer, clazz);
</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;">if</span><span style="color: #000000;"> (obj </span><span style="color: #000000;">!=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">) 
</span><span style="color: #008080;">25</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_772_794_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">26</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;"> obj;
</span><span style="color: #008080;">27</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;">28</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      String semaphore </span><span style="color: #000000;">=</span><span style="color: #000000;">  </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Singleton#getSingleton_</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> clazz.FullName;
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</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;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #000000;">objectContainer.Ext().SetSemaphore(semaphore,  </span><span style="color: #800080;">10000</span><span style="color: #000000;">)) 
</span><span style="color: #008080;">32</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_929_994_Open_Text"><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;">throw</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Exception(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Blocked semaphore </span><span style="color: #800000;">&quot;</span><span style="color: #000000;">  </span><span style="color: #000000;">+</span><span style="color: #000000;"> semaphore);
</span><span style="color: #008080;">34</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;">35</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">36</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      obj </span><span style="color: #000000;">=</span><span style="color: #000000;">  queryForSingletonClass(objectContainer, clazz);
</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: #008080;">38</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (obj </span><span style="color: #000000;">==</span><span style="color: #000000;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">) 
</span><span style="color: #008080;">39</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1078_1483_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"/>
</span><span style="color: #008080;">41</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;">42</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1094_1160_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">43</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    obj </span><span style="color: #000000;">=</span><span style="color: #000000;"> Activator.CreateInstance(clazz);
</span><span style="color: #008080;">44</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;">45</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 e) 
</span><span style="color: #008080;">46</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1191_1240_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">47</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          System.Console.WriteLine(e.Message);
</span><span style="color: #008080;">48</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;">49</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">50</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        objectContainer.Set(obj);
</span><span style="color: #008080;">51</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">52</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Open_Text').style.display='inline';"/>        </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1278_1447_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;"> !!! CAUTION !!!
</span><span style="color: #008080;">53</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>         * There is a  commit  call here.
</span><span style="color: #008080;">54</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>         * 
</span><span style="color: #008080;">55</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>         * The commit call  is  necessary, so  other transactions
</span><span style="color: #008080;">56</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>         * can see the new inserted object.
</span><span style="color: #008080;">57</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>         </span><span style="color: #008000;">*/</span></span><span style="color: #000000;">
</span><span style="color: #008080;">58</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        objectContainer.Commit();
</span><span style="color: #008080;">59</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">60</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;">61</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">62</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      objectContainer.Ext().ReleaseSemaphore(semaphore);
</span><span style="color: #008080;">63</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">64</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;"> obj;
</span><span style="color: #008080;">65</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;">66</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">67</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>    </span><span style="color: #0000FF;">private</span><span style="color: #000000;">  </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> Object queryForSingletonClass(IObjectContainer objectContainer, Type  clazz) 
</span><span style="color: #008080;">68</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Open_Text').style.display='inline';"/>    </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1656_1979_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">69</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IQuery q </span><span style="color: #000000;">=</span><span style="color: #000000;"> objectContainer.Query();
</span><span style="color: #008080;">70</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      q.Constrain(clazz);
</span><span style="color: #008080;">71</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      IObjectSet  objectSet  </span><span style="color: #000000;">=</span><span style="color: #000000;"> q.Execute();
</span><span style="color: #008080;">72</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (objectSet.Size() </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;">73</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1793_1828_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">74</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;"> objectSet.Next();
</span><span style="color: #008080;">75</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;">76</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>      </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (objectSet.Size() </span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;">) 
</span><span style="color: #008080;">77</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Open_Text').style.display='inline';"/>      </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresCS.ZipsSingleton.Cs_Singleton.Cs_51_43_1862_1959_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">78</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        </span><span style="color: #0000FF;">throw</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> Exception(
</span><span style="color: #008080;">79</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Singleton problem. Multiple  instances of: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;">  </span><span style="color: #000000;">+</span><span style="color: #000000;"> clazz.Name );
</span><span style="color: #008080;">80</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;">81</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;"> </span><span style="color: #0000FF;">null</span><span style="color: #000000;">;
</span><span style="color: #008080;">82</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;">83</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">84</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;">85</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">86</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">Singleton.vb</span></div><div class="fscCode"><pre ID="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43"><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: #008000;">'</span><span style="color: #008000;"> Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com </span><span style="color: #008000;">
</span><span style="color: #008080;">02</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">Imports</span><span style="color: #000000;"> System
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">Imports</span><span style="color: #000000;"> Db4objects.Db4o
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/></span><span style="color: #0000FF;">Imports</span><span style="color: #000000;"> Db4objects.Db4o.Query
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/>
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Open_Text').style.display='inline';"/></span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Namespace Db4objects</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_135_2525_Open_Text"><span style="color: #0000FF;">Namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Semaphores
</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: #008000;">'</span><span style="color: #008000;"> This class  demonstrates the use  of a  semaphore to ensure that only</span><span style="color: #008000;">
</span><span style="color: #008080;">08</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">    </span><span style="color: #008000;">'</span><span style="color: #008000;"> one instance of a  certain  class is stored to an IObjectContainer.</span><span style="color: #008000;">
</span><span style="color: #008080;">09</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">    </span><span style="color: #008000;">'</span><span style="color: #008000;"> </span><span style="color: #008000;">
</span><span style="color: #008080;">10</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">    </span><span style="color: #008000;">'</span><span style="color: #008000;"> Caution  !!! The getSingleton method contains a commit()  call.  </span><span style="color: #008000;">
</span><span style="color: #008080;">11</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">
</span><span style="color: #008080;">12</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Open_Text').style.display='inline';"/>    </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Class Singleton</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_408_2510_Open_Text"><span style="color: #0000FF;">Class</span><span style="color: #000000;"> Singleton
</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: #008080;">14</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;"> returns  a singleton object of one  class for an  IObjectContainer.</span><span style="color: #008000;">
</span><span style="color: #008080;">15</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">        </span><span style="color: #008000;">'</span><span style="color: #008000;"> Caution !!!  This  method contains a commit() call.</span><span style="color: #008000;">
</span><span style="color: #008080;">16</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">
</span><span style="color: #008080;">17</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Open_Text').style.display='inline';"/>        </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function GetSingleton()</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_583_1912_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> GetSingleton(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> objectContainer </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer, </span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> clazz </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> System.Type) </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Object</span><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"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> obj </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Object</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> queryForSingletonClass(objectContainer, clazz)
</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;">If</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Not</span><span style="color: #000000;"> obj </span><span style="color: #0000FF;">Is</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Nothing</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Then</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: #0000FF;">Return</span><span style="color: #000000;"> obj
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">If</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: #008080;">23</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;"> semaphore </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">String</span><span style="color: #000000;"> </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Singleton#getSingleton_</span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> clazz.FullName
</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: #008080;">25</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Not</span><span style="color: #000000;"> objectContainer.Ext().SetSemaphore(semaphore, </span><span style="color: #800080;">10000</span><span style="color: #000000;">) </span><span style="color: #0000FF;">Then</span><span style="color: #000000;">
</span><span style="color: #008080;">26</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Throw</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Exception(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Blocked semaphore </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> semaphore)
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">If</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"/>
</span><span style="color: #008080;">29</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            obj </span><span style="color: #000000;">=</span><span style="color: #000000;"> queryForSingletonClass(objectContainer, clazz)
</span><span style="color: #008080;">30</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</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;">If</span><span style="color: #000000;"> obj </span><span style="color: #0000FF;">Is</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Nothing</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Then</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: #008080;">33</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;">34</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    obj </span><span style="color: #000000;">=</span><span style="color: #000000;"> System.Activator.CreateInstance(clazz)
</span><span style="color: #008080;">35</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;"> e </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> Exception
</span><span style="color: #008080;">36</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    System.Console.WriteLine(e.Message)
</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;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</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: #008080;">39</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                objectContainer.Set(obj)
</span><span style="color: #008080;">40</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;">          Not Not Not  CAUTION Not Not Not </span><span style="color: #008000;">
</span><span style="color: #008080;">41</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                </span><span style="color: #008000;">'</span><span style="color: #008000;">          * There is a  commit  call here.</span><span style="color: #008000;">
</span><span style="color: #008080;">42</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                </span><span style="color: #008000;">'</span><span style="color: #008000;">          * </span><span style="color: #008000;">
</span><span style="color: #008080;">43</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                </span><span style="color: #008000;">'</span><span style="color: #008000;">          * The commit call  is  necessary, so  other transactions</span><span style="color: #008000;">
</span><span style="color: #008080;">44</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                </span><span style="color: #008000;">'</span><span style="color: #008000;">          * can see the New inserted Object.</span><span style="color: #008000;">
</span><span style="color: #008080;">45</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                </span><span style="color: #008000;">'</span><span style="color: #008000;">          */</span><span style="color: #008000;">
</span><span style="color: #008080;">46</span><span style="color: #008000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                objectContainer.Commit()
</span><span style="color: #008080;">47</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">48</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;">If</span><span style="color: #000000;">
</span><span style="color: #008080;">49</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">50</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            objectContainer.Ext().ReleaseSemaphore(semaphore)
</span><span style="color: #008080;">51</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">52</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;"> obj
</span><span style="color: #008080;">53</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Function</span></span><span style="color: #000000;">
</span><span style="color: #008080;">54</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">55</span><span style="color: #000000;"><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Open_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Closed_Image" src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Open_Text').style.display='inline';"/>        </span><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Function queryForSingletonClass()</span><span id="ResourcesReferenceClient-ServerSemaphoressemaphoresVB.ZipsSingleton.Vb_Singleton.Vb_152_43_1937_2495_Open_Text"><span style="color: #0000FF;">Function</span><span style="color: #000000;"> queryForSingletonClass(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> objectContainer </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer, </span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> clazz </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> System.Type) </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Object</span><span style="color: #000000;">
</span><span style="color: #008080;">56</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;"> q </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IQuery </span><span style="color: #000000;">=</span><span style="color: #000000;"> objectContainer.Query()
</span><span style="color: #008080;">57</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            q.Constrain(clazz)
</span><span style="color: #008080;">58</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;"> objectSet </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> q.Execute()
</span><span style="color: #008080;">59</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> objectSet.Size() </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: #0000FF;">Then</span><span style="color: #000000;">
</span><span style="color: #008080;">60</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;"> objectSet.Next()
</span><span style="color: #008080;">61</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;">If</span><span style="color: #000000;">
</span><span style="color: #008080;">62</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> objectSet.Size() </span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #800080;">1</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Then</span><span style="color: #000000;">
</span><span style="color: #008080;">63</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Throw</span><span style="color: #000000;"> </span><span style="color: #0000FF;">New</span><span style="color: #000000;"> Exception(</span><span style="color: #800000;">&quot;</span><span style="color: #800000;">Singleton problem. Multiple  instances of: </span><span style="color: #800000;">&quot;</span><span style="color: #000000;"> </span><span style="color: #000000;">+</span><span style="color: #000000;"> clazz.FullName)
</span><span style="color: #008080;">64</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;">If</span><span style="color: #000000;">
</span><span style="color: #008080;">65</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;"> </span><span style="color: #0000FF;">Nothing</span><span style="color: #000000;">
</span><span style="color: #008080;">66</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Function</span></span><span style="color: #000000;">
</span><span style="color: #008080;">67</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">68</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top"/>    </span><span style="color: #0000FF;">End Class</span></span><span style="color: #000000;">
</span><span style="color: #008080;">69</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>
</span><span style="color: #008080;">70</span><span style="color: #000000;"><img src="../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/></span><span style="color: #0000FF;">End Namespace</span></span></div></pre></div></div>
</span></div>
    </div>
    <div id="footer">
					This revision (5) was last Modified 2006-11-14T12:00:51 by Tetyana.
				</div>
  </body>
</html>