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

Method ConvertFrom

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

Source from the content-addressed store, hash-verified

260 return ((destinationType == typeof(RectangleF)) || base.CanConvertTo(context, destinationType));
261 }
262 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
263 {
264 if (culture == null)
265 culture = CultureInfo.CurrentCulture;
266
267 if (!(value is string))
268 return base.ConvertFrom(context, culture, value);
269
270 string text = ((string)value).Trim();
271 if (text.Length == 0)
272 return null;
273
274 char ch = culture.TextInfo.ListSeparator[0];
275 string[] textArray = text.Split(new char[] { ch });
276 float[] numArray = new float[textArray.Length];
277 if (numArray.Length != 4)
278 throw new ArgumentException("格式不正确");
279
280 TypeConverter converter = TypeDescriptor.GetConverter(typeof(float));
281 for (int i = 0; i < numArray.Length; i++)
282 numArray[i] = (float)converter.ConvertFromString(context, culture, textArray[i]);
283
284 return new RectangleF(numArray[0], numArray[1], numArray[2], numArray[3]);
285 }
286 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
287 {
288 if (culture == null)

Callers

nothing calls this directly

Calls 1

ConvertFromMethod · 0.45

Tested by

no test coverage detected