MCPcopy Create free account
hub / github.com/9chu/LuaSTGPlus / ConvertFrom

Method ConvertFrom

TexturedFontEditor/Helper.cs:184–207  ·  view source on GitHub ↗
(ITypeDescriptorContext context, CultureInfo culture, object value)

Source from the content-addressed store, hash-verified

182 return ((destinationType == typeof(PointF)) || base.CanConvertTo(context, destinationType));
183 }
184 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
185 {
186 if (culture == null)
187 culture = CultureInfo.CurrentCulture;
188
189 if (!(value is string))
190 return base.ConvertFrom(context, culture, value);
191
192 string text = ((string)value).Trim();
193 if (text.Length == 0)
194 return null;
195
196 char ch = culture.TextInfo.ListSeparator[0];
197 string[] textArray = text.Split(new char[] { ch });
198 float[] numArray = new float[textArray.Length];
199 if (numArray.Length != 2)
200 throw new ArgumentException("格式不正确");
201
202 TypeConverter converter = TypeDescriptor.GetConverter(typeof(float));
203 for (int i = 0; i < numArray.Length; i++)
204 numArray[i] = (float)converter.ConvertFromString(context, culture, textArray[i]);
205
206 return new PointF(numArray[0], numArray[1]);
207 }
208 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
209 {
210 if (culture == null)

Callers

nothing calls this directly

Calls 1

ConvertFromMethod · 0.45

Tested by

no test coverage detected