Index: Core/Common/src/Core.Common.Gui/Attributes/DynamicReadOnlyAttribute.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Attributes/DynamicReadOnlyAttribute.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Attributes/DynamicReadOnlyAttribute.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,61 @@ +using System; +using System.ComponentModel; + +using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; + +namespace Core.Common.Gui.Attributes +{ + /// + /// Marks property as a conditional read-only property. When this attribute is declared + /// on a property, the declaring a class should have a public method marked with + /// to be used to evaluate if + /// that property should be read-only or not. + /// + /// + /// + /// This attribute provides a run-time alternative to . + [AttributeUsage(AttributeTargets.Property)] + public sealed class DynamicReadOnlyAttribute : Attribute + { + /// + /// Determines whether the property is read-only or not. + /// + /// The object. + /// Name of the property of . + /// True if the property is read-only, false otherwise. + /// + /// does not correspond to a public property of . + /// When there isn't a single method + /// declared on marked with + /// and/or isn't matching the signature defined by . + public static bool IsReadOnly(object obj, string propertyName) + { + if (string.IsNullOrEmpty(propertyName)) + { + return ReadOnlyAttribute.Default.IsReadOnly; + } + + var isDynamicReadOnlyProperty = PropertyIsDynamicallyReadOnly(obj, propertyName); + if (!isDynamicReadOnlyProperty) + { + return ReadOnlyAttribute.Default.IsReadOnly; + } + + var isPropertyReadOnlyDelegate = DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(obj); + + return isPropertyReadOnlyDelegate(propertyName); + } + + private static bool PropertyIsDynamicallyReadOnly(object obj, string propertyName) + { + var propertyInfo = obj.GetType().GetProperty(propertyName); + if (propertyInfo == null) + { + throw new MissingMemberException(string.Format(CoreCommonGuiResources.Could_not_find_property_0_on_type_1_, propertyName, + obj.GetType())); + } + + return IsDefined(propertyInfo, typeof(DynamicReadOnlyAttribute)); + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Attributes/DynamicReadOnlyValidationMethodAttribute.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Attributes/DynamicReadOnlyValidationMethodAttribute.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Attributes/DynamicReadOnlyValidationMethodAttribute.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,92 @@ +using System; +using System.Linq; +using System.Reflection; + +using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; + +namespace Core.Common.Gui.Attributes +{ + /// + /// Marks a method to be used to determine if a property value can be set or not. The + /// method should be public and have the signature of . + /// + /// + [AttributeUsage(AttributeTargets.Method)] + public sealed class DynamicReadOnlyValidationMethodAttribute : Attribute + { + /// + /// Required method signature when marking a method with . + /// + /// Name of the property to be checked. + /// True if the referred property should be read-only, false if it should be editable. + public delegate bool IsPropertyReadOnly(string propertyName); + + /// + /// Creates a delegate that can be used to determine if a property should be read-only. + /// + /// The object instance declaring the validation method. + /// The delegate. + /// When there isn't a single method + /// declared on marked with + /// and/or isn't matching the signature defined by . + public static IsPropertyReadOnly CreateIsReadOnlyMethod(object target) + { + var methodInfo = GetIsReadOnlyMethod(target); + ValidateMethodInfo(methodInfo); + return CreateIsPropertyReadOnlyDelegate(target, methodInfo); + } + + private static IsPropertyReadOnly CreateIsPropertyReadOnlyDelegate(object target, MethodInfo methodInfo) + { + return (IsPropertyReadOnly) Delegate.CreateDelegate(typeof(IsPropertyReadOnly), target, methodInfo); + } + + private static void ValidateMethodInfo(MethodInfo methodInfo) + { + if (methodInfo.ReturnType != typeof(bool)) + { + var message = String.Format(CoreCommonGuiResources.DynamicReadOnlyValidationMethod_must_return_bool_on_Class_0_, + methodInfo.DeclaringType); + throw new MissingMethodException(message); + } + + ParameterInfo[] parameterInfos = methodInfo.GetParameters(); + if (parameterInfos.Length != 1) + { + var message = String.Format(CoreCommonGuiResources.DynamicReadOnlyValidationMethod_incorrect_argument_count_must_be_one_string_argument_on_Class_0_, + methodInfo.DeclaringType); + throw new MissingMethodException(message); + } + + if (parameterInfos[0].ParameterType != typeof(string)) + { + var message = String.Format(CoreCommonGuiResources.DynamicReadOnlyValidationMethod_must_have_string_argument_on_Class_0_, + methodInfo.DeclaringType); + throw new MissingMethodException(message); + } + } + + private static MethodInfo GetIsReadOnlyMethod(object obj) + { + var validationMethods = obj.GetType().GetMethods() + .Where(methodInfo => IsDefined(methodInfo, typeof(DynamicReadOnlyValidationMethodAttribute))) + .ToArray(); + + if (validationMethods.Length == 0) + { + var message = String.Format(CoreCommonGuiResources.DynamicReadOnlyValidationMethod_not_found_or_not_public_on_Class_0_, + obj.GetType()); + throw new MissingMethodException(message); + } + + if (validationMethods.Length > 1) + { + var message = String.Format(CoreCommonGuiResources.DynamicReadOnlyValidationMethod_only_one_allowed_per_Class_0_, + obj.GetType()); + throw new MissingMethodException(message); + } + + return validationMethods[0]; + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Attributes/DynamicVisibleAttribute.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Attributes/DynamicVisibleAttribute.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Attributes/DynamicVisibleAttribute.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,61 @@ +using System; +using System.ComponentModel; + +using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; + +namespace Core.Common.Gui.Attributes +{ + /// + /// Marks property as a conditional visible property. When this attribute is declared + /// on a property, the declaring a class should have a public method marked with + /// to be used to evaluate if + /// that property should be visible or not. + /// + /// + /// + /// This attribute provides a run-time alternative to . + [AttributeUsage(AttributeTargets.Property)] + public sealed class DynamicVisibleAttribute : Attribute + { + /// + /// Determines whether the property is visible or not. + /// + /// The object. + /// Name of the property of . + /// True if the property is visible, false otherwise. + /// + /// does not correspond to a public property of . + /// When there isn't a single method + /// declared on marked with + /// and/or isn't matching the signature defined by . + public static bool IsVisible(object obj, string propertyName) + { + if (string.IsNullOrEmpty(propertyName)) + { + return BrowsableAttribute.Default.Browsable; + } + + var isPropertyWithDynamicVisibility = PropertyIsDynamicallyVisible(obj, propertyName); + if (!isPropertyWithDynamicVisibility) + { + return BrowsableAttribute.Default.Browsable; + } + + var isPropertyVisibleDelegate = DynamicVisibleValidationMethodAttribute.CreateIsVisibleMethod(obj); + + return isPropertyVisibleDelegate(propertyName); + } + + private static bool PropertyIsDynamicallyVisible(object obj, string propertyName) + { + var propertyInfo = obj.GetType().GetProperty(propertyName); + if (propertyInfo == null) + { + throw new MissingMemberException(string.Format(CoreCommonGuiResources.Could_not_find_property_0_on_type_1_, propertyName, + obj.GetType())); + } + + return IsDefined(propertyInfo, typeof(DynamicVisibleAttribute)); + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Attributes/DynamicVisibleValidationMethodAttribute.cs =================================================================== diff -u --- Core/Common/src/Core.Common.Gui/Attributes/DynamicVisibleValidationMethodAttribute.cs (revision 0) +++ Core/Common/src/Core.Common.Gui/Attributes/DynamicVisibleValidationMethodAttribute.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,92 @@ +using System; +using System.Linq; +using System.Reflection; + +using CoreCommonGuiResources = Core.Common.Gui.Properties.Resources; + +namespace Core.Common.Gui.Attributes +{ + /// + /// Marks a method to be used to determine if a property should be shown or not. The + /// method should be public and have the signature of . + /// + /// + [AttributeUsage(AttributeTargets.Method)] + public sealed class DynamicVisibleValidationMethodAttribute : Attribute + { + /// + /// Required method signature when marking a method with . + /// + /// Name of the property to be checked. + /// True if the referred property should be visible, false if it should be hidden. + public delegate bool IsPropertyVisible(string propertyName); + + /// + /// Creates a delegate that can be used to determine if a property should be visible. + /// + /// The object instance declaring the validation method. + /// The delegate. + /// When there isn't a single method + /// declared on marked with + /// and/or isn't matching the signature defined by . + public static IsPropertyVisible CreateIsVisibleMethod(object target) + { + var methodInfo = GetIsVisibleMethod(target); + ValidateMethodInfo(methodInfo); + return CreateIsPropertyVisibleDelegate(target, methodInfo); + } + + private static IsPropertyVisible CreateIsPropertyVisibleDelegate(object target, MethodInfo methodInfo) + { + return (IsPropertyVisible)Delegate.CreateDelegate(typeof(IsPropertyVisible), target, methodInfo); + } + + private static void ValidateMethodInfo(MethodInfo methodInfo) + { + if (methodInfo.ReturnType != typeof(bool)) + { + var message = String.Format(CoreCommonGuiResources.DynamicVisibleValidationMethod_must_return_bool_on_Class_0_, + methodInfo.DeclaringType); + throw new MissingMethodException(message); + } + + ParameterInfo[] parameterInfos = methodInfo.GetParameters(); + if (parameterInfos.Length != 1) + { + var message = String.Format(CoreCommonGuiResources.DynamicVisibleValidationMethod_incorrect_argument_count_must_be_one_string_argument_on_Class_0_, + methodInfo.DeclaringType); + throw new MissingMethodException(message); + } + + if (parameterInfos[0].ParameterType != typeof(string)) + { + var message = String.Format(CoreCommonGuiResources.DynamicVisibleValidationMethod_must_have_string_argument_on_Class_0_, + methodInfo.DeclaringType); + throw new MissingMethodException(message); + } + } + + private static MethodInfo GetIsVisibleMethod(object obj) + { + var validationMethods = obj.GetType().GetMethods() + .Where(methodInfo => IsDefined(methodInfo, typeof(DynamicVisibleValidationMethodAttribute))) + .ToArray(); + + if (validationMethods.Length == 0) + { + var message = String.Format(CoreCommonGuiResources.DynamicVisibleValidationMethod_not_found_or_not_public_on_Class_0_, + obj.GetType()); + throw new MissingMethodException(message); + } + + if (validationMethods.Length > 1) + { + var message = String.Format(CoreCommonGuiResources.DynamicVisibleValidationMethod_only_one_allowed_per_Class_0_, + obj.GetType()); + throw new MissingMethodException(message); + } + + return validationMethods[0]; + } + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj =================================================================== diff -u -rcd9655d356bdff388c7058eeff1cdbed076c407b -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision cd9655d356bdff388c7058eeff1cdbed076c407b) +++ Core/Common/src/Core.Common.Gui/Core.Common.Gui.csproj (.../Core.Common.Gui.csproj) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -114,6 +114,10 @@ + + + + Index: Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs =================================================================== diff -u -r844b6342be08ffe7faa053883960c09f6e46fafa -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 844b6342be08ffe7faa053883960c09f6e46fafa) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -616,6 +616,15 @@ } /// + /// Looks up a localized string similar to Kon eigenschap {0} van type {1} niet vinden.. + /// + public static string Could_not_find_property_0_on_type_1_ { + get { + return ResourceManager.GetString("Could_not_find_property_0_on_type_1_", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap cross_small { @@ -753,6 +762,98 @@ } /// + /// Looks up a localized string similar to DynamicReadOnlyValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}.. + /// + public static string DynamicReadOnlyValidationMethod_incorrect_argument_count_must_be_one_string_argument_on_Class_0_ { + get { + return ResourceManager.GetString("DynamicReadOnlyValidationMethod_incorrect_argument_count_must_be_one_string_argum" + + "ent_on_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Argument van DynamicReadOnlyValidationMethod moet van het type 'string' zijn. Klasse: {0}.. + /// + public static string DynamicReadOnlyValidationMethod_must_have_string_argument_on_Class_0_ { + get { + return ResourceManager.GetString("DynamicReadOnlyValidationMethod_must_have_string_argument_on_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to DynamicReadOnlyValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}.. + /// + public static string DynamicReadOnlyValidationMethod_must_return_bool_on_Class_0_ { + get { + return ResourceManager.GetString("DynamicReadOnlyValidationMethod_must_return_bool_on_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to DynamicReadOnlyValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}.. + /// + public static string DynamicReadOnlyValidationMethod_not_found_or_not_public_on_Class_0_ { + get { + return ResourceManager.GetString("DynamicReadOnlyValidationMethod_not_found_or_not_public_on_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slechts één DynamicReadOnlyValidationMethod toegestaan per klasse: {0}.. + /// + public static string DynamicReadOnlyValidationMethod_only_one_allowed_per_Class_0_ { + get { + return ResourceManager.GetString("DynamicReadOnlyValidationMethod_only_one_allowed_per_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to DynamicVisibleValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}.. + /// + public static string DynamicVisibleValidationMethod_incorrect_argument_count_must_be_one_string_argument_on_Class_0_ { + get { + return ResourceManager.GetString("DynamicVisibleValidationMethod_incorrect_argument_count_must_be_one_string_argume" + + "nt_on_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Argument van DynamicVisibleValidationMethod moet van het type 'string' zijn. Klasse: {0}.. + /// + public static string DynamicVisibleValidationMethod_must_have_string_argument_on_Class_0_ { + get { + return ResourceManager.GetString("DynamicVisibleValidationMethod_must_have_string_argument_on_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to DynamicVisibleValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}.. + /// + public static string DynamicVisibleValidationMethod_must_return_bool_on_Class_0_ { + get { + return ResourceManager.GetString("DynamicVisibleValidationMethod_must_return_bool_on_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to DynamicVisibleValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}.. + /// + public static string DynamicVisibleValidationMethod_not_found_or_not_public_on_Class_0_ { + get { + return ResourceManager.GetString("DynamicVisibleValidationMethod_not_found_or_not_public_on_Class_0_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Slechts één DynamicVisibleValidationMethod toegestaan per klasse: {0}.. + /// + public static string DynamicVisibleValidationMethod_only_one_allowed_per_Class_0_ { + get { + return ResourceManager.GetString("DynamicVisibleValidationMethod_only_one_allowed_per_Class_0_", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap edit_redo { Index: Core/Common/src/Core.Common.Gui/Properties/Resources.resx =================================================================== diff -u -r844b6342be08ffe7faa053883960c09f6e46fafa -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision 844b6342be08ffe7faa053883960c09f6e46fafa) +++ Core/Common/src/Core.Common.Gui/Properties/Resources.resx (.../Resources.resx) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -916,4 +916,37 @@ ..\resources\textfield_rename.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Kon eigenschap {0} van type {1} niet vinden. + + + DynamicReadOnlyValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}. + + + Argument van DynamicReadOnlyValidationMethod moet van het type 'string' zijn. Klasse: {0}. + + + DynamicReadOnlyValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}. + + + DynamicReadOnlyValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}. + + + Slechts één DynamicReadOnlyValidationMethod toegestaan per klasse: {0}. + + + DynamicVisibleValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}. + + + Argument van DynamicVisibleValidationMethod moet van het type 'string' zijn. Klasse: {0}. + + + DynamicVisibleValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}. + + + DynamicVisibleValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}. + + + Slechts één DynamicVisibleValidationMethod toegestaan per klasse: {0}. + \ No newline at end of file Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Utils/Attributes/DynamicReadOnlyAttribute.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Utils/Attributes/DynamicReadOnlyValidationMethodAttribute.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Utils/Attributes/DynamicVisibleAttribute.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/src/Core.Common.Utils/Attributes/DynamicVisibleValidationMethodAttribute.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj =================================================================== diff -u -rcd9655d356bdff388c7058eeff1cdbed076c407b -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj (.../Core.Common.Utils.csproj) (revision cd9655d356bdff388c7058eeff1cdbed076c407b) +++ Core/Common/src/Core.Common.Utils/Core.Common.Utils.csproj (.../Core.Common.Utils.csproj) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -87,10 +87,6 @@ Properties\GlobalAssembly.cs - - - - Index: Core/Common/src/Core.Common.Utils/Properties/Resource.Designer.cs =================================================================== diff -u -rb443ebc25f4853fa10df2a68d3fedab32c8e84f3 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Common/src/Core.Common.Utils/Properties/Resource.Designer.cs (.../Resource.Designer.cs) (revision b443ebc25f4853fa10df2a68d3fedab32c8e84f3) +++ Core/Common/src/Core.Common.Utils/Properties/Resource.Designer.cs (.../Resource.Designer.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -71,107 +71,6 @@ } /// - /// Looks up a localized string similar to Kon eigenschap {0} van type {1} niet vinden.. - /// - internal static string Could_not_find_property_0_on_type_1_ { - get { - return ResourceManager.GetString("Could_not_find_property_0_on_type_1_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DynamicReadOnlyValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}.. - /// - internal static string DynamicReadOnlyValidationMethod_incorrect_argument_count_must_be_one_string_argument_on_Class_0_ { - get { - return ResourceManager.GetString("DynamicReadOnlyValidationMethod_incorrect_argument_count_must_be_one_string_argum" + - "ent_on_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Argument van DynamicReadOnlyValidationMethod moet van het type 'string' zijn. Klasse: {0}.. - /// - internal static string DynamicReadOnlyValidationMethod_must_have_string_argument_on_Class_0_ { - get { - return ResourceManager.GetString("DynamicReadOnlyValidationMethod_must_have_string_argument_on_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DynamicReadOnlyValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}.. - /// - internal static string DynamicReadOnlyValidationMethod_must_return_bool_on_Class_0_ { - get { - return ResourceManager.GetString("DynamicReadOnlyValidationMethod_must_return_bool_on_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DynamicReadOnlyValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}.. - /// - internal static string DynamicReadOnlyValidationMethod_not_found_or_not_public_on_Class_0_ { - get { - return ResourceManager.GetString("DynamicReadOnlyValidationMethod_not_found_or_not_public_on_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Slechts één DynamicReadOnlyValidationMethod toegestaan per klasse: {0}.. - /// - internal static string DynamicReadOnlyValidationMethod_only_one_allowed_per_Class_0_ { - get { - return ResourceManager.GetString("DynamicReadOnlyValidationMethod_only_one_allowed_per_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DynamicVisibleValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}.. - /// - internal static string DynamicVisibleValidationMethod_incorrect_argument_count_must_be_one_string_argument_on_Class_0_ { - get { - return ResourceManager.GetString("DynamicVisibleValidationMethod_incorrect_argument_count_must_be_one_string_argume" + - "nt_on_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Argument van DynamicVisibleValidationMethod moet van het type 'string' zijn. Klasse: {0}.. - /// - internal static string DynamicVisibleValidationMethod_must_have_string_argument_on_Class_0_ { - get { - return ResourceManager.GetString("DynamicVisibleValidationMethod_must_have_string_argument_on_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DynamicVisibleValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}.. - /// - internal static string DynamicVisibleValidationMethod_must_return_bool_on_Class_0_ { - get { - return ResourceManager.GetString("DynamicVisibleValidationMethod_must_return_bool_on_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to DynamicVisibleValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}.. - /// - internal static string DynamicVisibleValidationMethod_not_found_or_not_public_on_Class_0_ { - get { - return ResourceManager.GetString("DynamicVisibleValidationMethod_not_found_or_not_public_on_Class_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Slechts één DynamicVisibleValidationMethod toegestaan per klasse: {0}.. - /// - internal static string DynamicVisibleValidationMethod_only_one_allowed_per_Class_0_ { - get { - return ResourceManager.GetString("DynamicVisibleValidationMethod_only_one_allowed_per_Class_0_", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Parameter 'GroupSize' moet groter zijn dan 0.. /// internal static string EnumerableExtensions_SplitInGroups_GroupSize_must_be_greater_than_0 { Index: Core/Common/src/Core.Common.Utils/Properties/Resource.resx =================================================================== diff -u -rb443ebc25f4853fa10df2a68d3fedab32c8e84f3 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Common/src/Core.Common.Utils/Properties/Resource.resx (.../Resource.resx) (revision b443ebc25f4853fa10df2a68d3fedab32c8e84f3) +++ Core/Common/src/Core.Common.Utils/Properties/Resource.resx (.../Resource.resx) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -126,24 +126,6 @@ Thread synchronisatiefout (aanroep {1}): {0} - - DynamicReadOnlyValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}. - - - Slechts één DynamicReadOnlyValidationMethod toegestaan per klasse: {0}. - - - DynamicReadOnlyValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}. - - - DynamicReadOnlyValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}. - - - Argument van DynamicReadOnlyValidationMethod moet van het type 'string' zijn. Klasse: {0}. - - - Kon eigenschap {0} van type {1} niet vinden. - Geen 'default constructor' gevonden voor type {0}. @@ -174,19 +156,4 @@ '{0}' is geen geldige expressie voor deze methode. - - DynamicVisibleValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}. - - - DynamicVisibleValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}. - - - Argument van DynamicVisibleValidationMethod moet van het type 'string' zijn. Klasse: {0}. - - - DynamicVisibleValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}. - - - Slechts één DynamicVisibleValidationMethod toegestaan per klasse: {0}. - \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicReadOnlyAttributeTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicReadOnlyAttributeTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicReadOnlyAttributeTest.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,157 @@ +using System; + +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Test.Attributes.TestCaseClasses; + +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Attributes +{ + [TestFixture] + public class DynamicReadOnlyAttributeTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var attribute = new DynamicReadOnlyAttribute(); + + // Assert + Assert.IsInstanceOf(attribute); + } + + [Test] + [TestCase("")] + [TestCase(null)] + public void IsReadOnly_NoPropertyName_ReturnFalse(string propertyName) + { + // Call + var isReadOnly = DynamicReadOnlyAttribute.IsReadOnly(new object(), propertyName); + + // Assert + Assert.IsFalse(isReadOnly); + } + + [Test] + public void IsReadOnly_GivenPropertyNameDoesNotExistOnObject_ThrowMissingMemberException() + { + // Setup + var o = new object(); + + // Call + TestDelegate call = () => DynamicReadOnlyAttribute.IsReadOnly(o, "NotExistingProperty"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + Assert.AreEqual(string.Format("Kon eigenschap NotExistingProperty van type {0} niet vinden.", o.GetType()), exceptionMessage); + } + + [Test] + public void IsReadOnly_GivenPropertyDoesNotHaveDynamicReadOnlyAttribute_ReturnFalse() + { + // Setup + var o = new ClassWithPropertyWithoutDynamicReadOnlyAttribute(); + + // Call + var isReadOnly = DynamicReadOnlyAttribute.IsReadOnly(o, "Property"); + + // Assert + Assert.IsFalse(isReadOnly); + } + + [Test] + public void IsReadOnly_ClassLacksDynamicReadOnlyValidationMethod_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyButNoValidationMethod(); + + // Call + TestDelegate call = () => DynamicReadOnlyAttribute.IsReadOnly(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicReadOnlyValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void IsReadOnly_ClassHasMultipleDynamicReadOnlyValidationMethods_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyAndMultipleValidationMethod(); + + // Call + TestDelegate call = () => DynamicReadOnlyAttribute.IsReadOnly(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("Slechts één DynamicReadOnlyValidationMethod toegestaan per klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void IsReadOnly_ClassHasDynamicReadOnlyValidationMethodWithNonBoolReturnType_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyButValidationMethodReturnsIncorrectValueType(); + + // Call + TestDelegate call = () => DynamicReadOnlyAttribute.IsReadOnly(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicReadOnlyValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void IsReadOnly_ClassHasDynamicReadOnlyValidationMethodWithIncorrectArgumentCount_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyButValidationMethodNotOneArgument(); + + // Call + TestDelegate call = () => DynamicReadOnlyAttribute.IsReadOnly(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicReadOnlyValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void IsReadOnly_ClassHasDynamicReadOnlyValidationMethodWithIncorrectArgumentType_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyButValidationMethodArgumentNotString(); + + // Call + TestDelegate call = () => DynamicReadOnlyAttribute.IsReadOnly(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("Argument van DynamicReadOnlyValidationMethod moet van het type 'string' zijn. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + [TestCase(false)] + [TestCase(true)] + public void IsReadOnly_ClassWithDynamicReadOnlyProperty_ReturnResultFromValidationMethod(bool isReadOnly) + { + // Setup + var o = new ClassWithDynamicReadOnlyProperty(isReadOnly); + + // Call + var result = DynamicReadOnlyAttribute.IsReadOnly(o, "Property"); + + // Assert + Assert.AreEqual(isReadOnly, result); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicReadOnlyValidationMethodAttributeTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicReadOnlyValidationMethodAttributeTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicReadOnlyValidationMethodAttributeTest.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,108 @@ +using System; + +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Test.Attributes.TestCaseClasses; + +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Attributes +{ + [TestFixture] + public class DynamicReadOnlyValidationMethodAttributeTest + { + [Test] + public void CreateIsReadOnlyMethod_ClassLacksDynamicReadOnlyValidationMethod_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyButNoValidationMethod(); + + // Call + TestDelegate call = () => DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicReadOnlyValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void CreateIsReadOnlyMethod_ClassHasMultipleDynamicReadOnlyValidationMethods_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyAndMultipleValidationMethod(); + + // Call + TestDelegate call = () => DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("Slechts één DynamicReadOnlyValidationMethod toegestaan per klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void CreateIsReadOnlyMethod_ClassHasDynamicReadOnlyValidationMethodWithNonBoolReturnType_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyButValidationMethodReturnsIncorrectValueType(); + + // Call + TestDelegate call = () => DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicReadOnlyValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void CreateIsReadOnlyMethod_ClassHasDynamicReadOnlyValidationMethodWithIncorrectArgumentCount_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyButValidationMethodNotOneArgument(); + + // Call + TestDelegate call = () => DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicReadOnlyValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void CreateIsReadOnlyMethod_ClassHasDynamicReadOnlyValidationMethodWithIncorrectArgumentType_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicReadOnlyPropertyButValidationMethodArgumentNotString(); + + // Call + TestDelegate call = () => DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("Argument van DynamicReadOnlyValidationMethod moet van het type 'string' zijn. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + [TestCase(false)] + [TestCase(true)] + public void CreateIsReadOnlyMethod_ClassWithDynamicReadOnlyProperty_ReturnResultFromValidationMethod(bool isReadOnly) + { + // Setup + var o = new ClassWithDynamicReadOnlyProperty(isReadOnly); + + // Call + var result = DynamicReadOnlyValidationMethodAttribute.CreateIsReadOnlyMethod(o); + + // Assert + Assert.AreEqual(isReadOnly, result("Property")); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicVisibleAttributeTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicVisibleAttributeTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicVisibleAttributeTest.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,157 @@ +using System; + +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Test.Attributes.TestCaseClasses; + +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Attributes +{ + [TestFixture] + public class DynamicVisibleAttributeTest + { + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Call + var attribute = new DynamicVisibleAttribute(); + + // Assert + Assert.IsInstanceOf(attribute); + } + + [Test] + [TestCase("")] + [TestCase(null)] + public void IsVisible_NoPropertyName_ReturnTrue(string propertyName) + { + // Call + var isReadOnly = DynamicVisibleAttribute.IsVisible(new object(), propertyName); + + // Assert + Assert.IsTrue(isReadOnly); + } + + [Test] + public void IsVisible_GivenPropertyNameDoesNotExistOnObject_ThrowMissingMemberException() + { + // Setup + var o = new object(); + + // Call + TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "NotExistingProperty"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + Assert.AreEqual(string.Format("Kon eigenschap NotExistingProperty van type {0} niet vinden.", o.GetType()), exceptionMessage); + } + + [Test] + public void IsVisible_GivenPropertyDoesNotHaveDynamicVisibleAttribute_ReturnTrue() + { + // Setup + var o = new ClassWithPropertyWithoutDynamicVisibleAttribute(); + + // Call + var isReadOnly = DynamicVisibleAttribute.IsVisible(o, "Property"); + + // Assert + Assert.IsTrue(isReadOnly); + } + + [Test] + public void IsVisible_ClassLacksDynamicVisibleValidationMethod_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyButNoValidationMethod(); + + // Call + TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicVisibleValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void IsVisible_ClassHasMultipleDynamicVisibleValidationMethods_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyAndMultipleValidationMethod(); + + // Call + TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("Slechts één DynamicVisibleValidationMethod toegestaan per klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void IsVisible_ClassHasDynamicVisibleValidationMethodWithNonBoolReturnType_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodReturnsIncorrectValueType(); + + // Call + TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicVisibleValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void IsVisible_ClassHasDynamicVisibleValidationMethodWithIncorrectArgumentCount_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodNotOneArgument(); + + // Call + TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicVisibleValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void IsVisible_ClassHasDynamicVisibleValidationMethodWithIncorrectArgumentType_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodArgumentNotString(); + + // Call + TestDelegate call = () => DynamicVisibleAttribute.IsVisible(o, "Property"); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("Argument van DynamicVisibleValidationMethod moet van het type 'string' zijn. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + [TestCase(false)] + [TestCase(true)] + public void IsVisible_ClassWithDynamicVisibleProperty_ReturnResultFromValidationMethod(bool isReadOnly) + { + // Setup + var o = new ClassWithDynamicVisibleProperty(isReadOnly); + + // Call + var result = DynamicVisibleAttribute.IsVisible(o, "Property"); + + // Assert + Assert.AreEqual(isReadOnly, result); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicVisibleValidationMethodAttributeTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicVisibleValidationMethodAttributeTest.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Attributes/DynamicVisibleValidationMethodAttributeTest.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,108 @@ +using System; + +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Test.Attributes.TestCaseClasses; + +using NUnit.Framework; + +namespace Core.Common.Gui.Test.Attributes +{ + [TestFixture] + public class DynamicVisibleValidationMethodAttributeTest + { + [Test] + public void CreateIsVisibleMethod_ClassLacksDynamicVisibleValidationMethod_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyButNoValidationMethod(); + + // Call + TestDelegate call = () => DynamicVisibleValidationMethodAttribute.CreateIsVisibleMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicVisibleValidationMethod niet gevonden (of geen 'public' toegankelijkheid). Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void CreateIsVisibleMethod_ClassHasMultipleDynamicVisibleValidationMethods_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyAndMultipleValidationMethod(); + + // Call + TestDelegate call = () => DynamicVisibleValidationMethodAttribute.CreateIsVisibleMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("Slechts één DynamicVisibleValidationMethod toegestaan per klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void CreateIsVisibleMethod_ClassHasDynamicVisibleValidationMethodWithNonBoolReturnType_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodReturnsIncorrectValueType(); + + // Call + TestDelegate call = () => DynamicVisibleValidationMethodAttribute.CreateIsVisibleMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicVisibleValidationMethod moet 'bool' als 'return type' hebben. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void CreateIsVisibleMethod_ClassHasDynamicVisibleValidationMethodWithIncorrectArgumentCount_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodNotOneArgument(); + + // Call + TestDelegate call = () => DynamicVisibleValidationMethodAttribute.CreateIsVisibleMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("DynamicVisibleValidationMethod heeft een incorrect aantal argumenten. Zou er één moeten zijn. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + public void CreateIsVisibleMethod_ClassHasDynamicVisibleValidationMethodWithIncorrectArgumentType_ThrowsMissingMethodException() + { + // Setup + var o = new InvalidClassWithDynamicVisiblePropertyButValidationMethodArgumentNotString(); + + // Call + TestDelegate call = () => DynamicVisibleValidationMethodAttribute.CreateIsVisibleMethod(o); + + // Assert + var exceptionMessage = Assert.Throws(call).Message; + var expectedMessage = string.Format("Argument van DynamicVisibleValidationMethod moet van het type 'string' zijn. Klasse: {0}.", + o.GetType()); + Assert.AreEqual(expectedMessage, exceptionMessage); + } + + [Test] + [TestCase(false)] + [TestCase(true)] + public void CreateIsVisibleMethod_ClassWithDynamicVisibleProperty_ReturnResultFromValidationMethod(bool isReadOnly) + { + // Setup + var o = new ClassWithDynamicVisibleProperty(isReadOnly); + + // Call + var result = DynamicVisibleValidationMethodAttribute.CreateIsVisibleMethod(o); + + // Assert + Assert.AreEqual(isReadOnly, result("Property")); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Attributes/TestCaseClasses/DynamicReadOnlyTestCases.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Attributes/TestCaseClasses/DynamicReadOnlyTestCases.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Attributes/TestCaseClasses/DynamicReadOnlyTestCases.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,88 @@ +using Core.Common.Gui.Attributes; + +namespace Core.Common.Gui.Test.Attributes.TestCaseClasses +{ + internal class ClassWithPropertyWithoutDynamicReadOnlyAttribute + { + public double Property { get; set; } + } + + internal class InvalidClassWithDynamicReadOnlyPropertyButNoValidationMethod + { + [DynamicReadOnly] + public double Property { get; set; } + } + + internal class InvalidClassWithDynamicReadOnlyPropertyAndMultipleValidationMethod + { + [DynamicReadOnly] + public double Property { get; set; } + + [DynamicReadOnlyValidationMethod] + public bool IsDynamicReadOnly1(string propertyName) + { + return true; + } + + [DynamicReadOnlyValidationMethod] + public bool IsDynamicReadOnly2(string propertyName) + { + return false; + } + } + + internal class InvalidClassWithDynamicReadOnlyPropertyButValidationMethodReturnsIncorrectValueType + { + [DynamicReadOnly] + public double Property { get; set; } + + [DynamicReadOnlyValidationMethod] + public int IsDynamicReadOnly(string propertyName) + { + return 0; + } + } + + internal class InvalidClassWithDynamicReadOnlyPropertyButValidationMethodNotOneArgument + { + [DynamicReadOnly] + public double Property { get; set; } + + [DynamicReadOnlyValidationMethod] + public bool IsDynamicReadOnly(object o, string propertyName) + { + return true; + } + } + + internal class InvalidClassWithDynamicReadOnlyPropertyButValidationMethodArgumentNotString + { + [DynamicReadOnly] + public double Property { get; set; } + + [DynamicReadOnlyValidationMethod] + public bool IsDynamicReadOnly(object o) + { + return true; + } + } + + internal class ClassWithDynamicReadOnlyProperty + { + private readonly bool isReadOnly; + + public ClassWithDynamicReadOnlyProperty(bool isReadOnly) + { + this.isReadOnly = isReadOnly; + } + + [DynamicReadOnly] + public double Property { get; set; } + + [DynamicReadOnlyValidationMethod] + public bool IsDynamicReadOnly(string propertyName) + { + return isReadOnly; + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Attributes/TestCaseClasses/DynamicVisibilityTestCases.cs =================================================================== diff -u --- Core/Common/test/Core.Common.Gui.Test/Attributes/TestCaseClasses/DynamicVisibilityTestCases.cs (revision 0) +++ Core/Common/test/Core.Common.Gui.Test/Attributes/TestCaseClasses/DynamicVisibilityTestCases.cs (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -0,0 +1,88 @@ +using Core.Common.Gui.Attributes; + +namespace Core.Common.Gui.Test.Attributes.TestCaseClasses +{ + internal class ClassWithPropertyWithoutDynamicVisibleAttribute + { + public double Property { get; set; } + } + + internal class InvalidClassWithDynamicVisiblePropertyButNoValidationMethod + { + [DynamicVisible] + public double Property { get; set; } + } + + internal class InvalidClassWithDynamicVisiblePropertyAndMultipleValidationMethod + { + [DynamicVisible] + public double Property { get; set; } + + [DynamicVisibleValidationMethod] + public bool IsDynamicReadOnly1(string propertyName) + { + return true; + } + + [DynamicVisibleValidationMethod] + public bool IsDynamicReadOnly2(string propertyName) + { + return false; + } + } + + internal class InvalidClassWithDynamicVisiblePropertyButValidationMethodReturnsIncorrectValueType + { + [DynamicVisible] + public double Property { get; set; } + + [DynamicVisibleValidationMethod] + public int IsDynamicReadOnly(string propertyName) + { + return 0; + } + } + + internal class InvalidClassWithDynamicVisiblePropertyButValidationMethodNotOneArgument + { + [DynamicVisible] + public double Property { get; set; } + + [DynamicVisibleValidationMethod] + public bool IsDynamicReadOnly(object o, string propertyName) + { + return true; + } + } + + internal class InvalidClassWithDynamicVisiblePropertyButValidationMethodArgumentNotString + { + [DynamicVisible] + public double Property { get; set; } + + [DynamicVisibleValidationMethod] + public bool IsDynamicReadOnly(object o) + { + return true; + } + } + + internal class ClassWithDynamicVisibleProperty + { + private readonly bool isVisible; + + public ClassWithDynamicVisibleProperty(bool isVisible) + { + this.isVisible = isVisible; + } + + [DynamicVisible] + public double Property { get; set; } + + [DynamicVisibleValidationMethod] + public bool IsDynamicVisible(string propertyName) + { + return isVisible; + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj =================================================================== diff -u -rcd9655d356bdff388c7058eeff1cdbed076c407b -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision cd9655d356bdff388c7058eeff1cdbed076c407b) +++ Core/Common/test/Core.Common.Gui.Test/Core.Common.Gui.Test.csproj (.../Core.Common.Gui.Test.csproj) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -49,7 +49,13 @@ + + + + + + Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Utils.Test/Attributes/DynamicReadOnlyAttributeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Utils.Test/Attributes/DynamicReadOnlyValidationMethodAttributeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Utils.Test/Attributes/DynamicVisibleAttributeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Utils.Test/Attributes/DynamicVisibleValidationMethodAttributeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Utils.Test/Attributes/TestCaseClasses/DynamicReadOnlyTestCases.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag b92517dbc9956b930a6cfc7f96a1f762dfa41cf6 refers to a dead (removed) revision in file `Core/Common/test/Core.Common.Utils.Test/Attributes/TestCaseClasses/DynamicVisibilityTestCases.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj =================================================================== diff -u -rcd9655d356bdff388c7058eeff1cdbed076c407b -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj (.../Core.Common.Utils.Test.csproj) (revision cd9655d356bdff388c7058eeff1cdbed076c407b) +++ Core/Common/test/Core.Common.Utils.Test/Core.Common.Utils.Test.csproj (.../Core.Common.Utils.Test.csproj) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -85,13 +85,7 @@ - - - - - - Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/GroupLayerProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/GroupLayerProperties.cs (.../GroupLayerProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/GroupLayerProperties.cs (.../GroupLayerProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,4 +1,5 @@ using Core.Common.Gui; +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Layers; using Core.Plugins.SharpMapGis.Gui.Properties; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/LineStyleProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/LineStyleProperties.cs (.../LineStyleProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/LineStyleProperties.cs (.../LineStyleProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,5 +1,6 @@ using System.ComponentModel; +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Styles; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/LineStylePropertiesBase.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/LineStylePropertiesBase.cs (.../LineStylePropertiesBase.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/LineStylePropertiesBase.cs (.../LineStylePropertiesBase.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -3,6 +3,7 @@ using System.Drawing.Design; using System.Drawing.Drawing2D; using Core.Common.Gui; +using Core.Common.Gui.Attributes; using Core.Common.Utils; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Rendering.Thematics; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PointStyleProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PointStyleProperties.cs (.../PointStyleProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PointStyleProperties.cs (.../PointStyleProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,5 +1,6 @@ using System.ComponentModel; +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Styles; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PointStylePropertiesBase.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PointStylePropertiesBase.cs (.../PointStylePropertiesBase.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PointStylePropertiesBase.cs (.../PointStylePropertiesBase.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -4,6 +4,7 @@ using System.Drawing.Design; using System.Drawing.Drawing2D; using Core.Common.Gui; +using Core.Common.Gui.Attributes; using Core.Common.Utils; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Styles; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PolygonStyleProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PolygonStyleProperties.cs (.../PolygonStyleProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PolygonStyleProperties.cs (.../PolygonStyleProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,5 +1,6 @@ using System.ComponentModel; +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Styles; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PolygonStylePropertiesBase.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PolygonStylePropertiesBase.cs (.../PolygonStylePropertiesBase.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/PolygonStylePropertiesBase.cs (.../PolygonStylePropertiesBase.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,6 +1,7 @@ using System.ComponentModel; using System.Drawing; using Core.Common.Gui; +using Core.Common.Gui.Attributes; using Core.Common.Utils; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Styles; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerLineProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerLineProperties.cs (.../VectorLayerLineProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerLineProperties.cs (.../VectorLayerLineProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,5 +1,7 @@ using System; using System.ComponentModel; + +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Layers; using Core.GIS.SharpMap.Styles; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerPointProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerPointProperties.cs (.../VectorLayerPointProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerPointProperties.cs (.../VectorLayerPointProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,5 +1,7 @@ using System; using System.ComponentModel; + +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Core.GIS.SharpMap.Layers; using Core.GIS.SharpMap.Styles; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerPolygonProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerPolygonProperties.cs (.../VectorLayerPolygonProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerPolygonProperties.cs (.../VectorLayerPolygonProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -2,6 +2,8 @@ using System.ComponentModel; using System.Drawing.Design; using System.Windows.Forms; + +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Core.GIS.GeoAPI.CoordinateSystems; using Core.GIS.SharpMap.CoordinateSystems.Transformations; Index: Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerProperties.cs (.../VectorLayerProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Core/Plugins/src/Core.Plugins.SharpMapGis.Gui/Forms/GridProperties/VectorLayerProperties.cs (.../VectorLayerProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -2,6 +2,7 @@ using System.ComponentModel; using System.Drawing; using Core.Common.Gui; +using Core.Common.Gui.Attributes; using Core.Common.Utils; using Core.Common.Utils.Attributes; using Core.GIS.GeoAPI.CoordinateSystems; Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationGroupContextProperties.cs =================================================================== diff -u -rfa33f7c078c5d17f92f6a519f147a0a371593944 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationGroupContextProperties.cs (.../PipingCalculationGroupContextProperties.cs) (revision fa33f7c078c5d17f92f6a519f147a0a371593944) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingCalculationGroupContextProperties.cs (.../PipingCalculationGroupContextProperties.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -1,4 +1,5 @@ using Core.Common.Gui; +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Ringtoets.Piping.Data; Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingCalculationGroupContextPropertiesTest.cs =================================================================== diff -u -rb443ebc25f4853fa10df2a68d3fedab32c8e84f3 -rb92517dbc9956b930a6cfc7f96a1f762dfa41cf6 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingCalculationGroupContextPropertiesTest.cs (.../PipingCalculationGroupContextPropertiesTest.cs) (revision b443ebc25f4853fa10df2a68d3fedab32c8e84f3) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingCalculationGroupContextPropertiesTest.cs (.../PipingCalculationGroupContextPropertiesTest.cs) (revision b92517dbc9956b930a6cfc7f96a1f762dfa41cf6) @@ -2,6 +2,7 @@ using Core.Common.Base; using Core.Common.Gui; +using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Core.Common.Utils.Reflection;