<html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>TypeHandlers</title> <link rel="stylesheet" type="text/css" href="../../style.css"> </head> <body> <div class="CommonContent"> <div class="CommonContentArea"> <h1>TypeHandlers</h1><script> //We attach this function to a browser object as a variable so that if multiple of these blocks are //present on the same page, then they will simply over-write eachother with the same function instead //of generating a naming collision. window.WikiCodeFormattingCopyToClipboard = function copyToClipboard(sID){ var sContent = document.getElementById(sID).innerText; if( window.clipboardData && clipboardData.setData ) { clipboardData.setData("Text", sContent); } else { alert("You must enable javascript access to your clipboard for this feature to work. Please referr to your browser documentation or Google search for instructions."); } } </script> <p>One of the most important and convenient things that db4o provides is the ability to store any object just as it is: no interfaces to be implemented, no custom fields, no attributes/annotations - nothing, just a plain object. However, it is not as simple as it may seem - objects are getting more and more complex and sometimes the generic solution is not good enough for specific objects. </p> <p>This problem was recognized by db4o team long ago, and various solutions were provided to customize the way an object is stored: configuration #readAs method, <a href="translators.html" class="wikiLink">Translators</a>, transient <a href="../tuning/selective_persistence/transient_fields_in_java.html" class="wikiLink">fields in Java</a> and <a href="../tuning/selective_persistence/transient_fields_in_.net.html" class="wikiLink">.NET</a> and <a href="../tuning/selective_persistence/transient_classes.html" class="wikiLink">classes</a>, custom marshallers etc. However all these means were rather fixing the symptoms but not the disease itself. And the fact is that there is no single generic way to store just any available or future object in the best possible way. But luckily we don't even need it - all we need is a simple way to write a specific persistence solution for any custom object, and now db4o provides this way though a pluggable TypeHandler4/ITypeHandler4 interface:</p> <span name="cs_wiki_filter" csw_filters="net"> <p>.NET:</p> <p><code>configuration.RegisterTypeHandler(ITypeHandlerPredicate, ITypeHandler4);</code></p> </span><p>In the method above TypeHandler4 interface provides methods that define how an object is converted to a low-level byte-array and back and how it behaves in a query:</p> <span name="cs_wiki_filter" csw_filters="net"> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">ITypeHandler4.cs</span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">01</span><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Open_Text').style.display='inline';"/><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_0_69_Open_Text"><span style="color: #008000;">/*</span><span style="color: #008000;"> Copyright (C) 2004 - 2008 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: #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.Ext; </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.Internal; </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;"> Db4objects.Db4o.Internal.Fieldhandlers; </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: #0000FF;">using</span><span style="color: #000000;"> Db4objects.Db4o.Marshall; </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: #008080;">08</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.Db4o.Internal </span><span style="color: #008080;">09</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Open_Text').style.display='inline';"/></span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_244_568_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">10</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_247_271_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;"> </span><span style="color: #808080;"><exclude></exclude></span><span style="color: #808080;"></span></span> <span style="color: #008080;">11</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/><span style="color: #000000;"> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">interface</span><span style="color: #000000;"> ITypeHandler4 : IComparable4, IFieldHandler </span><span style="color: #008080;">12</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_334_566_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">13</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oITypeHandler4.Cs_Db4oITypeHandler4.Cs_1690_53_338_389_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;"> </span><span style="color: #808080;"><exception cref="Db4oIOException"></exception></span><span style="color: #808080;"></span></span> <span style="color: #008080;">14</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> Delete(IDeleteContext context); </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: #008080;">16</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> Defragment(IDefragmentContext context); </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"/> </span><span style="color: #0000FF;">object</span><span style="color: #000000;"> Read(IReadContext context); </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: #008080;">20</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> Write(IWriteContext context, </span><span style="color: #0000FF;">object</span><span style="color: #000000;"> obj); </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/ExpandedBlockEnd.gif" align="top"/>}</span></span></div></pre></div></div> <div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">IComparable4.cs</span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52"><div><!-- Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ --><span style="color: #008080;">01</span><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Open_Text').style.display='inline';"/><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_0_69_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: #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.Foundation; </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: #008080;">05</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.Db4o.Internal </span><span style="color: #008080;">06</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Open_Text').style.display='inline';"/></span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_141_259_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_144_168_Open_Text"><span style="color: #808080;">///</span><span style="color: #008000;"> </span><span style="color: #808080;"><exclude></exclude></span><span style="color: #808080;"></span></span> <span style="color: #008080;">08</span><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/><span style="color: #000000;"> </span><span style="color: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">interface</span><span style="color: #000000;"> IComparable4 </span><span style="color: #008080;">09</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Open_Text').style.display='inline';"/> </span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesTypeHandlersTypeHandlerCS.Zipsdb4oIComparable4.Cs_Db4oIComparable4.Cs_1747_52_200_257_Open_Text"><span style="color: #000000;">{ </span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/> IPreparedComparison PrepareComparison(</span><span style="color: #0000FF;">object</span><span style="color: #000000;"> obj); </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/ExpandedBlockEnd.gif" align="top"/>}</span></span></div></pre></div></div> </span> <p>TypeHandlerPredicate provides a #match method, which returns true for objects that should be handled with the specified TypeHandler. </p> <p>Type handler functionality is best explained on a <a href="typehandlers/custom_typehandler_example.html" class="wikiLink">working example</a>.</p> <p>Usecases and other benefits of the pluggable typehandler interface are reviewed <a href="typehandlers/pluggable_typehandler_benefits.html" class="wikiLink">here</a>.</p></div> </div> <div id="footer"> This revision (6) was last Modified 2008-02-04T21:44:30 by dlouwers. </div> </body> </html>