Index: src/Deltares.DSoilModel.Tests/DSoilModelContextTest.cs
===================================================================
diff -u -r130 -r132
--- src/Deltares.DSoilModel.Tests/DSoilModelContextTest.cs (.../DSoilModelContextTest.cs) (revision 130)
+++ src/Deltares.DSoilModel.Tests/DSoilModelContextTest.cs (.../DSoilModelContextTest.cs) (revision 132)
@@ -155,19 +155,19 @@
dSoilModelContext.ParameterView = ParameterViewSettings.AllParameters;
var isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressValue));
Assert.IsTrue(isVisible != null && isVisible.Value);
- isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressValueStochast));
+ isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressStochast));
Assert.IsTrue(isVisible != null && isVisible.Value);
dSoilModelContext.ParameterView = ParameterViewSettings.AsIsParameters;
isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressValue));
Assert.IsTrue(isVisible != null && isVisible.Value);
- isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressValueStochast));
+ isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressStochast));
Assert.IsTrue(isVisible != null && !isVisible.Value);
dSoilModelContext.ParameterView = ParameterViewSettings.ProbabilisticParameters;
isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressValue));
Assert.IsTrue(isVisible != null && !isVisible.Value);
- isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressValueStochast));
+ isVisible = dSoilModelContext.IsVisible(pcs, pcs.GetMemberName(x => x.StressStochast));
Assert.IsTrue(isVisible != null && isVisible.Value);
}
Index: src/Deltares.DSoilModel.Forms/DSoilModelContext.cs
===================================================================
diff -u -r130 -r132
--- src/Deltares.DSoilModel.Forms/DSoilModelContext.cs (.../DSoilModelContext.cs) (revision 130)
+++ src/Deltares.DSoilModel.Forms/DSoilModelContext.cs (.../DSoilModelContext.cs) (revision 132)
@@ -180,7 +180,7 @@
if (source is PreConsolidationStress)
{
- if (member == ((PreConsolidationStress)source).GetMemberName(x => x.StressValueStochast))
+ if (member == ((PreConsolidationStress)source).GetMemberName(x => x.StressStochast))
{
return ParameterView != ParameterViewSettings.AsIsParameters;
}
Index: src/Deltares.DSoilModel.Data.Tests/DSoilModelTransformerTests.cs
===================================================================
diff -u -r131 -r132
--- src/Deltares.DSoilModel.Data.Tests/DSoilModelTransformerTests.cs (.../DSoilModelTransformerTests.cs) (revision 131)
+++ src/Deltares.DSoilModel.Data.Tests/DSoilModelTransformerTests.cs (.../DSoilModelTransformerTests.cs) (revision 132)
@@ -37,10 +37,10 @@
[Test]
[TestCase(typeof(Soil))]
-// [TestCase(typeof(PreConsolidationStress))] // TODO: yet to check
- public void TestStochasticPropertiesUncoupled(Type classType)
+ [TestCase(typeof(PreConsolidationStress))]
+ public void TestFindAutoStochastProperty(Type objType)
{
- var obj = Activator.CreateInstance(classType);
+ var obj = Activator.CreateInstance(objType);
var stochastProperties = PropertyInfoSupport.GetPropertiesOfType(obj.GetType(), typeof (Stochast));
foreach (BindPropertyInfo propertyInfo in stochastProperties)
{
Index: src/Deltares.DSoilModel.Data/DSoilModelTransformer.cs
===================================================================
diff -u -r131 -r132
--- src/Deltares.DSoilModel.Data/DSoilModelTransformer.cs (.../DSoilModelTransformer.cs) (revision 131)
+++ src/Deltares.DSoilModel.Data/DSoilModelTransformer.cs (.../DSoilModelTransformer.cs) (revision 132)
@@ -2,6 +2,7 @@
using Deltares.Geotechnics;
using Deltares.Probabilistic;
using Deltares.Standard;
+using Deltares.Standard.Reflection;
namespace Deltares.DSoilModel.Data
{
@@ -12,12 +13,36 @@
///
public class DSoilModelTransformer : ITransformer
{
+ private bool IsSupported(object obj)
+ {
+ return obj is Soil || obj is PreConsolidationStress;
+ }
+
+ private Stochast FindAutoStochastPropertyInPreConsolidationStress(PreConsolidationStress pcs, string property)
+ {
+ // currect exception from the rule dictated by huge amount of dependency on original property names and
+ // changing it is way to complex and affects a lot of legacy projects
+ if (pcs.GetMemberName(x => x.StressStochast) == property)
+ {
+ return pcs.StressStochast;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
///
/// Gets a stochast by associated property name
///
///
private Stochast FindAutoStochastProperty(object obj, string property)
{
+ if (obj is PreConsolidationStress) // exceptional case
+ {
+ return FindAutoStochastPropertyInPreConsolidationStress((PreConsolidationStress) obj, property);
+ }
+
// AutoStochastProperty convention, in fact, is the naming convention "{property name}Stochast" only
// so, for best performance we can locate the Stochast by name rather than looping over all stochasts checking their property association
if (!String.IsNullOrEmpty(property))
@@ -37,7 +62,7 @@
public double GetTransformedValue(object owner, string property, double measuredValue)
{
- if (owner is Soil || owner is PreConsolidationStress)
+ if (IsSupported(owner))
{
var stochast = FindAutoStochastProperty(owner, property);
if (stochast != null)
@@ -51,7 +76,7 @@
public double SetTransformedValue(object owner, string property, double transformedValue)
{
- if (owner is Soil || owner is PreConsolidationStress)
+ if (IsSupported(owner))
{
var stochast = FindAutoStochastProperty(owner, property);
if (stochast != null)