public void PopulateFromJson(JObject jsonObject) { m_name = Serialization.JsonTokenValue <string>(jsonObject, "name", (string)null); JArray val = Serialization.JsonArray(jsonObject, "effects"); m_effects = new List <EffectDefinition>((val != null) ? val.get_Count() : 0); if (val != null) { foreach (JToken item in val) { m_effects.Add(EffectDefinition.FromJsonToken(item)); } } }
public new static EffectDefinition FromJsonToken(JToken token) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((int)token.get_Type() != 1) { Debug.LogWarning((object)("Malformed token : type Object expected, but " + token.get_Type() + " found")); return(null); } JObject jsonObject = Extensions.Value <JObject>((IEnumerable <JToken>)token); EffectDefinition effectDefinition = new EffectDefinition(); effectDefinition.PopulateFromJson(jsonObject); return(effectDefinition); }
public static AbstractEffectDefinition FromJsonToken(JToken token) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) if ((int)token.get_Type() != 1) { Debug.LogWarning((object)("Malformed token : type Object expected, but " + token.get_Type() + " found")); return(null); } JObject val = Extensions.Value <JObject>((IEnumerable <JToken>)token); JToken val2 = default(JToken); if (!val.TryGetValue("type", ref val2)) { Debug.LogWarning((object)"Malformed json: no 'type' property in object of class AbstractEffectDefinition"); return(null); } string text = Extensions.Value <string>((IEnumerable <JToken>)val2); AbstractEffectDefinition abstractEffectDefinition; if (!(text == "EffectDefinition")) { if (!(text == "ReferenceEffectDefinition")) { Debug.LogWarning((object)("Unknown type: " + text)); return(null); } abstractEffectDefinition = new ReferenceEffectDefinition(); } else { abstractEffectDefinition = new EffectDefinition(); } abstractEffectDefinition.PopulateFromJson(val); return(abstractEffectDefinition); }
public static EffectDefinition FromJsonProperty(JObject jsonObject, string propertyName, EffectDefinition defaultValue = null) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 JProperty val = jsonObject.Property(propertyName); if (val == null || (int)val.get_Value().get_Type() == 10) { return(defaultValue); } return(FromJsonToken(val.get_Value())); }