public ZipBundleReader( string fileName, string unpackDirectory, IZipFileReaderWrapper zipFileReaderWrapper, ICheckSumGenerator checkSumGenerator, ILogger logger, IFileSystem fileSystem, ISerializeWrapper serializeWrapper) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentException("fileName"); } if (string.IsNullOrEmpty(unpackDirectory)) { throw new ArgumentException("unpackDirectory"); } if (zipFileReaderWrapper == null) { throw new ArgumentNullException("zipFileReaderWrapper"); } if (checkSumGenerator == null) { throw new ArgumentNullException("checkSumGenerator"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } if (serializeWrapper == null) { throw new ArgumentNullException("serializeWrapper"); } this.mFileName = fileName; this.mUnpackDirectory = unpackDirectory; this.mZipFileReaderWrapper = zipFileReaderWrapper; this.mZipFileReaderWrapper.FileName = fileName; this.mCheckSumGenerator = checkSumGenerator; this.mLogger = logger; this.mFileSystem = fileSystem; this.mZipFileReaderWrapper.UnPackDirectory = unpackDirectory; this.mZipFileReaderWrapper.FileName = fileName; this.mSerializeWrapper = serializeWrapper; // Register event for when entries are extracted using the IZipFileReaderWrapper this.mZipFileReaderWrapper.OnEntryExtracted += EntryExtractedEventHandler; this.mSummary = new BundleSummary(); }
public ZipBundler( IZipFileWrapper zipFileWrapper, ICheckSumGenerator checkSumGenerator, ILogger logger, ISerializeWrapper serializeWrapper) { if (zipFileWrapper == null) { throw new ArgumentNullException("zipFileWrapper"); } if (checkSumGenerator == null) { throw new ArgumentNullException("checkSumGenerator"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (serializeWrapper == null) { throw new ArgumentNullException("serializeWrapper"); } this.mZipFileWrapper = zipFileWrapper; this.mCheckSumGenerator = checkSumGenerator; this.mLogger = logger; this.mSerializeWrapper = serializeWrapper; this.mSummary = new BundleSummary(); }
public ZipBundleReader( IZipFileReaderWrapper zipFileReaderWrapper, ICheckSumGenerator checkSumGenerator, ILogger logger, IFileSystem fileSystem, ISerializeWrapper serializeWrapper) { if (zipFileReaderWrapper == null) throw new ArgumentNullException("zipFileReaderWrapper"); if (checkSumGenerator == null) throw new ArgumentNullException("checkSumGenerator"); if (logger == null) throw new ArgumentNullException("logger"); if (fileSystem == null) throw new ArgumentNullException("fileSystem"); if (serializeWrapper == null) throw new ArgumentNullException("serializeWrapper"); this.mZipFileReaderWrapper = zipFileReaderWrapper; this.mCheckSumGenerator = checkSumGenerator; this.mLogger = logger; this.mFileSystem = fileSystem; this.mSerializeWrapper = serializeWrapper; // Register event for when entries are extracted using the IZipFileReaderWrapper this.mZipFileReaderWrapper.OnEntryExtracted += EntryExtractedEventHandler; this.mSummary = new BundleSummary(); }
void ChildrenConnectionTest(ISerializeWrapper serializer) { var client = new TestClient(serializer); var team = new TestTeam(); foreach (var number in Enumerable.Range(1, 4).ToArray()) { var id = client.People.Create(new TestPerson() { Name = $"person{ number }" }); team.PersonIDs.Add(id); } team.PersonIDs.RemoveAt(3); client.Teams.Create(team); var updatedTeam = client.Teams.ReadAll().First(); updatedTeam.Fix(client.People); Assert.AreEqual(3, updatedTeam.People.Count); Assert.AreEqual("person2", updatedTeam.People[1].Name); }
static void SetSerializerIfNull(ref ISerializeWrapper serializer) { if (serializer == null) { serializer = XMLSerializeWrapper.Default; } }
public static int Create <T>(this IList <T> items, T graph, ISerializeWrapper serializer = null) where T : CRUDObject { ListExtensions.SetSerializerIfNull(ref serializer); graph.Id = items.Select(x => x.Id).Concat(new int[] { 0 }).Max() + 1; graph.SortIndex = items.Select(x => x.SortIndex).Concat(new int[] { 0 }).Max() + 1; items.Add(serializer.Clone(graph)); return(graph.Id); }
void UpdateSeparationTest(ISerializeWrapper serializer) { var collection = new CRUDCollection <TestPerson>(new List <TestPerson>()); var id = collection.Create(new TestPerson()); collection.Update(id, record => record.IsChecked = true); var graph = collection.Read(id); Assert.AreEqual(false, graph.IsChecked); }
void Initialize(IList <T> items, ISerializeWrapper serializer, bool isAutoSave, Action <IList <T>, ISerializeWrapper> saveAction) { this.SaveAction = saveAction; this.Serializer = serializer; this.SetAutoSave(isAutoSave); this.Items = items ?? new List <T>(); this.Created += id => this.Changed(id); this.Updated += id => this.Changed(id); this.Deleted += id => this.Changed(id); }
void CreateReadTest(ISerializeWrapper serializer) { const string personName = "Taro Yamada"; var collection = new CRUDCollection <TestPerson>(new List <TestPerson>()); var id = collection.Create(new TestPerson() { Name = personName }); var graph = collection.Read(id); Assert.AreEqual(personName, graph.Name); }
void UpdateTest(ISerializeWrapper serializer) { const string personName = "Taro Yamada"; const string finalPersonName = "Hanako Yamada"; var collection = new CRUDCollection <TestPerson>(new List <TestPerson>()); var id = collection.Create(new TestPerson() { Name = personName }); collection.Update(id, record => record.Name = finalPersonName); var graph = collection.Read(id); Assert.AreEqual(finalPersonName, graph.Name); }
public ZipBundleReader( string fileName, string unpackDirectory, IZipFileReaderWrapper zipFileReaderWrapper, ICheckSumGenerator checkSumGenerator, ILogger logger, IFileSystem fileSystem, ISerializeWrapper serializeWrapper) { if (string.IsNullOrEmpty(fileName)) throw new ArgumentException("fileName"); if (string.IsNullOrEmpty(unpackDirectory)) throw new ArgumentException("unpackDirectory"); if (zipFileReaderWrapper == null) throw new ArgumentNullException("zipFileReaderWrapper"); if (checkSumGenerator == null) throw new ArgumentNullException("checkSumGenerator"); if (logger == null) throw new ArgumentNullException("logger"); if (fileSystem == null) throw new ArgumentNullException("fileSystem"); if (serializeWrapper == null) throw new ArgumentNullException("serializeWrapper"); this.mFileName = fileName; this.mUnpackDirectory = unpackDirectory; this.mZipFileReaderWrapper = zipFileReaderWrapper; this.mZipFileReaderWrapper.FileName = fileName; this.mCheckSumGenerator = checkSumGenerator; this.mLogger = logger; this.mFileSystem = fileSystem; this.mZipFileReaderWrapper.UnPackDirectory = unpackDirectory; this.mZipFileReaderWrapper.FileName = fileName; this.mSerializeWrapper = serializeWrapper; // Register event for when entries are extracted using the IZipFileReaderWrapper this.mZipFileReaderWrapper.OnEntryExtracted += EntryExtractedEventHandler; this.mSummary = new BundleSummary(); }
public ZipBundleReader( IZipFileReaderWrapper zipFileReaderWrapper, ICheckSumGenerator checkSumGenerator, ILogger logger, IFileSystem fileSystem, ISerializeWrapper serializeWrapper) { if (zipFileReaderWrapper == null) { throw new ArgumentNullException("zipFileReaderWrapper"); } if (checkSumGenerator == null) { throw new ArgumentNullException("checkSumGenerator"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } if (serializeWrapper == null) { throw new ArgumentNullException("serializeWrapper"); } this.mZipFileReaderWrapper = zipFileReaderWrapper; this.mCheckSumGenerator = checkSumGenerator; this.mLogger = logger; this.mFileSystem = fileSystem; this.mSerializeWrapper = serializeWrapper; // Register event for when entries are extracted using the IZipFileReaderWrapper this.mZipFileReaderWrapper.OnEntryExtracted += EntryExtractedEventHandler; this.mSummary = new BundleSummary(); }
void DeleteTest(ISerializeWrapper serializer) { const string personName = "Taro Yamada"; const string finalPersonName = "Hanako Yamada"; var collection = new CRUDCollection <TestPerson>(new List <TestPerson>()); var id = collection.Create(new TestPerson() { Name = personName }); collection.Create(new TestPerson() { Name = finalPersonName }); collection.Delete(id); var graphs = collection.ReadAll(); Assert.AreEqual(1, graphs.Count); Assert.AreEqual(finalPersonName, graphs.First().Name); }
public DataSourceItemImporter(ISerializeWrapper serializeWrapper, IFileSystem fileSystem, ILogger logger) { if (fileSystem == null) { throw new ArgumentNullException("fileSystem"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (serializeWrapper == null) { throw new ArgumentNullException("serializeWrapper"); } this.mFileSystem = fileSystem; this.mLogger = logger; this.mSerializeWrapper = serializeWrapper; }
public DataSourceItemExporter( IExportWriter exportWriter, ISerializeWrapper serializeWrapper, ILogger logger) { if (exportWriter == null) { throw new ArgumentNullException("exportWriter"); } if (serializeWrapper == null) { throw new ArgumentNullException("serializeWrapper"); } if (logger == null) { throw new ArgumentNullException("logger"); } this.mExportWriter = exportWriter; this.mSerializeWrapper = serializeWrapper; this.mLogger = logger; }
public static void Update <T>(this IList <T> items, int id, T graph, ISerializeWrapper serializer = null) where T : CRUDObject { graph.Id = id; items.Update(id, obj => obj.Id, graph, serializer); }
public WebAPIHub(string address, string apiKey, ISerializeWrapper serializer) { this.Address = address; this.APIKey = apiKey; this.Serializer = serializer; }
public static void Update <T>(this IList <T> items, int id, Action <T> updateAction, ISerializeWrapper serializer = null) where T : CRUDObject => items.Update(id, graph => graph.Id, graph => { updateAction(graph); graph.Id = id; }, serializer);
void Initialize(ISerializeWrapper serializer) { this.Data = new TestData(); this.People = new CRUDCollection <TestPerson>(this.Data.People); this.Teams = new CRUDCollection <TestTeam>(this.Data.Teams); }
public static void Update <T>(this IList <T> items, int id, Func <T, int> getIdFunc, Action <T> updateAction, ISerializeWrapper serializer = null) { ListExtensions.SetSerializerIfNull(ref serializer); var graph = items.FirstOrDefault(x => getIdFunc(x) == id); if (graph == null) { return; } updateAction(graph); var index = items.IndexOf(graph); items.RemoveAt(index); items.Insert(index, serializer.Clone(graph)); }
public CRUDCollection(IList <T> items, ISerializeWrapper serializer, bool isAutoSave, Action <IList <T>, ISerializeWrapper> saveAction) { this.Initialize(items, serializer, isAutoSave, saveAction); }
public static IList <T> ReadAll <T>(this IList <T> items, ISerializeWrapper serializer = null) where T : CRUDObject { ListExtensions.SetSerializerIfNull(ref serializer); return(serializer.Clone(items.OrderBy(graph => graph.SortIndex).ToList())); }
public static T Read <T>(this IList <T> items, int id, ISerializeWrapper serializer = null) where T : CRUDObject { ListExtensions.SetSerializerIfNull(ref serializer); return(serializer.Clone(items.FirstOrDefault(x => x.Id == id))); }
internal TestClient(ISerializeWrapper serializer) { this.Initialize(serializer); }
public ZipBundler( IZipFileWrapper zipFileWrapper, ICheckSumGenerator checkSumGenerator, ILogger logger, ISerializeWrapper serializeWrapper) { if (zipFileWrapper == null) throw new ArgumentNullException("zipFileWrapper"); if (checkSumGenerator == null) throw new ArgumentNullException("checkSumGenerator"); if (logger == null) throw new ArgumentNullException("logger"); if (serializeWrapper == null) throw new ArgumentNullException("serializeWrapper"); this.mZipFileWrapper = zipFileWrapper; this.mCheckSumGenerator = checkSumGenerator; this.mLogger = logger; this.mSerializeWrapper = serializeWrapper; this.mSummary = new BundleSummary(); }