IPEPConverter.cs 878 Bytes
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Windows.Data;

潘栩锋's avatar
潘栩锋 committed
8
namespace FLY.Thick.Base.UI.Converter
潘栩锋's avatar
潘栩锋 committed
9 10 11 12 13 14 15 16
{
    public class IPEPConverter : IValueConverter
    {
        #region IValueConverter 成员

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            IPEndPoint ep = (IPEndPoint)value;
17 18 19 20 21 22
            if (ep == null)
            {
                return "";
            }
            else
                return ep.ToString();
潘栩锋's avatar
潘栩锋 committed
23 24 25 26 27
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string s = (string)value;
28
            
潘栩锋's avatar
潘栩锋 committed
29 30 31 32 33 34
            return Misc.StringConverter.ToIPEndPoint(s);
        }

        #endregion
    }
}