public override void readValue(LoadControl loadControl, String name, JsonReader reader) { reader.Read(); if (reader.TokenType != JsonToken.StartObject) { throwReadFormatError(); } reader.Read(); if (reader.TokenType != JsonToken.PropertyName) { throwReadFormatError(); } var clrType = reader.Value.ToString(); var enumType = loadControl.TypeFinder.findType(clrType); var valueStr = reader.ReadAsString(); reader.Read(); if (reader.TokenType != JsonToken.EndObject) { throwReadFormatError(); } if (enumType != null) { Object value = Enum.Parse(enumType, valueStr); loadControl.addValue(name, value, enumType); } else { Log.Default.sendMessage("Could not find enum type {0}. Value not loaded.", LogLevel.Warning, "Saving", clrType); } }
public override void readValue(LoadControl loadControl, XmlReader xmlReader) { Type enumType = loadControl.TypeFinder.findType(xmlReader.GetAttribute(TYPE)); if (enumType != null) { String name = xmlReader.GetAttribute(NAME_ENTRY); Object value = Enum.Parse(enumType, xmlReader.ReadElementContentAsString()); loadControl.addValue(name, value, enumType); } else { Log.Default.sendMessage("Could not find enum type {0}. Value not loaded.", LogLevel.Warning, "Saving", xmlReader.GetAttribute(TYPE)); } }
public virtual void readValue(LoadControl loadControl, XmlReader xmlReader) { loadControl.addValue(xmlReader.GetAttribute(NAME_ENTRY), parseValue(xmlReader), typeof(T)); }
public virtual void readValue(LoadControl loadControl, String name, JsonReader xmlReader) { loadControl.addValue(name, xmlReader.Value != null ? parseValue(xmlReader) : default(T), typeof(T)); }