public override List <ConsumeProperty> ReadJson(JsonReader reader, Type objectType, List <ConsumeProperty> existingValue, bool hasExistingValue, JsonSerializer serializer) { string data = (string)reader.Value; string[] args = data.Split('|'); List <ConsumeProperty> properties = new List <ConsumeProperty>(); try { for (int i = 0; i < args.Length; i++) { string[] vals = args[i].Split('$'); string[] param; switch (vals[0]) { default: return(null); case "Recover": param = vals[1].Split('>'); Recover recover = new Recover() { amount = float.Parse(param[1]) }; properties.Add(recover); break; case "Replenish": param = vals[1].Split('>'); Replenish replenish = new Replenish() { amount = float.Parse(param[1]) }; properties.Add(replenish); break; case "StatsBuff_CP": properties.Add(new StatsBuff_CP(vals)); break; case "JobChange": param = vals[1].Split('>'); JobChange jobChange = new JobChange() { job = param[1] }; properties.Add(jobChange); break; } } } catch (Exception e) { Console.WriteLine(e.ToString()); } return(properties); }
public void Setup() { GlobalReference.GlobalValues = new GlobalValues(); effect = new Replenish(); parameter = new Mock <IEffectParameter>(); item = new Mock <IItem>(); room = new Mock <IRoom>(); Mock <IEnchantment> enchantment = new Mock <IEnchantment>(); Mock <ISerialization> serilization = new Mock <ISerialization>(); parameter.Setup(e => e.ObjectRoom).Returns(room.Object); parameter.Setup(e => e.Item).Returns(item.Object); item.Setup(e => e.Enchantments).Returns(new List <IEnchantment>() { enchantment.Object }); enchantment.Setup(e => e.Parameter).Returns(parameter.Object); serilization.Setup(e => e.Serialize(item.Object)).Returns("obj"); serilization.Setup(e => e.Deserialize <IItem>("obj")).Returns(item.Object); GlobalReference.GlobalValues.Serialization = serilization.Object; }