Example #1
0
        /// <summary>Finds out if this connection and another are the same.</summary>
        /// <param name="obj">obj to compare</param>
        /// <returns>True if the ID of this transfer equals the other's, or if the object is a string and the filename is the same, or if the object is a string or integer if its the same to the ID</returns>
        public override bool Equals(object obj)
        {
            LBLServerTransfer OtherTransfer = obj as LBLServerTransfer;
            string            OtherFilename = obj.ToString();

            return(OtherTransfer?.ID == ID || OtherFilename.ToUpper() == Filename.ToUpper() || OtherFilename == ID.ToString());
        }
Example #2
0
        /// <summary>Creates a transfer</summary>
        /// <param name="Type"></param>
        /// <param name="Overwrite"></param>
        /// <param name="Filename"></param>
        /// <returns>ID of the new transfer</returns>
        public string CreateTransfer(LBLServerTransfer.LBLTransferType Type, bool Overwrite, String Filename)
        {
            int ID;

            do
            {
                ID = GenerateID();
            } while(Transfers.ContainsKey(ID));                         //Generate IDs until there's an ID that isn't there yet

            //Create the actual transfer and add it to the map
            LBLServerTransfer Transfer = new LBLServerTransfer(ID, RootDir, Filename, Overwrite, Type);

            Transfers.TryAdd(ID, Transfer);

            //Return the needed info
            if (Type == LBLServerTransfer.LBLTransferType.Send)
            {
                return(ID.ToString() + ":" + Transfer.LineCount);
            }
            return(ID.ToString());
        }