public bool ReadProperty(Property prop, XmlNode token) { uint value; if (XmlPropertyTokens.ReadPropertyGeneric(token, out value)) { Instance inst = prop.Instance; Type instType = inst?.GetType(); FieldInfo info = instType.GetField(prop.Name, Property.BindingFlags); if (info != null) { Type enumType = info.FieldType; string item = value.ToInvariantString(); prop.Type = PropertyType.Enum; prop.Value = Enum.Parse(enumType, item); return(true); } } return(false); }
public bool ReadProperty(Property prop, XmlNode token) { if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value)) { Axes axes = (Axes)value; prop.Value = axes; return(true); } return(false); }
public bool ReadProperty(Property prop, XmlNode token) { if (XmlPropertyTokens.ReadPropertyGeneric(token, out int value)) { BrickColor brickColor = BrickColor.FromNumber(value); prop.XmlToken = "BrickColor"; prop.Value = brickColor; return(true); } return(false); }
public bool ReadProperty(Property prop, XmlNode token) { Contract.Requires(prop != null); if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value)) { Faces faces = (Faces)value; prop.Value = faces; return(true); } return(false); }
public bool ReadProperty(Property prop, XmlNode token) { uint value; if (XmlPropertyTokens.ReadPropertyGeneric(token, out value)) { Faces faces = (Faces)value; prop.Value = faces; return(true); } return(false); }
public bool ReadProperty(Property prop, XmlNode token) { // BrickColors are represented by ints, see if // we can infer when they should be a BrickColor. if (prop.Name.Contains("Color") || prop.Instance.ClassName.Contains("Color")) { var brickColorToken = XmlPropertyTokens.GetHandler <BrickColorToken>(); return(brickColorToken.ReadProperty(prop, token)); } else { return(XmlPropertyTokens.ReadPropertyGeneric <int>(prop, PropertyType.Int, token)); } }
public bool ReadProperty(Property prop, XmlNode token) { bool success = true; float[] fields = new float[XmlFields.Length]; for (int i = 0; i < fields.Length; i++) { string key = XmlFields[i]; try { var coord = token[key]; string text = coord?.InnerText; if (text == null) { text = "0"; success = false; } fields[i] = Formatting.ParseFloat(text); } catch { success = false; break; } } if (success) { float r = fields[0], g = fields[1], b = fields[2]; prop.Type = PropertyType.Color3; prop.Value = new Color3(r, g, b); } else { // Try falling back to the Color3uint8 technique... var color3uint8 = XmlPropertyTokens.GetHandler <Color3uint8Token>(); success = color3uint8.ReadProperty(prop, token); } return(success); }
public bool ReadProperty(Property prop, XmlNode token) { if (XmlPropertyTokens.ReadPropertyGeneric(token, out uint value)) { uint r = (value >> 16) & 0xFF; uint g = (value >> 8) & 0xFF; uint b = value & 0xFF; Color3uint8 result = Color3.FromRGB(r, g, b); prop.Value = result; return(true); } return(false); }
public void WriteProperty(Property prop, XmlDocument doc, XmlNode node) { ProtectedString value = prop.CastValue <ProtectedString>(); if (value.IsCompiled) { var binary = XmlPropertyTokens.GetHandler <BinaryStringToken>(); binary.WriteProperty(prop, doc, node); } else { string contents = Encoding.UTF8.GetString(value.RawBuffer); if (contents.Contains("\r") || contents.Contains("\n")) { XmlCDataSection cdata = doc.CreateCDataSection(contents); node.AppendChild(cdata); } else { node.InnerText = contents; } } }
public bool ReadProperty(Property prop, XmlNode token) { return(XmlPropertyTokens.ReadPropertyGeneric <long>(prop, PropertyType.Int64, token)); }
public bool ReadProperty(Property prop, XmlNode token) { return(XmlPropertyTokens.ReadPropertyGeneric <double>(prop, PropertyType.Double, token)); }
public bool ReadProperty(Property prop, XmlNode token) { return(XmlPropertyTokens.ReadPropertyGeneric <float>(prop, PropertyType.Float, token)); }
public bool ReadProperty(Property prop, XmlNode token) { return(XmlPropertyTokens.ReadPropertyGeneric <bool>(prop, PropertyType.Bool, token)); }