Configuration Collection of type 'AddRemoveClearMap': why do children need a key property?

Dec 17, 2012 at 11:07 AM
Edited Dec 17, 2012 at 11:09 AM

[This question originally asked on StackOverflow.com, but got no attention there]

 

I'm using Configuration Section Designer (CSD) to manage my .NET app.config file structure, and so far I'm lovin' it.

Problem is, I need a collection of items that doesn't lend itself to having a key. This is a list of permissions having a type {User | Group} and a name. There can be several items of the same type and several items of the same name.

It makes sense not to be able to do this using a collection of type BasicMap; but what about AddRemoveClearMap collections? (Ok, the 'map' in AddRemoveClearMap doesn't help, I need list semantics).

This is what CSD says when I try to configure it like this:

The Item Type of this collection does not have a key property.

Here's a screenshot.

Any pointers are welcome.

PS. This StackOverflow answer suggests I add a bogus (unique) GUID property to the objects in the collection and use that as the key. Is there a way to bend CSD to allow that, short of editing the CSD source code?

Coordinator
Dec 17, 2012 at 1:39 PM

Thank you for the comment. This is currently an active work item for this project, so will hopefully be completed soon.

Coordinator
Dec 17, 2012 at 3:42 PM

I have applied a user submitted patch that may help with this issue. I've uploaded the source code. If no issues found, we will include this in next build.

Dec 18, 2012 at 8:43 AM

Is this tracked somewhere? Can you share a link to the bug/patch/...? Need a beta-tester? B-) 

Coordinator
Dec 18, 2012 at 6:20 PM

I had to rollback the changes temporarily due to some issues. We will let you know when it is ready.

Coordinator
Dec 19, 2012 at 2:12 PM

IlMax is now working on this one.

Coordinator
Jan 7, 2013 at 9:58 PM

I'll fix it during this week (i hope)

Jul 15, 2013 at 2:24 PM
Any news on this?
Jul 15, 2013 at 2:39 PM
Looks like @iLMaX added the patch for this in March - https://csd.codeplex.com/SourceControl/changeset/72099

Unfortunately, the latest release is from January. Could you please create another release to include this?
Jul 15, 2013 at 3:51 PM
Edited Jul 15, 2013 at 3:52 PM
Compiled from source and tested in VS2012. Happy to report that it seems to work just fine :)

Thanks iLMaX! I'd buy you a beer for this!

The enhancement can be found in the properties for "Configuration Element Collection" types as the new property "Use Hash For Element Key"
Image
Coordinator
Jul 15, 2013 at 3:53 PM
fdsaasdf wrote:
Compiled from source and tested in VS2012. Happy to report that it seems to work just fine :)

Thanks iLMaX! I'd buy you a beer for this!
Waiting for the beer :)
Jul 26, 2013 at 8:46 PM
Awesome change, just remember that you have to override the GetHashCode method on your custom configuration element when using it (thank god for partial classes)
Jul 26, 2013 at 11:21 PM
Why does GetHashCode() need to be overridden?
Jul 26, 2013 at 11:33 PM
@iLMaX: I'll make true on my promise :) Got a PayPal account or smth?