public static TType Copy <TType>(this TType record) where TType : class, IDataRecord { var result = InvertJsonExtensions.DeserializeObject <TType>((string)InvertJsonExtensions.SerializeObject(record).ToString()) as TType; result.Identifier = Guid.NewGuid().ToString(); return(result); }
private void LoadRecord(FileInfo file) { if (Cached.ContainsKey(Path.GetFileNameWithoutExtension(file.Name))) { return; } var record = InvertJsonExtensions.DeserializeObject(For, JSON.Parse(File.ReadAllText(file.FullName))) as IDataRecord; if (record != null) { record.Repository = this.Repository; Cached.Add(record.Identifier, record); record.Changed = false; } }
public void Import(ExportedRecord record) { LoadRecordsIntoCache(); if (Cached.ContainsKey(record.Identifier)) { InvertJsonExtensions.DeserializeExistingObject(Cached[record.Identifier], JSON.Parse(record.Data).AsObject); } else { var dataRecord = InvertJsonExtensions.DeserializeObject(For, JSON.Parse(record.Data)) as IDataRecord; if (dataRecord != null) { Add(dataRecord); } } }
private void LoadRecord(string file) { if (Cached.ContainsKey(Path.GetFileNameWithoutExtension(file))) { return; } try { var record = InvertJsonExtensions.DeserializeObject(For, JSON.Parse(ReadFile(file))) as IDataRecord; if (record != null) { record.Repository = this.Repository; Cached.Add(record.Identifier, record); record.Changed = false; } } catch (Exception ex) { throw new Exception(string.Format("Error parsing file {0}", file), ex); } }