01/* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com */ 02
using System; 03
using Db4objects.Db4o.TA; 04
using Db4objects.Db4o.Activation; 05
06
namespace Db4objects.Db4odoc.TPClone 07
{ 08
public class Car : IActivatable, ICloneable 09
{ 10
private string _model; 11
private Pilot _pilot; 12
/*activator registered for this class*/ 13
[System.NonSerialized] 14
public IActivator _activator; 15
16
17
public Car(string model, Pilot pilot) 18
{ 19
_model = model; 20
_pilot = pilot; 21
} 22
// end Car 23
24
/*Bind the class to the specified object container, create the activator*/ 25
public void Bind(IActivator activator) 26
{ 27
if (_activator == activator) 28
{ 29
return; 30
} 31
if (activator != null && null != _activator) 32
{ 33
throw new System.InvalidOperationException(); 34
} 35
_activator = activator; 36
} 37
// end Bind 38
39
/*Call the registered activator to activate the next level, 40
* the activator remembers the objects that were already 41
* activated and won't activate them twice. 42
*/ 43
public void Activate(ActivationPurpose purpose) 44
{ 45
if (_activator == null) 46
return; 47
_activator.Activate(purpose); 48
} 49
// end Activate 50
51
public object Clone() 52
{ 53
return base.MemberwiseClone(); 54
} 55
// end Clone 56
57
58
override public string ToString() 59
{ 60
Activate(ActivationPurpose.Read); 61
return string.Format("{0}[{1}]", _model, _pilot); 62
} 63
// end ToString 64
} 65
}
01' Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com 02
03
Imports System 04
Imports Db4objects.Db4o 05
Imports Db4objects.Db4o.TA 06
Imports Db4objects.Db4o.Activation 07
08
Namespace Db4objects.Db4odoc.TPClone 09
Public Class Car 10
Implements IActivatable 11
Implements ICloneable 12
Private _model As String 13
Private _pilot As Pilot 14
'activator registered for this class 15
16
<Transient()> _ 17
Public _activator As IActivator 18
19
20
Public Sub New(ByVal model As String, ByVal pilot As Pilot) 21
_model = model 22
_pilot = pilot 23
End Sub 24
' end Car 25
26
'Bind the class to the specified object container, create the activator 27
28
Public Sub Bind(ByVal activator As IActivator) Implements IActivatable.Bind 29
If _activator Is activator Then 30
Return 31
End If 32
If activator IsNot Nothing AndAlso _activator IsNot Nothing Then 33
Throw New System.InvalidOperationException() 34
End If 35
_activator = activator 36
End Sub 37
' end Bind 38
39
'Call the registered activator to activate the next level, 40
' * the activator remembers the objects that were already 41
' * activated and won't activate them twice. 42
' 43
44
Public Sub Activate(ByVal purpose As ActivationPurpose) Implements IActivatable.Activate 45
If _activator Is Nothing Then 46
Return 47
End If 48
_activator.Activate(purpose) 49
End Sub 50
' end Activate 51
52
Public Function Clone() As Object Implements ICloneable.Clone 53
Return MyBase.MemberwiseClone() 54
End Function 55
' end Clone 56
57
58
Public Overloads Overrides Function ToString() As String 59
Activate(ActivationPurpose.Read) 60
Return String.Format("{0}[{1}]", _model, _pilot) 61
End Function 62
' end ToString 63
End Class 64
End Namespace