Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DateToXmlString.cs
1
using
System;
2
using
System.Globalization;
3
using
System.Windows.Data;
4
using
System.Windows.Markup;
5
using
Waher.Content.Xml
;
6
7
namespace
LegalLab.Converters
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
}
LegalLab.Converters.DateToXmlString
Converts the date part of a DateTime values to XML strings.
Definition:
DateToXmlString.cs:13
LegalLab.Converters.DateToXmlString.ConvertBack
object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
Definition:
DateToXmlString.cs:24
LegalLab.Converters.DateToXmlString.Convert
object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Definition:
DateToXmlString.cs:15
LegalLab.Converters.DateToXmlString.ProvideValue
override object ProvideValue(IServiceProvider serviceProvider)
Definition:
DateToXmlString.cs:33
Waher.Content.Xml.XML
Helps with common XML-related tasks.
Definition:
XML.cs:19
Waher.Content.Xml.XML.Encode
static string Encode(string s)
Encodes a string for use in XML.
Definition:
XML.cs:27
Waher.Content.Xml.XML.TryParse
static bool TryParse(string s, out DateTime Value)
Tries to decode a string encoded DateTime.
Definition:
XML.cs:744
LegalLab.Converters
Definition:
BooleanToVisibility.cs:8
Waher.Content.Xml
Definition:
XmlCodec.cs:11
LegalLab
LegalLab
Converters
DateToXmlString.cs
Generated by
1.9.5