1 /* Copyright (C) 2004 - 2009 Versant Inc. http://www.db4o.com */ 2 3 using Db4objects.Db4o.Internal; 4 using Db4objects.Db4o.Internal.Activation; 5 6 namespace Db4objects.Db4o.Internal.Activation 7 { 8 /// <summary> 9 /// Activates a fixed depth of the object graph regardless of 10 /// any existing activation depth configuration settings. 11 /// </summary> 12 /// <remarks> 13 /// Activates a fixed depth of the object graph regardless of 14 /// any existing activation depth configuration settings. 15 /// </remarks> 16 public class FixedActivationDepth : ActivationDepthImpl 17 { 18 private readonly int _depth; 19 FixedActivationDepth(int depth, ActivationMode mode)20 public FixedActivationDepth(int depth, ActivationMode mode) : base(mode) 21 { 22 _depth = depth; 23 } 24 FixedActivationDepth(int depth)25 public FixedActivationDepth(int depth) : this(depth, ActivationMode.Activate) 26 { 27 } 28 RequiresActivation()29 public override bool RequiresActivation() 30 { 31 return _depth > 0; 32 } 33 Descend(ClassMetadata metadata)34 public override IActivationDepth Descend(ClassMetadata metadata) 35 { 36 if (_depth < 1) 37 { 38 return this; 39 } 40 return new Db4objects.Db4o.Internal.Activation.FixedActivationDepth(_depth - 1, _mode 41 ); 42 } 43 44 // TODO code duplication in fixed activation/update depth AdjustDepthToBorders()45 public virtual Db4objects.Db4o.Internal.Activation.FixedActivationDepth AdjustDepthToBorders 46 () 47 { 48 return new Db4objects.Db4o.Internal.Activation.FixedActivationDepth(DepthUtil.AdjustDepthToBorders 49 (_depth)); 50 } 51 } 52 } 53