//public static IEnumerable<T> DeserializeFromColumnsAndDataJson<T>(JSONObject json)
        //where T : DataEntry
        //{
        //	DataEntry.< DeserializeFromColumnsAndDataJson > c__Iterator0 < T > variable = null;
        //	return variable;
        //}

        public static void DeserializeFromColumnsAndDataJsonAsync <T>(JsonTextReader reader, Action <T> objectCallback, Action onFinish)
            where T : DataEntry
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (objectCallback == null)
            {
                throw new ArgumentNullException("objectCallback");
            }
            if (!reader.Read())
            {
                throw new JsonException("JSON is finished unexpectedly");
            }
            if (reader.TokenType != JsonToken.StartObject)
            {
                throw new JsonException(string.Format("Couldn't find {0} token", JsonToken.StartObject));
            }
            DataEntry.DataEntryColumn[] synchronizableColumns = DataEntry.GetSynchronizableColumns <T>();
            if (!reader.Read())
            {
                throw new JsonException("JSON is finished unexpectedly");
            }
            if (reader.TokenType == JsonToken.PropertyName)
            {
                if ((reader.Value as string ?? string.Empty).ToUpperInvariant() == "COLUMNS")
                {
                    if (!reader.Read())
                    {
                        throw new JsonException("JSON is finished unexpectedly");
                    }
                    string[] strArrays = DataEntry.ParseStringsArray(reader);
                    DataEntry.DataEntryColumn dataEntryColumn = synchronizableColumns.FirstOrDefault <DataEntry.DataEntryColumn>((DataEntry.DataEntryColumn c) => (c.SynchronizableAttribute == null || c.DataColumnAttribute == null ? false : c.DataColumnAttribute.IsPrimaryKey));
                    Dictionary <int, int>     nums            = new Dictionary <int, int>();
                    int num = -1;
                    for (int i = 0; i < (int)strArrays.Length; i++)
                    {
                        int num1 = 0;
                        while (num1 < (int)synchronizableColumns.Length)
                        {
                            if (string.Equals(strArrays[i], synchronizableColumns[num1].SynchronizableName, StringComparison.InvariantCultureIgnoreCase))
                            {
                                if (synchronizableColumns[num1].DataColumnAttribute != null && synchronizableColumns[num1].DataColumnAttribute.IsPrimaryKey)
                                {
                                    num = i;
                                }
                                nums.Add(i, num1);
                                break;
                            }
                            else
                            {
                                num1++;
                            }
                        }
                    }
                    //bool flag = (num != -1 ? false : ReflectionUtilities.IsPrimaryKeyAutoincrement<T>());
                    bool flag = true;
                    if (dataEntryColumn == null && !flag)
                    {
                        throw new InvalidOperationException(string.Format("Couldn't find a synchronizable primary key for type {0}", typeof(T).Name));
                    }
                    if (num == -1 && !flag)
                    {
                        throw new InvalidOperationException(string.Format("Couldn't find a primary key field in JSON for type {0}", typeof(T).Name));
                    }
                    if (!reader.Read())
                    {
                        throw new JsonException("JSON is finished unexpectedly");
                    }
                    if (reader.TokenType == JsonToken.PropertyName)
                    {
                        if ((reader.Value as string ?? string.Empty).ToUpperInvariant() == "DATA")
                        {
                            if (!reader.Read())
                            {
                                throw new JsonException("JSON is finished unexpectedly");
                            }
                            if (reader.TokenType != JsonToken.StartArray)
                            {
                                throw new JsonException(string.Format("Token {0} expected", JsonToken.StartArray));
                            }
                            if (!reader.Read())
                            {
                                throw new JsonException("JSON is finished unexpectedly");
                            }
                            while (reader.TokenType != JsonToken.EndArray)
                            {
                                string[] strArrays1 = DataEntry.ParseStringsArray(reader);
                                int      num2       = (!flag ? strArrays1[num].ParseInt() : DataEntry.GetAvailableId <T>());
                                T        instance   = DataEntry.GetInstance <T>(num2);
                                for (int j = 0; j < (int)strArrays.Length; j++)
                                {
                                    if (j != num && nums.ContainsKey(j))
                                    {
                                        if (synchronizableColumns[nums[j]].SynchronizableAttribute.Pull)
                                        {
                                            try
                                            {
                                                synchronizableColumns[nums[j]].SetValue(instance, strArrays1[j]);
                                            }
                                            catch (FormatException formatException1)
                                            {
                                                FormatException formatException = formatException1;
                                                throw new SynchronizationException(string.Format("Failed to fill synchronizable property '{0}' with value '{1}' for {2} with ID {3}. Exception: {4}", new object[] { strArrays[j], strArrays1[j], typeof(T).Name, num2, formatException }));
                                            }
                                        }
                                    }
                                }
                                objectCallback(instance);
                                if (reader.Read())
                                {
                                    continue;
                                }
                                throw new JsonException("JSON is finished unexpectedly");
                            }
                            if (onFinish != null)
                            {
                                onFinish();
                            }
                            return;
                        }
                    }
                    throw new JsonException(string.Format("Token {0} not found", "DATA"));
                }
            }
            throw new JsonException(string.Format("Token {0} not found", "COLUMNS"));
        }
 public string GetValue(DataEntry entry)
 {
     return(entry.GetValue <DataEntry>(this.PropertyInfo));
 }
 public void SetValue(DataEntry entry, string value)
 {
     entry.SetValue <DataEntry>(this.PropertyInfo, value);
 }
 private void AddArrayToJsonAsField(JSONObject json, DataEntry entry)
 {
     json.AddField(this.SynchronizableName, this.GetJsonOfArray(entry));
 }
 private void AddArrayToJson(JSONObject json, DataEntry entry)
 {
     json.Add(this.GetJsonOfArray(entry));
 }
 public static JSONObject SerializeToColumnsAndDataJson <T>(T entry)
     where T : DataEntry
 {
     return(DataEntry.SerializeToColumnsAndDataJson <T>(new T[] { entry }));
 }
 public static bool InstanceExists <T>(int id)
     where T : DataEntry
 {
     return(DataEntry.InstanceExists(typeof(T), id));
 }
 public static T GetInstance <T>(int id)
     where T : DataEntry
 {
     return((T)DataEntry.GetInstance(typeof(T), id));
 }