コード例 #1
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            object mAPCLAss;

            if (value is string)
            {
                try
                {
                    string str  = (string)value;
                    int    num  = str.IndexOf(':');
                    int    num1 = str.IndexOf(',');
                    if (num == -1 || num1 == -1)
                    {
                        return(base.ConvertFrom(context, culture, value));
                    }
                    else
                    {
                        str.Substring(num + 1, num1 - num - 1);
                        num  = str.IndexOf(':', num1 + 1);
                        num1 = str.IndexOf(',', num1 + 1);
                        str.Substring(num + 1, num1 - num - 1);
                        num = str.IndexOf(':', num1 + 1);
                        str.Substring(num + 1);
                        mAPCLAss = new MAP_CLASS();
                    }
                }
                catch
                {
                    throw new ArgumentException(string.Concat("you can not“", (string)value, "”Convert to SpellingOptions type"));
                }
                return(mAPCLAss);
            }
            return(base.ConvertFrom(context, culture, value));
        }
コード例 #2
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType != typeof(string) || !(value is MAP_CLASS))
            {
                return(base.ConvertTo(context, culture, value, destinationType));
            }
            MAP_CLASS mAPCLAss = (MAP_CLASS)value;

            return(string.Concat(new object[] { "MAP ID:", mAPCLAss.MapID, ",X: ", mAPCLAss.CoordX, ",Y: ", mAPCLAss.CoordY }));
        }