[ROOT] / doc / toc / ARCCore / Class / Extensions

AddValue , ForEach , GetValue , KeysAsString , Result , Single , SingleOrDefault , ToStringDateAndTime , ToStringDB , ToStringShort , ToStringVeryShort , ToStringWithMS , Use


Contains a few general nice to have extensions methods.

TODO: If this class accumulates too many methods, consider splitting it into multiple classes in a separate folder.
TODO: For instance a TypeExtensions class and DictionaryExtensions class would be natural.
TODO: (together with maybe a StringExtensionClass).

NOTE: Message to developers. Think through before you decide on adding anything to this class. It should really be kept as small as possible.
NOTE: Often a utility method in a related class is good enough.

See also UtilCore.


AddValueGives better error messages compared to 'original' Add when adding a value to a directory if key already exists
ForEachUseful when we want to write collection.ForEach( ... ) instead of
GetValueGives better error messages when reading value from directory if key does not exist
KeysAsStringGives a compressed overview of keys in a dictionary. Helpful for building exception messages.
ResultReturns heading plus return-value of function (calls function). If function == null then empty string is returned
SingleSame as inbuilt LINQ's Single except that gives a more friendly exception message
SingleOrDefaultSame as inbuilt LINQ's SingleOrDefault except that gives a more friendly exception message
ToStringDateAndTimeUses format 'yyyy-MM-dd HH:mm:ss.fff'.
ToStringDBGives the minimum representation of type as string suitable for later reconstruction by GetType.
ToStringShortReturns a shorter representation than ToStringDB.
ToStringVeryShortReturns same as ToStringShort but without any generics information at all.
ToStringWithMSUses either format 'd\.hh\:mm\:ss\.fff' or 'hh\:mm\:ss\.fff' depending on TotalHours >=24 hours or not.
UseConvenience method that shortens down code in cases where an instance of an object must be created first in order to use that same variable multiple times

Details

Generated 2024-03-29 09:02:28.809 UTC