![]() |
VOOZH | about |
dotnet add package RedCorners --version 18.0.0
NuGet\Install-Package RedCorners -Version 18.0.0
<PackageReference Include="RedCorners" Version="18.0.0" />
<PackageVersion Include="RedCorners" Version="18.0.0" />Directory.Packages.props
<PackageReference Include="RedCorners" />Project file
paket add RedCorners --version 18.0.0
#r "nuget: RedCorners, 18.0.0"
#:package RedCorners@18.0.0
#addin nuget:?package=RedCorners&version=18.0.0Install as a Cake Addin
#tool nuget:?package=RedCorners&version=18.0.0Install as a Cake Tool
RedCorners brings some neat utilities to your C# projects.
For more documentation, visit https://redcorners.com/core/
RedCorners offers a number of extension methods to boost productivity. All extensions are under the RedCorners namespace:
using RedCorners;
This method returns the first take=20 characters of a non-null string. If the original input has less of equal to take characters, the original string is returned, otherwise the output contains the first take characters from the input, followed by ..., making it a take+3 characters output.
In case the input is null, an empty string is returned.
Examples:
Console.WriteLine($"Hello, World! This is a very long text.".Head());
Console.WriteLine($"Hello, World! This is a very long text.".Head(100));
// Hello, World! This i...
// Hello, World! This is a very long text.
This method takes a string as an input, and returns a HashSet<string> containing the hashtags mentioned in the input. If the input is null, an empty HashSet<string> is returned.
Hashtags are converted to LowerInvariant forms.
Example:
string input = "Hello #World #EVERYBODY!";
var hashtags = input.Hashtags();
Console.WriteLine($"Hashtags: {string.Join(" ", hashtags)}");
// Hashtags: #world #everybody
string.RemoveDuplicateTags(bool humanFormatted = false, string separator = ",")
This method takes a separator separated input containing tags, removes duplicate tags, trims tags and converts them to lowercase, and returns a new string with the result. If humanFormatted is true, the output tags will have a space between them. Example:
Console.WriteLine("food, Drinks, FooD,fun".RemoveDuplicateTags());
Console.WriteLine("food, Drinks, FooD,fun".RemoveDuplicateTags(true));
// food,drinks,fun
// food, drinks, fun
This method returns a string without the specified prefix. If the input is null, null is returned. Examples:
Console.WriteLine("Hello, World!".RemovePrefix("Hello"));
Console.WriteLine("Hello, World!".RemovePrefix("Foo"));
// , World!
// Hello, World!
This method returns true if the input is a valid email address. It relies on System.Net.Mail.MailAddress. Example:
Assert("foo@hotmail.com");
Assert(!"not an email address");
This method takes a path as its input, creates that path if it doesn't exist, and returns the input. It is useful when chained with other I/O actions. Example:
this.FilePath = Path
.Combine(basePath, "ObjectStorage", bucket, typeFileName)
.CreateDirectoryAndReturn();
This method returns a UTC DateTime equivalent to the input long in milliseconds. Example:
long epoch = 1557738320000;
Console.WriteLine(epoch.DateFromEpochMs());
// 5/13/2019 9:05:20 AM
This method is the opposite of long.DateFromEpochMs(), where it converts a DateTime to epoch milliseconds, as long.
This method returns the week number for the input DateTime, relative to 2019-03-11.
This method returns the DateTime for the first day of the input week number. Example:
DateTime input = DateTime.UtcNow;
Console.WriteLine(input);
int weekNumber = input.ToWeekNumber();
Console.WriteLine(weekNumber);
Console.WriteLine(weekNumber.GetFirstDayOfWeek());
weekNumber++;
Console.WriteLine(weekNumber.GetFirstDayOfWeek());
// 5/13/2019 9:20:15 AM
// 9
// 5/13/2019 12:00:00 AM
// 5/20/2019 12:00:00 AM
This method returns the DateTime for the first day of the next week. Identical to:
(weeknumber + 1).GetFirstDayOfWeek();
RedCorners provides extensions that facilitate converting data where models have different base classes, but share some properties.
This method looks at the properties of the destination object, and where there is an identical property in the source, it copies the value of the source to that property of the destination. Example:
class Contact
{
public int Id { get; set; }
public int Name { get; set; }
public int Email { get; set; }
}
class UpdateContactModel
{
public int Name { get; set; }
public int Email { get; set; }
}
...
Contact original = new Contact {
Id = 10,
Name = "John",
Email = "john@redcorners.com"
};
UpdateContactModel update = new UpdateContactModel {
Name = "Sarah",
Email = "sarah@redcorners.com"
};
// Inject Name and Email from [update] to [original]
update.Inject(original);
Console.WriteLine(original.Id);
// Prints [10], because UpdateContactModel doesn't have a property named [Id]
Console.WriteLine(original.Name);
// Prints [Sarah], because it was injected from the UpdateContactModel
This method injects an object to a new object of type T and returns the new T. Example:
Contact contact = update.ReturnAs<Contact>();
Console.WriteLine(original.Id);
// Prints [0], because UpdateContactModel doesn't have a property named [Id], so the default(int) is used.
Console.WriteLine(original.Name);
// Prints [Sarah], because it was injected from the UpdateContactModel
This method returns a list of objects of type T from an arbitrary list of objects of any type, by doing one-by-one Injects.
Components are under the RedCorners.Components namespace.
RedCorners.Components.Benchmark is using a Stopwatch to time some actions. Example:
Benchmark benchmark = new Benchmark();
await Task.Delay(1234);
Console.WriteLine(benchmark.ToString());
await Task.Delay(4321);
Console.WriteLine(benchmark.StopToString());
// 1.24s
// 5.57s
Stops the timer and returns the duration as a TimeSpan.
Returns the duration as a string with two decimal points and the s prefix. Does not stop the timer, and can be used multiple times.
Same as ToString(), but stops the timer.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on RedCorners:
| Package | Downloads |
|---|---|
|
RedCorners.Forms
Side Bar, Tabbed View and more for your Xamarin.Forms projects. |
|
|
RedCorners.Forms.GoogleMaps
Advanced Google Maps for Xamarin Forms (iOS and Android). |
|
|
RedCorners.Components.ObjectStorage
Easy cross-platform storage of settings as JSON in C#. |
|
|
POIWorld.Client
Client for POIWorld and Wikidata |
|
|
RedCorners.ApiClient
API Client for RedCorners Backends. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 18.0.0 | 1,785 | 12/4/2022 |
| 17.0.0 | 678 | 12/4/2022 |
| 16.0.0 | 476 | 12/4/2022 |
| 15.0.0 | 496 | 12/4/2022 |
| 14.0.0 | 4,879 | 5/29/2022 |
| 13.0.0 | 1,820 | 5/27/2022 |
| 12.0.0 | 601 | 5/22/2022 |
| 11.0.0 | 641 | 5/7/2022 |
| 10.0.0 | 616 | 5/6/2022 |
| 9.0.1 | 667 | 4/11/2022 |
| 9.0.0 | 629 | 4/11/2022 |
| 8.0.0 | 35,498 | 2/26/2020 |
| 7.0.0 | 1,071 | 1/28/2020 |
| 6.0.0 | 5,085 | 12/18/2019 |
| 5.0.0 | 12,386 | 7/7/2019 |
| 4.11.0 | 2,304 | 6/20/2019 |
| 4.10.0 | 1,821 | 6/18/2019 |
| 4.1.4 | 987 | 6/17/2019 |
| 4.1.3 | 778 | 6/17/2019 |
| 4.1.2 | 4,722 | 5/17/2019 |
RedCorners brings some neat utilities to your C# projects.