Try to parse XML (similar to Integer.TryParse).

I’ve facing following problem during my current project. We have a lot of automation here. We have plug-ins architecture inside. Plug-ins are simple classes which inherits our special interface off-course. But main issue for plug-in is to persist his status. It’s possible with properties. So plug-ins are classes with properties which are processed automatically. Under processing I’m talking about setting/getting values and storing in our system. But plug-in can contains not just properties with simple types but complex types as well. Here complex type is some class which can easily be serialized/deserialized to/from XML. So we should be able to store complex types in properties. BTW: all values are storing as strings in our system. If can’t then I’m trying to convert value to a type of property. During conversation I’m checking if the passed value can be deserialized to complex type if yes – then it’s deserialized and value successfully set. If not I’m looking for a converter if no converter found I’m trying to set value directly.

    So my actual problem is that I can’t check that string can be parsed by XML processor. For example if we have in the string special symbols it can’t be processed. So I need to do try … catch to handle errors during deserialization. So I’m wondering why haven’t Microsoft add TryParse method to XML processor.

Advertisements

1 comment so far

  1. […] Andriy Mykhaylyuk Wrote an interesting post today on amykhaylyuk.wordpress.comThe first bit is quoted here: […]


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: