public static void Add(DownLoader pDownLoader)
 {
     if (!Instance.sDownLoadMap.ContainsKey(pDownLoader.Key))
     {
         Instance.sDownLoadMap.Add(pDownLoader.Key, pDownLoader);
         Instance.sWaitDownLoad.Add(pDownLoader);
         isNeedSort = true;
     }
 }
        public static DownLoader DownLoadFileAsync(string sourceurl, string destination, string pFileName, string pMD5, long pLength, System.Action <DownLoader> finished, System.Action <DownLoader> progress = null, bool isClear = true)
        {
            DownLoader ret = null;

            if (Instance.sDownLoadMap.ContainsKey(sourceurl))
            {
                Debug.LogWarning("the file is downloading.url = " + sourceurl);
                ret = (DownLoader)Instance.sDownLoadMap[sourceurl];
            }
            else
            {
                ret = new DownLoader(sourceurl, destination, pFileName, pMD5, pLength, isClear);
            }
            DownLoadFileAsync(ret, finished, progress, isClear);
            return(ret);
        }
        public DownLoader AddByUrl(string pSourceurl, string pDestination, string pFileName, string pMD5, long pLength, bool pClear)
        {
            if (State != DownloadState.normal)
            {
                Debug.LogError("the group is downloading.");
                return(null);
            }
            if (IsHaveURL(pSourceurl))
            {
                return(null);
            }
            DownLoader ret = new DownLoader(pSourceurl, pDestination, pFileName, pMD5, pLength, pClear);

            Add(ret);
            return(ret);
        }
        public static void DownLoadFileAsync(DownLoader pLoader, System.Action <DownLoader> finished, System.Action <DownLoader> progress = null, bool isClear = true)
        {
            if (pLoader == null)
            {
                return;
            }
            if (finished != null)
            {
                pLoader.OnComplete += finished;
            }
            if (progress != null)
            {
                pLoader.OnProgress += progress;
            }

            Add(pLoader);
        }
        private void OnDestroy()
        {
            ArrayList tkeys = new ArrayList(sDownLoadMap.Keys);

            for (int i = 0, length = tkeys.Count; i < length; i++)
            {
                object     tk   = tkeys[i];
                DownLoader item = (DownLoader)sDownLoadMap[tk];
                item.Dispose();
            }

            ArrayList tgkeys = new ArrayList(sGroupMap.Keys);

            for (int i = 0, length = tgkeys.Count; i < length; i++)
            {
                object        tk   = tgkeys[i];
                DownLoadGroup item = (DownLoadGroup)sGroupMap[tk];
                item.Dispose();
            }
        }
 public static int Compare(DownLoader a, DownLoader b)
 {
     return(a.priority.CompareTo(b.priority));
 }
 private void Add(DownLoader newObject)
 {
     groupList.Add(newObject);
 }