This topic applies to .NET version only
.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.
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).
You can use attributes with db4o to configure how db4o will process your classes. At present we provide only one attribute:
[Indexed]
This attribute can be applied to class fields
01using System; 02
using Db4objects.Db4o.Config.Attributes; 03
04
namespace Db4objects.Db4odoc.Attributes 05
{ 06
public class Car 07
{ 08
[Indexed] 09
private string _model; 10
private int _year; 11
} 12
}
01' Copyright (C) 2004 - 2006 db4objects Inc. http://www.db4o.com 02
Imports System 03
Imports Db4objects.Db4o 04
05
Namespace Db4objects.Db4odoc.Attributes 06
Public Class Car 07
<Config.Attributes.Indexed()> Private _model As String 08
Private _year As Integer 09
End Class 10
End Namespace
and its functionality is equivalent to the db4o configuration setting:
Db4o.Configure().ObjectClass(clazz).ObjectField("fieldName").Indexed(true)