Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 5
0
 static void SetSerializerIfNull(ref ISerializeWrapper serializer)
 {
     if (serializer == null)
     {
         serializer = XMLSerializeWrapper.Default;
     }
 }
Exemplo n.º 6
0
 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);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 11
0
        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();
        }
Exemplo n.º 12
0
        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;
        }
Exemplo n.º 16
0
 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);
 }
Exemplo n.º 17
0
 public WebAPIHub(string address, string apiKey, ISerializeWrapper serializer)
 {
     this.Address    = address;
     this.APIKey     = apiKey;
     this.Serializer = serializer;
 }
Exemplo n.º 18
0
 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);
Exemplo n.º 19
0
 void Initialize(ISerializeWrapper serializer)
 {
     this.Data   = new TestData();
     this.People = new CRUDCollection <TestPerson>(this.Data.People);
     this.Teams  = new CRUDCollection <TestTeam>(this.Data.Teams);
 }
Exemplo n.º 20
0
        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));
        }
Exemplo n.º 21
0
 public CRUDCollection(IList <T> items, ISerializeWrapper serializer, bool isAutoSave, Action <IList <T>, ISerializeWrapper> saveAction)
 {
     this.Initialize(items, serializer, isAutoSave, saveAction);
 }
Exemplo n.º 22
0
 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()));
 }
Exemplo n.º 23
0
 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)));
 }
Exemplo n.º 24
0
 internal TestClient(ISerializeWrapper serializer)
 {
     this.Initialize(serializer);
 }
Exemplo n.º 25
0
        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();
        }