public object ConvertFromString(Type type, string data) { if (data[0] == '#') { if (data.Length == 7) { byte r = (byte)(16 * HexToDecimal(data[1]) + HexToDecimal(data[2])); byte g = (byte)(16 * HexToDecimal(data[3]) + HexToDecimal(data[4])); byte b = (byte)(16 * HexToDecimal(data[5]) + HexToDecimal(data[6])); return(new Color(r, g, b)); } if (data.Length == 9) { byte r2 = (byte)(16 * HexToDecimal(data[1]) + HexToDecimal(data[2])); byte g2 = (byte)(16 * HexToDecimal(data[3]) + HexToDecimal(data[4])); byte b2 = (byte)(16 * HexToDecimal(data[5]) + HexToDecimal(data[6])); byte a = (byte)(16 * HexToDecimal(data[7]) + HexToDecimal(data[8])); return(new Color(r2, g2, b2, a)); } throw new Exception(); } int[] array = HumanReadableConverter.ValuesListFromString <int>(',', data); if (array.Length == 3) { return(new Color(array[0], array[1], array[2])); } if (array.Length == 4) { return(new Color(array[0], array[1], array[2], array[3])); } throw new Exception(); }
public object ConvertFromString(Type type, string data) { float[] array = HumanReadableConverter.ValuesListFromString <float>(',', data); if (array.Length == 4) { return(new BoundingSphere(new Vector3(array[0], array[1], array[2]), array[3])); } throw new Exception(); }
public object ConvertFromString(Type type, string data) { int[] array = HumanReadableConverter.ValuesListFromString <int>(',', data); if (array.Length == 3) { return(new Point3(array[0], array[1], array[2])); } throw new Exception(); }
public object ConvertFromString(Type type, string data) { float[] array = HumanReadableConverter.ValuesListFromString <float>(',', data); if (array.Length == 16) { return(new Matrix(array[0], array[1], array[2], array[3], array[4], array[5], array[6], array[7], array[8], array[9], array[10], array[11], array[12], array[13], array[14], array[15])); } throw new Exception(); }