WordPress database error: [INSERT, UPDATE command denied to user '51213-2'@'10.10.20.167' for table 'wp_options']
INSERT INTO `wp_options` (`option_name`, `option_value`, `autoload`) VALUES ('_transient_doing_cron', '1714676206.3184061050415039062500', 'yes') ON DUPLICATE KEY UPDATE `option_name` = VALUES(`option_name`), `option_value` = VALUES(`option_value`), `autoload` = VALUES(`autoload`)


Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372

Warning: Cannot modify header information - headers already sent by (output started at /home/lexiqued/www/WordPress/wp-includes/wp-db.php:1502) in /home/lexiqued/www/WordPress/wp-includes/rest-api/class-wp-rest-server.php on line 1372
{"id":160,"date":"2011-09-02T09:08:59","date_gmt":"2011-09-02T08:08:59","guid":{"rendered":"http:\/\/www.jonathanantoine.com\/?p=160"},"modified":"2011-09-02T16:21:28","modified_gmt":"2011-09-02T15:21:28","slug":"convert-in-code-as-in-xaml-how-to-get-thet-xaml-processors-converter","status":"publish","type":"post","link":"http:\/\/www.jonathanantoine.com\/2011\/09\/02\/convert-in-code-as-in-xaml-how-to-get-thet-xaml-processors-converter\/","title":{"rendered":"Convert in code as in XAML: how to get the XAML processor’s converter ?"},"content":{"rendered":"

\"convert<\/a>Sometimes you need to set property on controls from the code and then you realize that this is not like in XAML: these are not strings? No, they are not! This is because the XAML processor convert the string to the correct type when it process the XAML. In this post we’ll see how to reproduce the same behavior from the code: a little snippet which can help you someday !
\n
\nAs you can
find out on MSDN<\/a>, everything is done trough the class TypeConverter<\/a>. For any type, you can create a TypeConverter (to be precise: a class inheriting from TypeConverter) which will convert it from any other type and especially string. Note that there is only four methods used in the XAML processing: CanConvertTo, CanConvertFrom, ConvertTo, ConvertFrom.<\/p>\n

When the XAML processor process the XAML it checks, the presence of a TypeConverter <\/a>attribute<\/a> on the target property<\/span>. This attribute simply specify which converter can be used to convert a value from a given type to a value of the aimed property’s type. If it exists, the XAML processor instanciates one and use it to convert to the correct type value.<\/p>\n

Here is the snippet, in his simplified version, I use to reproduce the same behavior in code:<\/span><\/p>\n

[csharp]
\npublic T ConvertTo<T>(string originalString)
\n{
\n var typeConverter = TypeDescriptor.GetConverter(typeof(T));
\n if (typeConverter != null)
\n return (T)typeConverter.ConvertFromString(originalString);
\n else
\n {
\n var errorMsg = string.Format("Cannot retrive the converter of type{0}",
\n typeof(T).Name);
\n throw new ArgumentOutOfRangeException(errorMsg);
\n }
\n}<\/p>\n

public T ConvertTo<T>(object originalValue)
\n{
\n var typeConverter = TypeDescriptor.GetConverter(typeof(T));
\n if (typeConverter != null)
\n return (T)typeConverter.ConvertFrom(originalValue);
\n else
\n {
\n var errorMsg = string.Format("Cannot retrive the converter of type{0}",
\n typeof(T).Name);
\n throw new ArgumentOutOfRangeException(errorMsg);
\n }
\n}
\n[\/csharp]<\/p>\n

I can then use it to do the most common thing in XAML: create a SolidColorBrush from a string. You can notice that any representation can be used: hexadecimal, name of the color, etc. :<\/p>\n

[csharp]SolidColorBrush redBrush = ConvertTo<SolidColorBrush>("Red");
\nSolidColorBrush anotherBrush = ConvertTo<SolidColorBrush>("#FF125645");
\n[\/csharp]<\/p>\n

This is just an exemple and this snippet can be enhanced with, for example, calls to CanConvertXXX. Also if you want more information on TypeConverter and how to implement a custome one, I recommend you to read the MSDN page which is quite well written on this subject<\/a>.<\/p>\n

Regards,<\/p>\n

\"kick<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

Sometimes you need to set property on controls from the code and then you realize that this is not like in XAML: these are not strings? No, they are not! This is because the XAML…<\/p>\n","protected":false},"author":3,"featured_media":176,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3,4,5],"tags":[22,14,15],"_links":{"self":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/160"}],"collection":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/comments?post=160"}],"version-history":[{"count":19,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/160\/revisions"}],"predecessor-version":[{"id":180,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/posts\/160\/revisions\/180"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media\/176"}],"wp:attachment":[{"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/media?parent=160"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/categories?post=160"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.jonathanantoine.com\/wp-json\/wp\/v2\/tags?post=160"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}