Sophie

Sophie

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

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

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Cascaded Behavior</title>
    <link rel="stylesheet" type="text/css" href="../../../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Cascaded Behavior</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>You
can use different object events to initiate cascaded behavior on update,
activate, delete. The following example shows how to ensure that all the
referenced objects are deleted when the parent object is deleted:</p>



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

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">CallbacksExample.cs: <span class="fscMemberName">TestCascadedDelete</span></span></div><div class="fscCode"><pre ID="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74"><div><!--

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

--><span style="color: #008080;">01</span><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> TestCascadedDelete()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Open_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Closed_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Closed_Text').style.display='inline';"/><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Closed_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Open_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Open_Text').style.display='inline';"/>        </span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_49_864_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        FillContainer();
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            IObjectContainer container </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer();
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Open_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Closed_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Closed_Text').style.display='inline';"/><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Closed_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Open_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Open_Text').style.display='inline';"/>        </span><span style="color: #0000FF;">try</span><span style="color: #000000;"> </span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_142_805_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">06</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          </span><span style="color: #008000;">//</span><span style="color: #008000;"> check the contents of the database</span><span style="color: #008000;">
</span><span style="color: #008080;">07</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">          IObjectSet result </span><span style="color: #000000;">=</span><span style="color: #000000;"> container.Get(</span><span style="color: #0000FF;">null</span><span style="color: #000000;">);
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          ListResult(result);
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          IEventRegistry registry </span><span style="color: #000000;">=</span><span style="color: #000000;">  EventRegistryFactory.ForObjectContainer(container);
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>          </span><span style="color: #008000;">//</span><span style="color: #008000;"> register an event handler, which will delete the pilot when his car is Deleted </span><span style="color: #008000;">
</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: #000000;">                registry.Deleted </span><span style="color: #000000;">+=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> ObjectEventHandler(OnDeleted);
</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: #008000;">//</span><span style="color: #008000;"> delete all the cars</span><span style="color: #008000;">
</span><span style="color: #008080;">14</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">          result </span><span style="color: #000000;">=</span><span style="color: #000000;"> container.Query(</span><span style="color: #0000FF;">typeof</span><span style="color: #000000;">(Car));
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Open_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Closed_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Closed_Text').style.display='inline';"/><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Closed_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Open_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Open_Text').style.display='inline';"/>          </span><span style="color: #0000FF;">while</span><span style="color: #000000;">(result.HasNext()) </span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_626_692_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                  container.Delete(result.Next());
</span><span style="color: #008080;">17</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;">18</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;"> check if the database is empty</span><span style="color: #008000;">
</span><span style="color: #008080;">19</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">          result </span><span style="color: #000000;">=</span><span style="color: #000000;"> container.Get(</span><span style="color: #0000FF;">null</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"/>          ListResult(result);
</span><span style="color: #008080;">21</span><span style="color: #000000;"><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Open_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Closed_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Closed_Text').style.display='inline';"/><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Closed_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Open_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Open_Text').style.display='inline';"/>        }</span></span><span style="color: #000000;"> </span><span style="color: #0000FF;">finally</span><span style="color: #000000;"> </span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_TestCascadedDelete_282_74_814_857_Open_Text"><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"/>                CloseContainer();
</span><span style="color: #008080;">23</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;">24</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">CallbacksExample.cs: <span class="fscMemberName">OnDeleted</span></span></div><div class="fscCode"><pre ID="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65"><div><!--

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

--><span style="color: #008080;">1</span><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">static</span><span style="color: #000000;"> </span><span style="color: #0000FF;">void</span><span style="color: #000000;"> OnDeleted(</span><span style="color: #0000FF;">object</span><span style="color: #000000;"> sender, ObjectEventArgs args)
</span><span style="color: #008080;">2</span><span style="color: #000000;"><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Open_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Closed_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Closed_Text').style.display='inline';"/><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Closed_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Open_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Open_Text').style.display='inline';"/>        </span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_75_238_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            Object obj </span><span style="color: #000000;">=</span><span style="color: #000000;"> args.Object;
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">if</span><span style="color: #000000;"> (obj </span><span style="color: #0000FF;">is</span><span style="color: #000000;"> Car)
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Open_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Closed_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Closed_Text').style.display='inline';"/><img id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Closed_Text').style.display='none'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Open_Image').style.display='inline'; document.getElementById('....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Open_Text').style.display='inline';"/>            </span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="....CallbacksCS.ZipsCallbacksExample.Cs_CallbacksExample.Cs_OnDeleted_360_65_155_228_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                OpenContainer().Delete(((Car)obj).Pilot);
</span><span style="color: #008080;">7</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;">8</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        }</span></span></div></pre></div></div>

</span>

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


<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">CallbacksExample.vb: <span class="fscMemberName">TestCascadedDelete</span></span></div><div class="fscCode"><pre ID="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74"><div><!--

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

--><span style="color: #008080;">01</span><img id="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Open_Text').style.display='none'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Closed_Image').style.display='inline'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Closed_Text').style.display='inline';"/><img id="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Closed_Text').style.display='none'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Open_Image').style.display='inline'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub TestCascadedDelete()</span><span id="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_TestCascadedDelete_491_74_15_989_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> TestCascadedDelete()
</span><span style="color: #008080;">02</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            FillContainer()
</span><span style="color: #008080;">03</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> container </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectContainer </span><span style="color: #000000;">=</span><span style="color: #000000;"> OpenContainer
</span><span style="color: #008080;">04</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">Try</span><span style="color: #000000;">
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #008000;">'</span><span style="color: #008000;"> check the contents of the database</span><span style="color: #008000;">
</span><span style="color: #008080;">06</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> result </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IObjectSet </span><span style="color: #000000;">=</span><span style="color: #000000;"> container.Get(</span><span style="color: #0000FF;">Nothing</span><span style="color: #000000;">)
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                ListResult(result)
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">Dim</span><span style="color: #000000;"> registry </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> IEventRegistry </span><span style="color: #000000;">=</span><span style="color: #000000;"> EventRegistryFactory.ForObjectContainer(container)
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #008000;">'</span><span style="color: #008000;"> register an event handler, which will delete the pilot when his car is Deleted </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: #0000FF;">AddHandler</span><span style="color: #000000;"> registry.Deleted, </span><span style="color: #0000FF;">AddressOf</span><span style="color: #000000;"> OnDeleted
</span><span style="color: #008080;">11</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #008000;">'</span><span style="color: #008000;"> delete all the cars</span><span style="color: #008000;">
</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: #000000;">                result </span><span style="color: #000000;">=</span><span style="color: #000000;"> container.Query(</span><span style="color: #0000FF;">GetType</span><span style="color: #000000;">(Car))
</span><span style="color: #008080;">13</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">While</span><span style="color: #000000;"> result.HasNext
</span><span style="color: #008080;">14</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                    container.Delete(result.Next)
</span><span style="color: #008080;">15</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #0000FF;">End</span><span style="color: #000000;"> </span><span style="color: #0000FF;">While</span><span style="color: #000000;">
</span><span style="color: #008080;">16</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                </span><span style="color: #008000;">'</span><span style="color: #008000;"> check if the database is empty</span><span style="color: #008000;">
</span><span style="color: #008080;">17</span><span style="color: #008000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/></span><span style="color: #000000;">                result </span><span style="color: #000000;">=</span><span style="color: #000000;"> container.Get(</span><span style="color: #0000FF;">Nothing</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"/>                ListResult(result)
</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;">Finally</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"/>                CloseContainer()
</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;">Try</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 style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">CallbacksExample.vb: <span class="fscMemberName">OnDeleted</span></span></div><div class="fscCode"><pre ID="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65"><div><!--

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

--><span style="color: #008080;">1</span><img id="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Open_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Open_Text').style.display='none'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Closed_Image').style.display='inline'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Closed_Text').style.display='inline';"/><img id="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Closed_Image" src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Closed_Text').style.display='none'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Open_Image').style.display='inline'; document.getElementById('....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Open_Text').style.display='inline';"/><span style="color: #0000FF;">Private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Shared</span><span style="color: #000000;"> </span><span id="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Sub OnDeleted()</span><span id="....CallbacksVB.ZipsCallbacksExample.Vb_CallbacksExample.Vb_OnDeleted_569_65_15_260_Open_Text"><span style="color: #0000FF;">Sub</span><span style="color: #000000;"> OnDeleted(</span><span style="color: #0000FF;">ByVal</span><span style="color: #000000;"> sender </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: #0000FF;">ByVal</span><span style="color: #000000;"> args </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> ObjectEventArgs)
</span><span style="color: #008080;">2</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;"> args.Object
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>            </span><span style="color: #0000FF;">If</span><span style="color: #000000;"> </span><span style="color: #0000FF;">TypeOf</span><span style="color: #000000;"> obj </span><span style="color: #0000FF;">Is</span><span style="color: #000000;"> Car </span><span style="color: #0000FF;">Then</span><span style="color: #000000;">
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>                OpenContainer.Delete(</span><span style="color: #0000FF;">CType</span><span style="color: #000000;">(obj, Car).Pilot)
</span><span style="color: #008080;">5</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;">6</span><span style="color: #000000;"><img src="../../../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockEnd.gif" align="top"/>        </span><span style="color: #0000FF;">End Sub</span></span></div></pre></div></div>

</span></div>
    </div>
    <div id="footer">
					This revision (3) was last Modified 2007-12-02T16:56:25 by Tetyana.
				</div>
  </body>
</html>