public void Test()
        {
            InvitationRequest request = new InvitationRequest(1111);
            this.TestFactory(request);

            InvitationAck ack = new InvitationAck(2222);
            this.TestFactory(ack);

            byte[] data = { 12, 34, 56 };
            FileDataResponse dataResponse = new FileDataResponse(data, 3333);
            this.TestFactory(dataResponse);

            FileEvent e1 = new FileEvent();
            e1.Name = "1234";
            List<FileEvent> lf = new List<FileEvent>();
            lf.Add(e1);
            PatchRequest patchRequest = new PatchRequest(lf, 4444);
            this.TestFactory(patchRequest);

            PeerList peerList = PeerList.GetPeerList("abc");
            peerList.AddPeer(new Peer("127.0.0.1", 5555));
            PeerListMessage pm = new PeerListMessage(peerList, 6666);
            this.TestFactory(pm);

            SyncAck syncAck = new SyncAck(7777);
            this.TestFactory(syncAck);

            SyncRequest syncRequest = new SyncRequest(8888);
            this.TestFactory(syncRequest);

            File.WriteAllText(".Distribox/VersionList.txt", "[]");
            VersionList vl = new VersionList();
            VersionListMessage vm = new VersionListMessage(vl, 9999);
            this.TestFactory(vm);
        }
예제 #2
0
        /// <summary>
        /// Gets all version that exist in <paramref name="list"/> but not exist in this
        /// </summary>
        /// <returns>The less than.</returns>
        /// <param name="list">The list.</param>
        public List <FileEvent> GetLessThan(VersionList list)
        {
            HashSet <string> myFileList = new HashSet <string>();

            foreach (var item in this.AllFiles)
            {
                foreach (var history in item.History)
                {
                    myFileList.Add(item.Id + "@" + history.Serialize());
                }
            }

            List <FileEvent> patches = new List <FileEvent>();

            foreach (var item in list.AllFiles)
            {
                foreach (var history in item.History)
                {
                    string guid = item.Id + "@" + history.Serialize();
                    if (myFileList.Contains(guid))
                    {
                        continue;
                    }

                    patches.Add(history);
                }
            }

            return(patches);
        }
예제 #3
0
        /// <summary>
        /// Gets all version that exist in <paramref name="list"/> but not exist in this
        /// </summary>
        /// <returns>The less than.</returns>
        /// <param name="list">The list.</param>
        public List<FileEvent> GetLessThan(VersionList list)
        {
            HashSet<string> myFileList = new HashSet<string>();
            foreach (var item in this.AllFiles)
            {
                foreach (var history in item.History)
                {
                    myFileList.Add(item.Id + "@" + history.Serialize());
                }
            }

            List<FileEvent> patches = new List<FileEvent>();
            foreach (var item in list.AllFiles)
            {
                foreach (var history in item.History)
                {
                    string guid = item.Id + "@" + history.Serialize();
                    if (myFileList.Contains(guid))
                    {
                        continue;
                    }

                    patches.Add(history);
                }
            }

            return patches;
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Distribox.Network.VersionListMessage"/> class.
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="myPort">My port.</param>
 public VersionListMessage(VersionList list, int myPort)
     : base(myPort)
 {
     this.List = list;
     this.Type = MessageType.VersionListMessage;
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Distribox.FileSystem.VersionControl"/> class.
 /// </summary>
 public VersionControl()
 {
     VersionList = new VersionList();
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Distribox.FileSystem.VersionControl"/> class.
 /// </summary>
 public VersionControl()
 {
     VersionList = new VersionList();
 }
예제 #7
0
        public void GetLessThanTest()
        {
            var vl1 = new VersionList();
            vl1.AllFiles = this.list;

            var vl2 = new VersionList();
            vl2.GetLessThan(vl1);
        }