/// <summary> /// Add a new <see cref="IRequiresRecovery"/> object to this /// list. /// </summary> /// <param name="recovery">Object to add.</param> public void Add(IRequiresRecovery recovery) { lock (_lockObj) { _recoveries.Push(recovery ?? throw new ArgumentNullException(nameof(recovery))); } }
/// <summary> /// Add a new <see cref="IRequiresRecovery"/> object to this /// list. /// </summary> /// <param name="recovery">Object to add.</param> public void Add(IRequiresRecovery recovery) { Guard.ArgumentNotNull(recovery, "recovery"); lock(lockObj) { recoveries.Push(recovery); } }
/// <summary> /// Add a new <see cref="IRequiresRecovery"/> object to this /// list. /// </summary> /// <param name="recovery">Object to add.</param> public void Add(IRequiresRecovery recovery) { Guard.ArgumentNotNull(recovery, "recovery"); lock (lockObj) { recoveries.Push(recovery); } }
public override void PreBuildUp(IBuilderContext context) { Guard.ArgumentNotNull(context, "context"); if (context.Existing == null) { ILifetimePolicy lifetimePolicy = GetLifetimePolicy(context); IRequiresRecovery recovery = lifetimePolicy as IRequiresRecovery; if (recovery != null) { context.RecoveryStack.Add(recovery); } object existing = lifetimePolicy.GetValue(); if (existing != null) { context.Existing = existing; context.BuildComplete = true; } } }
/// <summary> /// Called during the chain of responsibility for a build operation. The /// PreBuildUp method is called when the chain is being executed in the /// forward direction. /// </summary> /// <param name="context">Context of the build operation.</param> // FxCop suppression: Validation is done by Guard class public override void PreBuildUp(IBuilderContext context) { Guard.ArgumentNotNull(context, "context"); if (context.Existing != null) { return; } IPolicyList containingPolicyList; ILifetimePolicy lifetimePolicy = GetLifetimePolicy(context, out containingPolicyList); var scope = lifetimePolicy as IScopeLifetimePolicy; if (null != scope && !ReferenceEquals(containingPolicyList, context.PersistentPolicies)) { lifetimePolicy = scope.CreateScope() as ILifetimePolicy; context.PersistentPolicies.Set(lifetimePolicy, context.BuildKey); context.Lifetime.Add(lifetimePolicy); } IRequiresRecovery recovery = lifetimePolicy as IRequiresRecovery; if (recovery != null) { context.RecoveryStack.Add(recovery); } object existing = lifetimePolicy.GetValue(); if (existing != null) { context.Existing = existing; context.BuildComplete = true; } }