An Xml Serializable PropertyBag Dictionary Class for .NET(www.west-wind.com)

submitted by diamondzdiamondz(75) 7 months, 17 days ago

How to create a PropertyBag object which you can serialize to XML.

5 comments |category: |Views: 57

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by fun_cyberfun_cyber(1) 7 months, 17 days ago 0

good thinking

Reply

posted by dpetersondpeterson(4397) 7 months, 15 days ago 0

It's a clever solution, but I'm wondering why XML should be used at all in this scenario? If the default serializer doesn't support IDictionary properly, why attempt to use it at all?
Using the JSON.NET library, dictionary objects can be serialized as JSON very easily. Dictionaries are easily represented in JSON, which is not the case with XML.

Reply

posted by bradygasterbradygaster(4897) 7 months, 15 days ago 0

Would it be possible to extend this example in a way that JSON could be output rather than XML? I agree with you dpeterson, and think a lot of people will be alienated who are moving away from XML and into other serialization formats.

Reply

posted by rstrahlrstrahl(7226) 7 months, 12 days ago 0

@dpeterson - actually I doubt you get two way serialization/deserialization of objects in JSON. It's not really possible given that no type information is available if you have Dictionary<string,object>. THere's no way for the deserializer to turn that back into the original dictionary unless type info is explicitly provided. There's more info on the post's comments about this.

Reply

posted by dpetersondpeterson(4397) replied to rstrahlrstrahl(7226), 7 months, 12 days ago 0

Ah, I was working under the assumption that the object would be of a known type. Similar to how you would write code for mapping a DTO to your data layer and back. In this case you would just explicitly cast rather than storing any type information.

Reply

information Login or create an account to comment on this story