internal MobeelizerJsonEntity(String json) { JObject jsonObject = JObject.Parse(json); model = (String)jsonObject["model"]; guid = (String)jsonObject["guid"]; try { owner = jsonObject["owner"].ToString(); } catch (KeyNotFoundException e) { throw new InvalidOperationException("Owner field is required", e); } catch (NullReferenceException e) { throw new InvalidOperationException("Owner field is required", e); } try { conflictState = (MobeelizerConflictState)(Enum.Parse(typeof(MobeelizerConflictState), jsonObject["conflictState"].ToString(), true)); } catch (NullReferenceException) { conflictState = MobeelizerConflictState.NO_IN_CONFLICT; } try { JObject jsonFields = (JObject)jsonObject["fields"]; fields = new Dictionary <String, String>(); foreach (KeyValuePair <String, JToken> key in jsonFields) { fields.Add(key.Key, key.Value.ToString()); } } catch (NullReferenceException) { } }
internal MobeelizerJsonEntity(String json) { JObject jsonObject = JObject.Parse(json); model = (String)jsonObject["model"]; guid = (String)jsonObject["guid"]; try { owner = jsonObject["owner"].ToString(); } catch (KeyNotFoundException e) { throw new InvalidOperationException("Owner field is required", e); } catch (NullReferenceException e) { throw new InvalidOperationException("Owner field is required", e); } try { conflictState = (MobeelizerConflictState)(Enum.Parse(typeof(MobeelizerConflictState), jsonObject["conflictState"].ToString(), true)); } catch (NullReferenceException) { conflictState = MobeelizerConflictState.NO_IN_CONFLICT; } try { JObject jsonFields = (JObject)jsonObject["fields"]; fields = new Dictionary<String, String>(); foreach (KeyValuePair<String, JToken> key in jsonFields) { fields.Add(key.Key, key.Value.ToString()); } } catch (NullReferenceException) { } }