Design-time validation node's nested validator node not showing up

Topics: Development Team Discussion, User Discussion
Jun 10, 2007 at 6:14 PM
Hi,
I would like to create a validator that has some properties and also one nested validator that it needs to do it job. I have all of the code done, but I can't get the nested node to show up in the design tool, when opening an existing config file. The custom parent validator node shows up, but the nested validator does not show up. I have looked at the OpenCore method in the DesignManager and tried to override it with a CustomValidationSettingsNodeBuilder, but I don't really understand how to override the OpenCore and the GetConfigurationSectionInfo methods of the DesignManager. In the end, I ended up copying most of the code from the ValidationConfigurationDesignManager including the ValidationSettingsBuilder and the ValidationSettingsNodeBuilder classes used in the GetConfigurationSectionInfo and OpenCore methods respectively. Now the problem is that when I open the config file, two identical Validation Application Block nodes show up (named Validation Application Block and Validation Application Block 1 respectively). The second one uses my custom logic from my custom DesignManager and also displays the nested node that I want -> so I guess I have the core logic correct. The two "Validation Application Block" nodes show up because of the config file being parsed by both my custom DesignManager (which gets the logic of showing the nested node correct) and by the entlib ValidationConfigurationDesignManager (which does not have the logic to correctly load my nested validator). I know that I somehow have to only insert the new logic for the nested validator, but don't know how to do it.
I hope the question is clear and that there is someone on this forum who can help me. To phrase the question another way, what is the procedure for adding a custom validation design node and get it to show up correctly while opening a config file.

Below is a sample of a config file where ConfigurablePropertyValueValidator is the parent validator that contains some properties and a SizeRangeValidator as the nested validator (I know I can set this up another way using property nodes, but this is not what I want to do):

<validation>
<type assemblyName="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
name="System.Drawing.Bitmap">
<ruleset name="Rule Set">
<validator propertyName="Size" messageTemplate=""
messageTemplateResourceName="" messageTemplateResourceType=""
tag="" type="MyNamespace.Validation.ConfigurablePropertyValueValidator`1, Validation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
name="Configurable Property Value Validator">
<validator widthLowerBound="30" widthUpperBound="320" heightLowerBound="20"
heightUpperBound="240" negated="false" messageTemplate="" messageTemplateResourceName=""
messageTemplateResourceType="" tag="" type="MyNamespace.Validation.SizeRangeValidator, Validation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
name="Size Range Validator" />
</validator>
</ruleset>
</type>
</validation>
Jun 10, 2007 at 10:11 PM
The problem is now solved. I found an example of custom matching rules in the PolicyInjection Block from the entlibcontrib solution and followed a similar scheme to get this done.