Sophie

Sophie

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

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

<html>
  <head>
    <META http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Using Attributes</title>
    <link rel="stylesheet" type="text/css" href="../../style.css">
  </head>
  <body>
    <div class="CommonContent">
      <div class="CommonContentArea">
        <h1>Using Attributes</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><font color="#990000">This topic applies to .NET version only</font>  <br></p>
<p>.NET Attributes provide the means for a developer to add meta-data that 
describes, or annotates specific elements of code such as classes, methods, 
properties, etc. At compile time the resulting metadata is placed into the 
Portable Executable (PE)file along with the Microsoft Intermediate Language 
(MSIL). Once metadata is in the PE other .NET programs may access it using the 
.NET Reflection API.</p>

<p>Attributes can be used to document classes at design 
time, specify runtime information (such as the name of an XML field to be used 
when serializing information from the class), and even dictate runtime behavior 
(such as whether the class should automatically participate in a transaction). 
</p>

<p>You can use attributes with db4o to configure how db4o will process 
your classes. At present we provide only one attribute:</p>

<p><code>[Indexed]</code></p>

<p>This attribute 
can be applied to class fields</p>

<span name="cs_wiki_filter" csw_filters="cs">
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">Car.cs</span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37"><div><!--

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

--><span style="color: #008080;">01</span><img id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Open_Text').style.display='inline';"/><span id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_0_67_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">/**/</span><span id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_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;"> Db4objects.Db4o.Config.Attributes;
</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: #008080;">04</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.Attributes
</span><span style="color: #008080;">05</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Open_Text').style.display='inline';"/></span><span id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_150_235_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: #0000FF;">public</span><span style="color: #000000;"> </span><span style="color: #0000FF;">class</span><span style="color: #000000;"> Car
</span><span style="color: #008080;">07</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Open_Text').style.display='inline';"/>  </span><span id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">...</span><span id="ResourcesReferenceImplementation_StrategiesattributesCS.ZipsCar.Cs_Car.Cs_1090_37_171_233_Open_Text"><span style="color: #000000;">{
</span><span style="color: #008080;">08</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>    [Indexed]
</span><span style="color: #008080;">09</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>    </span><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">string</span><span style="color: #000000;"> _model;
</span><span style="color: #008080;">10</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>    </span><span style="color: #0000FF;">private</span><span style="color: #000000;"> </span><span style="color: #0000FF;">int</span><span style="color: #000000;"> _year;
</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><span name="cs_wiki_filter" csw_filters="vb"></p>
<div class="FormattedSourceCode"><div class="fscHeader"><span class="fscFileName">Car.vb</span></div><div class="fscCode"><pre ID="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37"><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: #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;">2</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;"> Db4objects.Db4o
</span><span style="color: #008080;">3</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/None.gif" align="top"/>
</span><span style="color: #008080;">4</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Open_Text').style.display='inline';"/></span><span id="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Namespace Db4objects</span><span id="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_90_274_Open_Text"><span style="color: #0000FF;">Namespace</span><span style="color: #000000;"> Db4objects.Db4odoc.Attributes
</span><span style="color: #008080;">5</span><span style="color: #000000;"><img id="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Open_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Open_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Closed_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Closed_Text').style.display='inline';"/><img id="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Closed_Image" src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/ContractedSubBlock.gif" align="top" style="display: none;" onClick="this.style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Closed_Text').style.display='none'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Open_Image').style.display='inline'; document.getElementById('ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Open_Text').style.display='inline';"/>    </span><span style="color: #0000FF;">Public</span><span style="color: #000000;"> </span><span id="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Closed_Text" style="border: solid 1px #808080; background-color: #FFFFFF; display: none;">Class Car</span><span id="ResourcesReferenceImplementation_StrategiesattributesVB.ZipsCar.Vb_Car.Vb_1194_37_141_260_Open_Text"><span style="color: #0000FF;">Class</span><span style="color: #000000;"> Car
</span><span style="color: #008080;">6</span><span style="color: #000000;"><img src="../../Utility/ActiPro.CodeHighligher/OutliningIndicators/InBlock.gif" align="top"/>        </span><span style="color: #000000;">&lt;</span><span style="color: #000000;">Config.Attributes.Indexed()</span><span style="color: #000000;">&gt;</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Private</span><span style="color: #000000;"> _model </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: #008080;">7</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;"> _year </span><span style="color: #0000FF;">As</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Integer</span><span style="color: #000000;">
</span><span style="color: #008080;">8</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;">9</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>
<p></span> <br></p>

<p>and its functionality 
is equivalent to the db4o configuration setting: </p>

<p><code>Db4o.Configure().ObjectClass(clazz).ObjectField("fieldName").Indexed(true)</code></p></div>
    </div>
    <div id="footer">
					This revision (6) was last Modified 2006-12-04T07:56:36 by Tetyana.
				</div>
  </body>
</html>