Esempio n. 1
0
        internal List <List <object> > UpdateData()
        {
            GenerateUpdates();

            foreach (List <object> UpdateRecords in this._ListOfUpdates)
            {
                Type          RecordType = UpdateRecords.ElementAt(0).GetType();
                List <object> new_List   = new List <object>();
                List <object> FileList   = this._ListOfFileData.Where(i => i.ElementAt(0).GetType() == RecordType).FirstOrDefault();

                foreach (FileMap map in this._ListOfMaps.Where(i => i.TableType == RecordType))
                {
                    IEnumerable <PropertyInfo> IndexProperty      = PropertyHelper.GetIsIndex(RecordType, map);
                    IEnumerable <PropertyInfo> PropertiesToChange = PropertyHelper.GetPropertiesToChange(RecordType, map);

                    PropertyInfo Index = IndexProperty.FirstOrDefault();

                    if (IndexProperty.Count() >= 2 || Index == null)
                    {
                        throw new Exception("Update JSON File Can only have 1 index");
                    }

                    foreach (object record in FileList)
                    {
                        object recordIndexValue = RecordType.GetProperty(Index.Name).GetValue(record);

                        object filerecord = UpdateRecords.Find(delegate(object obj)
                        {
                            return(Index.GetValue(obj).Equals(recordIndexValue));
                        });

                        if (filerecord != null)
                        {
                            foreach (PropertyInfo prop in PropertiesToChange)
                            {
                                prop.SetValue(record, prop.GetValue(filerecord));
                            }
                        }
                        new_List.Add(record);
                    }
                }
                this._ListOfFileData.Remove(FileList);

                this._ListOfFileData.Add(new_List);
            }
            return(this._ListOfFileData);
        }
 public string EndAsyncUpdateRecords(IAsyncResult result)
 {
     return(UpdateRecords.EndUpdateRecords(result));
 }
    public IAsyncResult BeginAsyncUpdateRecords(AsyncCallback cb, object state)
    {
        var updateRecords = new UpdateRecords();

        return(updateRecords.BeginUpdateRecords(cb, state));
    }