예제 #1
0
        private string GenerateProgressMessage(Uri uri, long?bytesDownloaded = null, long?totalBytes = null, int?progressPercentage = null, double?speed = null)
        {
            var strBldr = new StringBuilder();

            strBldr.AppendFormat("Downloading: {0}", uri);
            if (bytesDownloaded.HasValue && totalBytes.HasValue)
            {
                // A workaround for a bug in Mono misreporting TotalBytesToReceive
                // https://github.com/mono/mono/issues/9808
                if (totalBytes == -1)
                {
                    strBldr.AppendFormat("\nProgress: {0}B downloaded", Misc.NormalizeBinary(bytesDownloaded.Value));
                }
                else
                {
                    strBldr.AppendFormat("\nProgress: {0}% ({1}B/{2}B)", progressPercentage, Misc.NormalizeBinary(bytesDownloaded.Value), Misc.NormalizeBinary(totalBytes.Value));
                }
            }
            if (speed != null)
            {
                double val;
                string unit;

                Misc.CalculateUnitSuffix(speed.Value, out val, out unit);
                strBldr.AppendFormat("\nSpeed: {0:F2}{1}/s", val, unit);
            }
            return(strBldr.Append(".").ToString());
        }
 public override string ToString()
 {
     return(Misc.PrettyPrintCollectionHex(segments));
 }
예제 #3
0
 public void Scan(string path, bool recursive = false)
 {
     lock (dictSync)
     {
         Logger.LogAs(this, LogLevel.Noisy, "Scanning directory {0}.", path);
         var stopwatch = Stopwatch.StartNew();
         ClearExtensionMethodsCache();
         BuildAssemblyCache();
         ScanInner(path, recursive);
         assemblyFromAssemblyPath = null;
         stopwatch.Stop();
         Logger.LogAs(this, LogLevel.Noisy, "Scanning took {0}s, there are now {1} types in dictionaries.", Misc.NormalizeDecimal(stopwatch.Elapsed.TotalSeconds),
                      GetTypeCount());
     }
 }