Git Product home page Git Product logo

carlib's Introduction

CarLib

Build status codecov

The library includes commonly used functions during the development work.

TimeSpan.ToReadableString

Get the friendly formated display string for specified time span, e.g.

var timespan = new TimeSpan(2, 0, 25);
var friendlyString = timespan.ToReadableString();
// friendlyString is "2 Hour(s) 25 Second(s)".

TimeSpan.ToTimeEstimationString

Get the friendly formated display string for time , e.g.

var timespan = new TimeSpan(2, 0, 25);
var estimationString = timespan.ToTimeEstimationString();
// estimationString is "About 2 Hour(s) 25 Second(s)".

FileSizeFormatter.GetReadableFileSize

Provides the human readable format for the specified file size. e.g.

var fileSize = FileSizeFormatter.GetReadableFileSize(1024 * 1024 * 1.5);
// fileSize is "1.5 MB".
var fileSize = FileSizeFormatter.GetReadableFileSize(@"c:\temp\123.txt");
// fileSize is "112 KB".

PathUtilities.AddTrailingBackslash

Add the trailing slash at the end of specified path just when needed. e.g.

const string testDirectory = @"C:\folder\";
var actual = PathUtilities.AddTrailingBackslash(testDirectory);
// actual is "C:\folder\".
const string testDirectory = @"  C:/folder  "
var actual = PathUtilities.AddTrailingBackslash(testDirectory);
// actual is C:/folder/

SpecialFolderChecker.InWindowsDirectory

Check if the specified directory in Windows directory or SYSROOT. e.g.

string directory = @"C:\Windows
bool actual = SpecialFolderChecker.InWindowsDirectory(directory);
// actual is True.

SpecialFolderChecker.InUserProfile

Check if the specified directory in the user's profile folder. e.g.

string directory = @"C:\Users\<login user name>";
bool actual = SpecialFolderChecker.InUserProfile(directory);
// actual is True.

FileCopyRemainingTimeCalculator

Helper class to estimate the remaining time on file copy. // Arrange var calc = new FileCopyRemainingTimeCalculator();

calc.ProgressChanged(10, 100);

// suppose pausing for 3 seconds
calc.Pause();
Thread.Sleep(3000);
calc.Resume();

// use 1 second to copy 10 bytes (20 - 10)
Thread.Sleep(1000);
calc.ProgressChanged(20, 100);

// suppose pausing for 1 second
calc.Pause();
Thread.Sleep(1000);
calc.Resume();

// use 1 second to copy 10 bytes (30 - 20)
Thread.Sleep(1000);
calc.ProgressChanged(30, 100);

// suppose pausing for 2 seconds
calc.Pause();
Thread.Sleep(2000);
calc.Resume();

// Act
var actualRemainingTime = calc.EvaluateRemainingTime();

// Assert
AssertSecondsWithTolerance(7, actualRemainingTime.TotalSeconds);

carlib's People

Contributors

carlosliu-becls avatar carlos-liu avatar

Stargazers

dev avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.