// Copyright (C) Stichting Deltares 2016. All rights reserved.
//
// This file is part of Ringtoets.
//
// Ringtoets is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
// All names, logos, and references to "Deltares" are registered trademarks of
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
using System;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.FailureMechanism;
namespace Ringtoets.Common.Utils
{
///
/// This class is used to be able to assign calculations to failure mechanism section results without having
/// to keep in mind the underlying types for either calculations or section results.
///
public class SectionResultWithCalculationAssignment
{
private readonly Action setCalculationAction;
private readonly Func getCalculationAction;
///
/// Creates new instance of .
///
/// The result which can have a calculation assigned.
/// The to get an
/// from the .
/// The to set an
/// to the .
/// Thrown when any of the parameters is null.
public SectionResultWithCalculationAssignment(
FailureMechanismSectionResult result,
Func getCalculationAction,
Action setCalculationAction)
{
if (result == null)
{
throw new ArgumentNullException("result");
}
if (getCalculationAction == null)
{
throw new ArgumentNullException("getCalculationAction");
}
if (setCalculationAction == null)
{
throw new ArgumentNullException("setCalculationAction");
}
Result = result;
this.getCalculationAction = getCalculationAction;
this.setCalculationAction = setCalculationAction;
}
///
/// Gets the for which the assignment object is defined.
///
public FailureMechanismSectionResult Result { get; private set; }
///
/// Gets or sets the from the using the actions passed
/// to the constructor.
///
internal ICalculation Calculation
{
get
{
return getCalculationAction(Result);
}
set
{
setCalculationAction(Result, value);
}
}
}
}