This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
namespace System | |
{ | |
public class Throw | |
{ | |
public static void IfIsNull(object value, Exception ex = null) | |
{ | |
if (value == null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
namespace Cryptography | |
{ | |
public class Base64 | |
{ | |
public static string Encrypt(string text) | |
{ | |
Throw.IfIsNullOrEmpty(text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Text; | |
namespace Cryptography | |
{ | |
public class MD5 | |
{ | |
public static string Encrypt(string text) | |
{ | |
Throw.IfIsNullOrEmpty(text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Cryptography; | |
namespace Cryptography | |
{ | |
public class RSA | |
{ | |
public static string Encrypt(string text, string key) | |
{ | |
Throw.IfIsNullOrEmpty(text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Configuration; | |
using System.Linq; | |
namespace Configuration | |
{ | |
public static class AppSetting | |
{ | |
public static bool GetBoolean(string key, bool defaultValue = false) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace System | |
{ | |
public static class IntExtentions | |
{ | |
#region [ Times ] | |
public static void Times(this int self, Action action) | |
{ | |
Throw.IfIsNull(action); | |
Throw.IfLessThanOrEqZero(self); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System.Text; | |
namespace System | |
{ | |
public static class StringExtentions | |
{ | |
public static string RemoveNonNumeric(this string self) | |
{ | |
Throw.IfIsNullOrEmpty(self); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using System.Linq; | |
namespace System | |
{ | |
public static class IEnumerableExtensions | |
{ | |
public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) | |
{ | |
Throw.IfIsNull(action); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace System | |
{ | |
public static class FuncExtentions | |
{ | |
public static Func<T, TResult> Memoize<T, TResult>(this Func<T, TResult> func) | |
{ | |
var cache = new Dictionary<T, TResult>(); | |
Func<T, TResult> memoizeFunc = n => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace System | |
{ | |
public static class DateTimeExtentions | |
{ | |
public static bool IsWeekend(this DateTime self) | |
{ | |
return (self.DayOfWeek == DayOfWeek.Sunday || self.DayOfWeek == DayOfWeek.Saturday); | |
} | |
public static bool IsLeapYear(this DateTime self) |
OlderNewer