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 static SerializeData CreateEmptySerializeData(Type type) { return(new SerializeData { Type = type, UseObjectInfo = (!type.GetTypeInfo().IsValueType&& type != typeof(string)), IsHumanReadableSupported = HumanReadableConverter.IsTypeSupported(type) }); }
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(); }
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 void WriteObject(string name, SerializeData staticSerializeData, object value) { if (staticSerializeData.IsHumanReadableSupported) { Serialize(name, (value != null) ? HumanReadableConverter.ConvertToString(value) : string.Empty); return; } EnterNode(name); base.WriteObject(staticSerializeData, value); LeaveNode(name); }
public void ReadObject(string name, SerializeData staticSerializeData, ref object value) { if (staticSerializeData.IsHumanReadableSupported) { string value2 = null; Serialize(name, ref value2); value = HumanReadableConverter.ConvertFromString(staticSerializeData.Type, value2); } else { EnterNode(name); base.ReadObject(staticSerializeData, ref value); LeaveNode(name); } }
public string ConvertToString(object value) { Color color = (Color)value; if (color.A != byte.MaxValue) { return(HumanReadableConverter.ValuesListToString(',', new int[4] { color.R, color.G, color.B, color.A })); } return(HumanReadableConverter.ValuesListToString(',', new int[3] { color.R, color.G, color.B })); }
public string ConvertToString(object value) { Vector2 vector = (Vector2)value; return(HumanReadableConverter.ValuesListToString <float>(',', vector.X, vector.Y)); }
public string ConvertToString(object value) { Plane plane = (Plane)value; return(HumanReadableConverter.ValuesListToString <float>(',', plane.Normal.X, plane.Normal.Y, plane.Normal.Z, plane.D)); }
public string ConvertToString(object value) { Point3 point = (Point3)value; return(HumanReadableConverter.ValuesListToString <int>(',', point.X, point.Y, point.Z)); }
public string ConvertToString(object value) { Matrix matrix = (Matrix)value; return(HumanReadableConverter.ValuesListToString <float>(',', matrix.M11, matrix.M12, matrix.M13, matrix.M14, matrix.M21, matrix.M22, matrix.M23, matrix.M24, matrix.M31, matrix.M32, matrix.M33, matrix.M34, matrix.M41, matrix.M42, matrix.M43, matrix.M44)); }
public string ConvertToString(object value) { Rectangle rectangle = (Rectangle)value; return(HumanReadableConverter.ValuesListToString <int>(',', rectangle.Left, rectangle.Top, rectangle.Width, rectangle.Height)); }
public string ConvertToString(object value) { BoundingBox boundingBox = (BoundingBox)value; return(HumanReadableConverter.ValuesListToString <float>(',', boundingBox.Min.X, boundingBox.Min.Y, boundingBox.Min.Z, boundingBox.Max.X, boundingBox.Max.Y, boundingBox.Max.Z)); }
public string ConvertToString(object value) { Quaternion quaternion = (Quaternion)value; return(HumanReadableConverter.ValuesListToString <float>(',', quaternion.X, quaternion.Y, quaternion.Z, quaternion.W)); }
public string ConvertToString(object value) { Box box = (Box)value; return(HumanReadableConverter.ValuesListToString <int>(',', box.Left, box.Top, box.Near, box.Width, box.Height, box.Depth)); }
public string ConvertToString(object value) { BoundingSphere boundingSphere = (BoundingSphere)value; return(HumanReadableConverter.ValuesListToString <float>(',', boundingSphere.Center.X, boundingSphere.Center.Y, boundingSphere.Center.Z, boundingSphere.Radius)); }
public string ConvertToString(object value) { BoundingRectangle boundingRectangle = (BoundingRectangle)value; return(HumanReadableConverter.ValuesListToString <float>(',', boundingRectangle.Min.X, boundingRectangle.Min.Y, boundingRectangle.Max.X, boundingRectangle.Max.Y)); }