Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DateToXmlString.cs
1using System;
2using System.Globalization;
3using System.Windows.Data;
4using System.Windows.Markup;
6
8{
12 public class DateToXmlString : MarkupExtension, IValueConverter
13 {
15 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16 {
17 if (value is DateTime Value)
18 return XML.Encode(Value, true);
19 else
20 return value?.ToString();
21 }
22
24 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
25 {
26 if (value is string s && XML.TryParse(s, out DateTime TP))
27 return TP.Date;
28 else
29 return value;
30 }
31
33 public override object ProvideValue(IServiceProvider serviceProvider)
34 {
35 return this;
36 }
37 }
38}
Helps with common XML-related tasks.
Definition: XML.cs:19
static string Encode(string s)
Encodes a string for use in XML.
Definition: XML.cs:27
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition: XML.cs:744