Index: Core/Common/src/Core.Common.Gui/Converters/KeyValueElementAttribute.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Converters/KeyValueElementAttribute.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Converters/KeyValueElementAttribute.cs (revision ca27aee933103177a29a8d2ab46e127dbb8bacf6) @@ -0,0 +1,90 @@ +// Copyright (C) Stichting Deltares 2017. 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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 System.Reflection; + +namespace Core.Common.Gui.Converters +{ + /// + /// Attribute when using the to define what is + /// shown as name and value for eache element. + /// + [AttributeUsage(AttributeTargets.Property)] + public class KeyValueElementAttribute : Attribute + { + private readonly string namePropertyName; + private readonly string valuePropertyName; + + /// + /// Creates a new instance of . + /// + /// The name of the property to show as name. + /// The name of the property to show as value. + public KeyValueElementAttribute(string namePropertyName, string valuePropertyName) + { + this.namePropertyName = namePropertyName; + this.valuePropertyName = valuePropertyName; + if (valuePropertyName == null) + { + throw new ArgumentNullException(nameof(valuePropertyName)); + } + if (namePropertyName == null) + { + throw new ArgumentNullException(nameof(namePropertyName)); + } + } + + /// + /// Gets the property value from the that is used + /// as name. + /// + /// The source to obtain the property value of. + /// The value used as name of the property. + public string GetName(object source) + { + PropertyInfo namePropertyInfo = source.GetType().GetProperty(namePropertyName); + if (namePropertyInfo == null) + { + throw new ArgumentException($"Key property '{namePropertyName}' was not found on type {source.GetType().Name}."); + } + + return Convert.ToString(namePropertyInfo.GetValue(source, new object[0])); + } + + /// + /// Gets the property value from the that is used + /// as value. + /// + /// The source to obtain the property value of. + /// The value used as value of the property. + public string GetValue(object source) + { + PropertyInfo valuePropertyInfo = source.GetType().GetProperty(valuePropertyName); + if (valuePropertyInfo == null) + { + throw new ArgumentException($"Key property '{valuePropertyName}' was not found on type {source.GetType().Name}."); + } + + return Convert.ToString(valuePropertyInfo.GetValue(source, new object[0])); + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Converters/KeyValueExpandableArrayConverter.cs =================================================================== diff -u -r2b62d771a30ac4a3a59b52efc9df88afbc6663b2 -rca27aee933103177a29a8d2ab46e127dbb8bacf6 --- Core/Common/src/Core.Common.Gui/Converters/KeyValueExpandableArrayConverter.cs (.../KeyValueExpandableArrayConverter.cs) (revision 2b62d771a30ac4a3a59b52efc9df88afbc6663b2) +++ Core/Common/src/Core.Common.Gui/Converters/KeyValueExpandableArrayConverter.cs (.../KeyValueExpandableArrayConverter.cs) (revision ca27aee933103177a29a8d2ab46e127dbb8bacf6) @@ -26,7 +26,7 @@ namespace Core.Common.Gui.Converters { - public class KeyValueExpandableArrayConverter : ExpandableArrayConverter + public class KeyValueExpandableArrayConverter : ArrayConverter { public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { @@ -43,30 +43,28 @@ public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { + var keyValueAttribute = context?.PropertyDescriptor?.Attributes?[typeof(KeyValueElementAttribute)] as KeyValueElementAttribute; + + if (keyValueAttribute == null) + { + throw new ArgumentException($"The {typeof(KeyValueExpandableArrayConverter).Name} can only be used on properties that have the " + + $"{typeof(KeyValueElementAttribute).Name} defined."); + } + PropertyDescriptor[] properties = null; var array = value as Array; if (array != null) { Type type = array.GetType(); Type elementType = type.GetElementType(); - if (!typeof(KeyValueExpandableArrayElement).IsAssignableFrom(elementType)) - { - throw new ArgumentException($"Require elements in the array of type {typeof(KeyValueExpandableArrayElement).Name}."); - } - int length = array.GetLength(0); properties = new PropertyDescriptor[length]; for (var index = 0; index < length; ++index) { - var keyValueExpandableArrayElement = array.GetValue(index) as KeyValueExpandableArrayElement; - - if (keyValueExpandableArrayElement == null) - { - throw new ArgumentException($"Require elements in the array to be not null."); - } - properties[index] = new ArrayPropertyDescriptor(keyValueExpandableArrayElement, type, elementType); + object source = array.GetValue(index); + properties[index] = new ArrayPropertyDescriptor(elementType, keyValueAttribute.GetName(source), keyValueAttribute.GetValue(source)); } } return new PropertyDescriptorCollection(properties); @@ -77,14 +75,14 @@ /// Properties are named based the first item in the provided tuple and the value is /// based on the second item. /// - protected class ArrayPropertyDescriptor : SimplePropertyDescriptor + private class ArrayPropertyDescriptor : SimplePropertyDescriptor { private readonly object value; - public ArrayPropertyDescriptor(KeyValueExpandableArrayElement element, Type componentType, Type propertyType) - : base(componentType, Convert.ToString(element.Name), propertyType) + public ArrayPropertyDescriptor(Type elementType, string name, object value) + : base(elementType, name, value.GetType()) { - value = element.Value; + this.value = value; } public override bool IsReadOnly @@ -102,21 +100,8 @@ public override void SetValue(object component, object value) { - throw new NotImplementedException(); + throw new NotSupportedException(); } } } - - public class KeyValueExpandableArrayElement - { - public KeyValueExpandableArrayElement(string name, object value) - { - Name = name; - Value = value; - } - - public string Name { get; } - - public object Value { get;} - } } \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -r2b62d771a30ac4a3a59b52efc9df88afbc6663b2 -rca27aee933103177a29a8d2ab46e127dbb8bacf6 --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision 2b62d771a30ac4a3a59b52efc9df88afbc6663b2) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision ca27aee933103177a29a8d2ab46e127dbb8bacf6) @@ -121,6 +121,7 @@ + Index: Core/Common/test/Core.Common.Gui.Test/Converters/ExpandableArrayConverterTest.cs =================================================================== diff -u -r2b62d771a30ac4a3a59b52efc9df88afbc6663b2 -rca27aee933103177a29a8d2ab46e127dbb8bacf6 --- Core/Common/test/Core.Common.Gui.Test/Converters/ExpandableArrayConverterTest.cs (.../ExpandableArrayConverterTest.cs) (revision 2b62d771a30ac4a3a59b52efc9df88afbc6663b2) +++ Core/Common/test/Core.Common.Gui.Test/Converters/ExpandableArrayConverterTest.cs (.../ExpandableArrayConverterTest.cs) (revision ca27aee933103177a29a8d2ab46e127dbb8bacf6) @@ -54,7 +54,7 @@ object text = converter.ConvertTo(sourceArray, typeof(string)); // Assert - Assert.AreEqual(string.Format("Aantal ({0})", arrayCount), text); + Assert.AreEqual($"Aantal ({arrayCount})", text); } [Test] Index: Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueElementAttributeTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueElementAttributeTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueElementAttributeTest.cs (revision ca27aee933103177a29a8d2ab46e127dbb8bacf6) @@ -0,0 +1,180 @@ +// Copyright (C) Stichting Deltares 2017. 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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 Core.Common.Gui.Converters; +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Converters +{ + [TestFixture] + public class KeyValueElementAttributeTest + { + [Test] + public void Constructor_WithoutValuePropertyName_ThrowsArgumentNullException() + { + // Setup + const string namePropertyName = "name"; + + // Call + TestDelegate test = () => new KeyValueElementAttribute(namePropertyName, null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("valuePropertyName", exception.ParamName); + } + + [Test] + public void Constructor_WithoutNamePropertyName_ThrowsArgumentNullException() + { + // Setup + const string valuePropertyName = "value"; + + // Call + TestDelegate test = () => new KeyValueElementAttribute(null, valuePropertyName); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("namePropertyName", exception.ParamName); + } + + [Test] + public void Constructor_WithParameters_CreatesNewInstance() + { + // Setup + const string valuePropertyName = "value"; + const string namePropertyName = "name"; + + // Call + var attribute = new KeyValueElementAttribute(namePropertyName, valuePropertyName); + + // Assert + Assert.IsInstanceOf(attribute); + } + + [Test] + public void GetName_WithObjectWithProperty_ReturnsValueOfProperty() + { + // Setup + const string expectedName = "expectedName"; + + var attribute = new KeyValueElementAttribute(nameof(TestObject.Name), nameof(TestObject.Value)); + + // Call + string name = attribute.GetName(new TestObject + { + Name = expectedName, + }); + + // Assert + Assert.AreEqual(expectedName, name); + } + + [Test] + public void GetName_WithObjectWithNonStringProperty_ReturnsValueOfProperty() + { + // Setup + int expectedName = new Random(21).Next(3, 50); + + var attribute = new KeyValueElementAttribute(nameof(TestObject.NonStringName), nameof(TestObject.NonStringValue)); + + // Call + string name = attribute.GetName(new TestObject + { + NonStringName = expectedName, + }); + + // Assert + Assert.AreEqual(Convert.ToString(expectedName), name); + } + + [Test] + public void GetName_WithObjectWithoutPropertyWithName_ThrowsArgumentException() + { + // Setup + var attribute = new KeyValueElementAttribute("IDoNotExist", nameof(TestObject.Value)); + + // Call + TestDelegate test = () => attribute.GetName(new TestObject()); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetValue_WithObjectWithProperty_ReturnsValueOfProperty() + { + // Setup + const string expectedValue = "expectedValue"; + + var attribute = new KeyValueElementAttribute(nameof(TestObject.Name), nameof(TestObject.Value)); + + // Call + string value = attribute.GetValue(new TestObject + { + Value = expectedValue + }); + + // Assert + Assert.AreEqual(expectedValue, value); + } + + [Test] + public void GetValue_WithObjectWithNonStringProperty_ReturnsStringConvertedValueOfProperty() + { + // Setup + int expectedValue = new Random(21).Next(3, 50); + + var attribute = new KeyValueElementAttribute(nameof(TestObject.NonStringName), nameof(TestObject.NonStringValue)); + + // Call + string value = attribute.GetValue(new TestObject + { + NonStringValue = expectedValue + }); + + // Assert + Assert.AreEqual(Convert.ToString(expectedValue), value); + } + + [Test] + public void GetValue_WithObjectWithoutPropertyWithName_ThrowsArgumentException() + { + // Setup + var attribute = new KeyValueElementAttribute(nameof(TestObject.Name), "IDoNotExist"); + + // Call + TestDelegate test = () => attribute.GetValue(new TestObject()); + + // Assert + Assert.Throws(test); + } + + private class TestObject + { + public string Name { get; set; } + public string Value { get; set; } + + public int NonStringName { get; set; } + public int NonStringValue { get; set; } + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueExpandableArrayConverterTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueExpandableArrayConverterTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Converters/KeyValueExpandableArrayConverterTest.cs (revision ca27aee933103177a29a8d2ab46e127dbb8bacf6) @@ -0,0 +1,299 @@ +// Copyright (C) Stichting Deltares 2017. 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 Lesser 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 Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser 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 System.ComponentModel; +using System.Linq; +using Core.Common.Gui.Converters; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; + +namespace Core.Common.Gui.Test.Converters +{ + [TestFixture] + public class KeyValueExpandableArrayConverterTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var converter = new KeyValueExpandableArrayConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void ConvertTo_FromArrayToString_ReturnCountText() + { + // Setup + int arrayCount = new Random(21).Next(0, 10); + + var sourceArray = new int[arrayCount]; + var converter = new KeyValueExpandableArrayConverter(); + + // Call + object text = converter.ConvertTo(sourceArray, typeof(string)); + + // Assert + Assert.AreEqual($"Aantal ({arrayCount})", text); + } + + [Test] + public void ConvertTo_FromNullToString_ReturnEmptyText() + { + // Setup + var converter = new KeyValueExpandableArrayConverter(); + + // Call + object text = converter.ConvertTo(null, typeof(string)); + + // Assert + Assert.AreEqual(string.Empty, text); + } + + [Test] + public void ConvertTo_FromArrayToInt_ThrowsNotSupportedException() + { + // Setup + var sourceArray = new int[1]; + var converter = new KeyValueExpandableArrayConverter(); + + // Call + TestDelegate call = () => converter.ConvertTo(sourceArray, typeof(int)); + + // Assert + Assert.Throws(call); + } + + [Test] + public void ConvertTo_FromArrayToNull_ThrowsArgumentNullException() + { + // Setup + var sourceArray = new int[2]; + var converter = new KeyValueExpandableArrayConverter(); + + // Call + TestDelegate call = () => converter.ConvertTo(sourceArray, null); + + // Assert + Assert.Throws(call); + } + + [Test] + public void GetProperties_WithoutContext_ThrowsArgumentException() + { + var converter = new KeyValueExpandableArrayConverter(); + + // Call + TestDelegate test = () => converter.GetProperties(new object()); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, + "The KeyValueExpandableArrayConverter can only be used on properties that have the KeyValueElementAttribute defined."); + } + + [Test] + public void GetProperties_WithoutPropertyDescriptor_ThrowsArgumentException() + { + var mocks = new MockRepository(); + var context = mocks.Stub(); + mocks.ReplayAll(); + + var converter = new KeyValueExpandableArrayConverter(); + + // Call + TestDelegate test = () => converter.GetProperties(context, new object()); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, + "The KeyValueExpandableArrayConverter can only be used on properties that have the KeyValueElementAttribute defined."); + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_WithoutKeyValueElementAttribute_ThrowsArgumentException() + { + var mocks = new MockRepository(); + var context = mocks.Stub(); + var descriptor = mocks.Stub("name", new Attribute[0]); + context.Stub(c => c.PropertyDescriptor).Return(descriptor); + mocks.ReplayAll(); + + var converter = new KeyValueExpandableArrayConverter(); + + // Call + TestDelegate test = () => converter.GetProperties(context, new object()); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage( + test, + "The KeyValueExpandableArrayConverter can only be used on properties that have the KeyValueElementAttribute defined."); + mocks.VerifyAll(); + } + + [Test] + [TestCase(0)] + [TestCase(1)] + [TestCase(12)] + public void GetProperties_FromArray_ReturnPropertyDescriptorsForEachElementWithNameToOneBasedIndex(int elementCount) + { + // Setup + var attribute = new KeyValueElementAttribute(nameof(TestObject.Name), nameof(TestObject.Value)); + var attributes = new AttributeCollection(attribute); + + var mocks = new MockRepository(); + var context = mocks.Stub(); + var descriptor = mocks.Stub("name", new Attribute[0]); + descriptor.Stub(d => d.Attributes).Return(attributes); + context.Stub(c => c.PropertyDescriptor).Return(descriptor); + mocks.ReplayAll(); + + const string name = "name"; + const string value = "value"; + TestObject[] array = Enumerable.Repeat(new TestObject + { + Name = name, + Value = value + }, elementCount).ToArray(); + + var converter = new KeyValueExpandableArrayConverter(); + + // Call + PropertyDescriptorCollection propertyDescriptors = converter.GetProperties(context, array); + + // Assert + Assert.IsNotNull(propertyDescriptors); + Assert.AreEqual(elementCount, propertyDescriptors.Count); + for (var i = 0; i < elementCount; i++) + { + Assert.AreEqual(typeof(TestObject), propertyDescriptors[i].ComponentType); + Assert.AreEqual(name, propertyDescriptors[i].Name); + Assert.AreEqual(name, propertyDescriptors[i].DisplayName); + Assert.AreEqual(value.GetType(), propertyDescriptors[i].PropertyType); + CollectionAssert.IsEmpty(propertyDescriptors[i].Attributes); + + var actualValue = propertyDescriptors[i].GetValue(array) as string; + Assert.NotNull(actualValue); + Assert.AreEqual(value, actualValue); + } + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_FromArray_SettingValuesShouldThrowNotSupportedException() + { + // Setup + var attribute = new KeyValueElementAttribute(nameof(TestObject.Name), nameof(TestObject.Value)); + var attributes = new AttributeCollection(attribute); + + var mocks = new MockRepository(); + var context = mocks.Stub(); + var descriptor = mocks.Stub("name", new Attribute[0]); + descriptor.Stub(d => d.Attributes).Return(attributes); + context.Stub(c => c.PropertyDescriptor).Return(descriptor); + mocks.ReplayAll(); + + const int elementCount = 12; + TestObject[] array = Enumerable.Repeat(new TestObject + { + Name = "some name" + }, elementCount).ToArray(); + + var converter = new KeyValueExpandableArrayConverter(); + + // Call + PropertyDescriptorCollection propertyDescriptors = converter.GetProperties(context, array); + + // Assert + for (var i = 0; i < elementCount; i++) + { + Assert.Throws(() => propertyDescriptors[i].SetValue(array, i)); + } + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_IncorrectAttributeNamePropertyName_ThrowsArgumentException() + { + // Setup + var attribute = new KeyValueElementAttribute("IDoNotExist", nameof(TestObject.Value)); + var attributes = new AttributeCollection(attribute); + + var mocks = new MockRepository(); + var context = mocks.Stub(); + var descriptor = mocks.Stub("name", new Attribute[0]); + descriptor.Stub(d => d.Attributes).Return(attributes); + context.Stub(c => c.PropertyDescriptor).Return(descriptor); + mocks.ReplayAll(); + + const int elementCount = 12; + TestObject[] array = Enumerable.Repeat(new TestObject + { + Name = "some name" + }, elementCount).ToArray(); + + var converter = new KeyValueExpandableArrayConverter(); + + // Call + TestDelegate test = () => converter.GetProperties(context, array); + + // Assert + Assert.Throws(test); + } + + [Test] + public void GetProperties_IncorrectAttributeValuePropertyName_ThrowsArgumentException() + { + // Setup + var attribute = new KeyValueElementAttribute(nameof(TestObject.Name), "IDoNotExist"); + var attributes = new AttributeCollection(attribute); + + var mocks = new MockRepository(); + var context = mocks.Stub(); + var descriptor = mocks.Stub("name", new Attribute[0]); + descriptor.Stub(d => d.Attributes).Return(attributes); + context.Stub(c => c.PropertyDescriptor).Return(descriptor); + mocks.ReplayAll(); + + const int elementCount = 12; + TestObject[] array = Enumerable.Repeat(new TestObject + { + Name = "some name" + }, elementCount).ToArray(); + + var converter = new KeyValueExpandableArrayConverter(); + + // Call + TestDelegate test = () => converter.GetProperties(context, array); + + // Assert + Assert.Throws(test); + } + + private class TestObject + { + public string Name { get; set; } + public string Value { get; set; } + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj =================================================================== diff -u -r9a63232347559e0dceb413fd38d7b87258807910 -rca27aee933103177a29a8d2ab46e127dbb8bacf6 --- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision 9a63232347559e0dceb413fd38d7b87258807910) +++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision ca27aee933103177a29a8d2ab46e127dbb8bacf6) @@ -93,6 +93,8 @@ + + Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs =================================================================== diff -u -r2b62d771a30ac4a3a59b52efc9df88afbc6663b2 -rca27aee933103177a29a8d2ab46e127dbb8bacf6 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs (.../HydraulicBoundaryLocationProperties.cs) (revision 2b62d771a30ac4a3a59b52efc9df88afbc6663b2) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/HydraulicBoundaryLocationProperties.cs (.../HydraulicBoundaryLocationProperties.cs) (revision ca27aee933103177a29a8d2ab46e127dbb8bacf6) @@ -163,11 +163,12 @@ [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_AlphaValues_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_AlphaValues_Description))] [TypeConverter(typeof(KeyValueExpandableArrayConverter))] - public KeyValueExpandableArrayElement[] AlphaValues + [KeyValueElement(nameof(Stochast.Name), nameof(Stochast.Alpha))] + public Stochast[] AlphaValues { get { - return GetGeneralIllustrationPointsResult().Stochasts.Select(s => new KeyValueExpandableArrayElement(s.Name, s.Alpha)).ToArray(); + return GetGeneralIllustrationPointsResult().Stochasts.ToArray(); } } @@ -177,11 +178,12 @@ [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Durations_DisplayName))] [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Durations_Description))] [TypeConverter(typeof(KeyValueExpandableArrayConverter))] - public KeyValueExpandableArrayElement[] Durations + [KeyValueElement(nameof(Stochast.Name), nameof(Stochast.Duration))] + public Stochast[] Durations { get { - return GetGeneralIllustrationPointsResult().Stochasts.Select(s => new KeyValueExpandableArrayElement(s.Name, s.Duration)).ToArray(); + return GetGeneralIllustrationPointsResult().Stochasts.ToArray(); } }