[Mono-dev] ConfigurationElementCollection.ThrowOnDuplicate

Atsushi Eno atsushi at ximian.com
Fri Dec 22 09:09:27 EST 2006


Hi Kosta,

Thanks for the hint :-) Now I understand what ThrowOnDuplicate
means - it rejects a different element. Therefore, current
mono implementation has an issue that an identical element to
one of the existing items actually raises an error.

I have a patch and some standalone tests for review.

Atsushi Eno

Konstantin Triger wrote:
> Hi Atsushi,
> 
> I think the implementation of ThrowOnDuplicate is correct: it indicates 
> whether the collection throws if duplicates exist. To make this happen 
> there should be elements with same keys but different values. But I 
> think that your implementation of MySection is incorrect, it should be 
> like this:
> 
> public class MySection : ConfigurationSection
> {
>     [ConfigurationProperty("MyElements")]
>     public MyElementCollection MyElements
>     {
>         get { return (MyElementCollection)this["MyElements"]; }
>     }
> }
> 
> In addition, a cleaner implementation for MyElement would be this:
> 
> public class MyElement : ConfigurationElement
> {
>     [ConfigurationProperty("name", Options = 
> ConfigurationPropertyOptions.IsKey)]
>     public string Name
>     {
>         get { return (string)this["name"]; }
>     }
> /*
>     [ConfigurationProperty("value")]
>     public string Value
>     {
>         get { return (string)this["value"]; }
>     }
> */
> }
> 
> BTW, uncomment Value property and add some 'value' to one of your Foos. 
> This throws on .net (did not check on mono).
> 
> Regards,
> Kosta
> 
> 
> 
> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com on behalf of Atsushi Eno
> Sent: Fri 22/12/2006 11:03
> To: mono-devel-list at lists.ximian.com
> Subject: [Mono-dev] ConfigurationElementCollection.ThrowOnDuplicate
> 
> Hi,
> 
> I have been trying to fix some web service config stuff, and
> noticed that ConfigurationElementCollection.ThrowOnDuplicate property
> behavior is somewhat different from .net (the attached example
> does not raise an error on .net while mono does).
> 
> According to the documentation, I believe that Mono behavior is
> the correct behavior, but with this I find difficulty to fix
> web service configuration issue, so I'm tempted to find that
> current behavior is incorrect (and my understanding becomes wrong) ;-)
> 
> So, does anyone have ideas on how this property works?
> 
> Atsushi Eno
> 

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: t38.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061222/f8751dbe/attachment.pl 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t38.exe.config
Type: application/xml
Size: 259 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061222/f8751dbe/attachment.rdf 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: t38.exe.expected
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061222/f8751dbe/attachment-0001.pl 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: t39.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061222/f8751dbe/attachment-0002.pl 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t39.exe.config
Type: application/xml
Size: 259 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061222/f8751dbe/attachment-0001.rdf 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: t39.exe.expected
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061222/f8751dbe/attachment-0003.pl 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: throw-on-duplicate.patch
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20061222/f8751dbe/attachment-0004.pl 


More information about the Mono-devel-list mailing list