25 January 2021

Extensions 2.0.1 Major version update released!

On Friday morning a major version update of Extensions was released.  The new version brings with it a TON of new extension methods for C# such as:

  1. Most notable is the .Save() and .Load() methods added to the System.Object class.  This allows any object to be serialized to and from disk very rapidly e.g.:

    (object)MyClass.Save(<FilePath>);

    and

    (MyClassDefinition)MyClass = (object)MyClass.Load(<FilePath>);

  2. A series of extensions was added to the System.Double class allowing any number cast as a double to be quickly converted between binary data sizes e.g.:

    double SizeInTB = 2;
    double SizeInKB = SizeInTB.ToKB(Constants.NumberByte.TB);

    Which will return 2,147,483,648 i.e. the number of KB in 2 TB.

  3. A series of extensions was added to both the System.String and Sytem.Text.StringBuilder classes that make it easy to validate strong passwords e.g.:

    string MyPassword = Console.Readline();
    if (MyPassword.IsStrong())
    {
        //Pass.  Input is a strong password.
    }
    else
    {
        //Fail.  Input is NOT a strong password.
    }

    Even better is if you want to exclude say symbols or special characters requiring users to only use upper case, lower case and numbers, you can override the default parameters e.g.:

    if (MyPassword.IsStrong(true, true, true, false))

    The component methods of .IsStrong() can also be used independently e.g.

    MyPassword.HasUpper()
    MyPassword.HasLower()
    MyPassword.HasNumeric()
    MyPassword.HasSymbol()


  4. A series of extensions was added to both the System.String and Sytem.Text.StringBuilder classes that make it easy to validate if a string is a valid US Zip code e.g.:

    MyString.IsZipCode()

    The method handles both 5 digit and 9 digit zip codes.

  5. Extension methods was also added to make other string based operations easier e.g.

    MyString.IsLower()
    MyString.IsUpper()

  6. Extension methods from previous versions were enhanced by adding the option to ignore white space as part of these methods:

    MyString.IsAlphabetic()
    MyString.IsAlphaNumeric()
    MyString.IsNumeric()

  7. On the lighter side of things, if you've ever wondered what it was like to live in the Morse Code era, you can leverage to silly methods to see for yourself like this:

    "My message I want to send".ToMorseCode().MorseCodeBeep();

For a more detail of what Extensions offer, see:







Add Extensions to your toolbox and make your coding life a little easier.  

Happy coding
C

No comments:

Post a Comment

Comments are moderated only for the purpose of keeping pesky spammers at bay.

SharePoint Remote Event Receivers are DEAD!!!

 Well, the time has finally come.  It was evident when Microsoft started pushing everyone to WebHooks, but this FAQ and related announcement...