using Microsoft.UI.Xaml.Data; namespace XFEExtension.NetCore.WinUIHelper.Utilities.Converter; /// /// Provides conversion between and objects. /// /// This converter is typically used in scenarios where a value needs to be /// transformed into a or vice versa, such as in data binding or serialization /// contexts. public partial class DateTimeOffsetConverter : IValueConverter { /// /// Converts a value to a instance. /// /// The value to convert. Must be a instance. /// The target type for the conversion. This parameter is not used in this implementation. /// An optional parameter for the conversion. This parameter is not used in this implementation. /// The language information for the conversion. This parameter is not used in this implementation. /// A instance representing the input value, or if the input value is not a . public object? Convert(object value, Type targetType, object parameter, string language) => value is DateTime dateTime ? new DateTimeOffset(dateTime) : default; /// /// Converts a value to a . Returns if /// the input value is not a . /// /// The value to convert, expected to be of type . /// The target type of the conversion. This parameter is not used in this implementation. /// An optional parameter for the conversion. This parameter is not used in this implementation. /// The language information for the conversion. This parameter is not used in this implementation. /// A representation of the input value, or if the input value is not a . public object? ConvertBack(object value, Type targetType, object parameter, string language) => value is DateTimeOffset dateTimeOffset ? dateTimeOffset.DateTime : default; }