예제 #1
0
 static AnalyticsFile()
 {
     Serializer.RegisterTypeConverter(typeof(DateTime), new SingleTypeConverter <DateTime> {
         ConvertToString = value => value.ToBinary().ToString(),
         ConvertToObject = value => DateTime.FromBinary(long.Parse(value))
     });
 }
예제 #2
0
        static UserConfig()
        {
            Serializer.RegisterTypeConverter(typeof(WindowState), WindowState.Converter);

            Serializer.RegisterTypeConverter(typeof(Point), new SingleTypeConverter <Point> {
                ConvertToString = value => $"{value.X} {value.Y}",
                ConvertToObject = value => {
                    int[] elements = StringUtils.ParseInts(value, ' ');
                    return(new Point(elements[0], elements[1]));
                }
            });

            Serializer.RegisterTypeConverter(typeof(Size), new SingleTypeConverter <Size> {
                ConvertToString = value => $"{value.Width} {value.Height}",
                ConvertToObject = value => {
                    int[] elements = StringUtils.ParseInts(value, ' ');
                    return(new Size(elements[0], elements[1]));
                }
            });
        }