How does Linq-to-Xml convert objects to strings? -


There are many ways in Linux-to-XML, which can add arbitrary objects to an XML tree. These objects are converted into string in some ways, but I can not find this description how it is done. The reference I am mentioning has been mentioned (but not specified).

I need this for Javascript interop, but there is nothing more about this question.

Linux is not just calling to XML. Toaster () . Firstly, it accepts null elements, and the other thing is that it is not working anymore .string () implements:

For example:

New XElement ("elem", true). Ostring () == " true " // But ... true.ToString () == "true" // IIRC, this culture is irreversible, but in any case ... true. Toasting (Culture Info Environmental Craft) == "True"

Other basic data types are specially treated.

So, does anyone know what it is doing and where is it described?

Earmon, you are right. Quick visit with

* shows that XElement will try to add value to all 'simple' types, and then one Call the appropriate XmlConvert.ToString () method.

Here is a (slightly edited) fraction, for example:

  if (value is string) {str = (string) value; } And if (value is double) {str = XmlConvert.ToString ((double) value); } // ...  

If the object is not 'simple' type, obj.ToString () will be used.

This is very good, because it is almost the only correct way to do this.

Of course, you usually want to take with a grain of salt based on "today's time". Actually, MS can change one day how they do it. We do not care - what matters is that semantics are made in stone.

* (Product links are always provided for convenience. There is no connection with the product or its manufacturer, other are expected to be indirect customers.)

Update: , Pialorasis and Russia confirm it for the second side of the equation (extract values ​​and casting them), on page 172:

[When an excelment is molded for the given kind of decimal ...] clear [cast] operator overload internally XmlConvert to System.Xml or parse methods for .NET types .


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -