01/* Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com */ 02
using Db4objects.Db4o; 03
using Db4objects.Db4o.Activation; 04
using Db4objects.Db4o.TA; 05
06
namespace Db4objects.Db4odoc.TP.Rollback 07
{ 08
public class Id : IActivatable 09
{ 10
int _number = 0; 11
12
[System.NonSerialized] 13
IActivator _activator; 14
15
public Id(int number) 16
{ 17
_number = number; 18
} 19
20
// Bind the class to an object container 21
public void Bind(IActivator activator) 22
{ 23
if (_activator == activator) 24
{ 25
return; 26
} 27
if (activator != null && null != _activator) 28
{ 29
throw new System.InvalidOperationException(); 30
} 31
_activator = activator; 32
} 33
34
// activate the object fields 35
public void Activate(ActivationPurpose purpose) 36
{ 37
if (_activator == null) 38
return; 39
_activator.Activate(purpose); 40
} 41
42
public void Change(int number) 43
{ 44
Activate(ActivationPurpose.Write); 45
_number = number; 46
} 47
48
public override string ToString() 49
{ 50
Activate(ActivationPurpose.Read); 51
return _number.ToString(); 52
} 53
} 54
55
}
01' Copyright (C) 2004 - 2008 db4objects Inc. http://www.db4o.com 02
03
Imports Db4objects.Db4o 04
Imports Db4objects.Db4o.Activation 05
Imports Db4objects.Db4o.TA 06
07
Namespace Db4objects.Db4odoc.TP.Rollback 08
Public Class Id 09
Implements IActivatable 10
Private _number As Integer = 0 11
12
<Transient()> _ 13
Private _activator As IActivator 14
15
Public Sub New(ByVal number As Integer) 16
_number = number 17
End Sub 18
19
' Bind the class to an object container 20
Public Sub Bind(ByVal activator As IActivator) Implements IActivatable.Bind 21
If _activator Is activator Then 22
Return 23
End If 24
If activator IsNot Nothing AndAlso _activator IsNot Nothing Then 25
Throw New System.InvalidOperationException() 26
End If 27
_activator = activator 28
End Sub 29
30
' activate the object fields 31
Public Sub Activate(ByVal purpose As ActivationPurpose) Implements IActivatable.Activate 32
If _activator Is Nothing Then 33
Return 34
End If 35
_activator.Activate(purpose) 36
End Sub 37
38
Public Sub Change(ByVal number As Integer) 39
Activate(ActivationPurpose.Write) 40
_number = number 41
End Sub 42
43
Public Overloads Overrides Function ToString() As String 44
Activate(ActivationPurpose.Read) 45
Return _number.ToString() 46
End Function 47
End Class 48
49
End Namespace