Craig’s Utility Library 3.0 Released

12/20/2011

OK, so I should have uploaded this last week but I've been a bit lazy (I'm on vacation). That being said, the big news is that Craig's Utility Library has a new version. However, it's not 2.3 (which would be the next version sequentially) but 3.0. The reason for the jump is that this version is not exactly compatible with the older version. Much of the code has been reworked completely (much of the static methods are now extension methods, etc). Here is just the short list that they would let me put up on CodePlex:

Fixes

  1. Added fix for length of columns when dealing with nvarchars in SQLServer class.
  2. Added fix for Map objects that were set to cascade where ManyToMany and ManyToOne objects underneath were not cascading properly.
  3. Added Any and All functions to ObjectBaseClass that accept SQL Commands/CommandTypes.
  4. Fixed cascading saves for Mapped objects in ORM.
  5. Added check in StringID and StringReference for -1 (max length), so that the validation actually works on update...
  6. Added fix for ZipFile when calling AddFile (now creates the zip file correctly).
  7. Added check to ORM code to make sure that load commands aren't overwritten with defaults.
  8. Fixed issue with ObjectBaseClass if the instance returned by Any is null.
  9. Fixed bug in DataMapper when using the AutoMap feature.
  10. Fixed small bug in RGBHistogram's Equalize function as well as Equalize function in BitmapExtensions.
  11. Fixed issue that allows unsafe code to be tested/run (seems to be related to updating to 4.0).
  12. Fixed bug in Random class's NextColor function.
  13. Fixed issue with ArgsParser code involving double quotes and reduced code a bit.
  14. Fixed minor issues with RSAEncryption class.
  15. Fixed minor issues/made code simpler for Conversion, Matrix, Set, and Vector3 classes.
  16. Fixed a couple of bugs in vector class (initial size of items not set right, removing first item in list, etc.)
  17. Fixed various issues/improved BinaryTree class

Changes

Most static functions have been moved to various extension methods and a number of functions have been added (too many to list here).
On top of that a number of changes have been made to various classes:

  1. Added ability in ProfilerManager to get data for a specific function and made ProfilerInfo public
  2. Changed the parameters of the Column DataClass (now has a generic default value, uses DbType instead of SqlDbType for the DataType property, etc)
  3. Added ability to query list of users who logged into a machine (WMI code)
  4. Added a ClearMappings function to MicroORM.
  5. Updated SQLHelper's code (removed functions that are no longer used, instead keeping generic versions).
  6. Merged AddParameter and AddOutputParameter into one function (and GetParameter and GetOutputParameter) and changed order of a couple parameters.
  7. Updated ErrorManager code to use extension methods moved from the Web namespace (DumpCache, DumpApplicationState, etc).
  8. Updated WebPageThumbnail code to use some default values to make things simpler.
  9. Made TypeMapping class a bit more fluent to make adding mappings easier.
  10. Simplified Validator code and added a number of functions for new validation rules.
  11. Finished adding IoC code (very simple IoC container).
  12. Rewrote LDAP code (simplified).
  13. Reworked some of the Reflection.Emit classes (mostly to reduce redundant functions, replace wordy code, etc.)
  14. Added GenericStringFormatter class (used by FormatString function in the StringExtensions class)
  15. Moved NaiveBayes class to AI namespace.
  16. Improved ListMapping functionality
  17. Added functions to priority queue for adding items, improved Pop functionality.
  18. Added DateSpan class.
  19. Moved Cisco classes to FileFormats namespace

Also Items Have been removed due to the fact that they were either too difficult to maintain or simply not being used:

  1. Removed Youtube code (will eventually replace this with Google API namespace.
  2. Removed FOAF and APML helpers as neither format seem to be used...
  3. Removed Speech namespace (wasn't really maintaining it)...
  4. Removed Pair and Triple classes (not needed with addition of System.Tuple)

This doesn't include the new list of extension methods:

Utilities.DataTypes.ExtensionMethods

  • Array extensions
    • Clear
    • Combine
  • DateTime extensions
    • DaysInMonth
    • DaysLeftInMonth
    • DaysLeftInYear
    • FirstDayOfMonth
    • FirstDayOfWeek
    • FromUnixTime (actually extension for int and long values)
    • IsInFuture
    • IsInPast
    • IsWeekDay
    • IsWeekEnd
    • LastDayOfMonth
    • LastDayOfWeek
    • ToUnix
  • Generic object extensions
    • If
    • NotIf
    • Return
    • Chain
    • Do
    • Execute
  • ICollection extensions
    • AddAndReturn
    • AddRange
    • AddIf
    • AddIfUnique
    • Remove
    • RemoveRange
  • IComparable extensions
    • Between
  • IDictionary extensions
    • Sort
    • SortByValue
  • IEnumerable extensions
    • Exists
    • For
    • ForEach
    • ForParallel
    • ForEachParallel
    • IsNullOrEmpty
    • RemoveDefaults
    • ToArray
    • ToString
    • TrueForAll
    • TryAll
    • TryAllParallel
  • MatchCollection extensions
    • Where
  • string extensions
    • Encode
    • FromBase64
    • Left
    • Right
    • ToBase64
    • ToByteArray
    • ToFirstCharacterUpperCase
    • ToSentenceCapitalize
    • ToTitleCase
    • NumberTimesOccurs
    • Reverse
    • FilterOutText
    • KeepFilterText
    • AlphaNumericOnly
    • AlphaCharactersOnly
    • NumericOnly
    • IsUnicode
    • FormatString
    • RegexFormat
  • Various type conversion/type checking extensions
    • FormatToString
    • IsNotDefault
    • IsDefault
    • IsNotNull
    • IsNull
    • IsNotNullOrDBNull
    • IsNullOrDBNull
    • NullCheck
    • ThrowIfDefault
    • ThrowIfNullOrEmpty
    • ThrowIfNullOrDBNull
    • ToSQLDbType
    • ToDbType
    • ToType
    • TryTo
  • Various value type extensions
    • ToBool (int)
    • ToInt (bool)
    • ToBase64String (byte array)
    • ToEncodedString (byte array)
    • IsUnicode (byte array)
Utilities.IO.ExtensionMethods
  • Serialization extensions
    • ToBinary
    • ToJSON
    • ToSOAP
    • ToXML
    • ToObject
    • JSONToObject
    • SOAPToObject
    • XMLToObject
  • Uri extensions
    • Read
    • ReadBinary
  • Math extensions
    • Betweek
    • Clamp
    • Factorial
    • Max
    • Median
    • Min
    • Mode
    • Pow
    • Round
    • StandardDeviation
    • Sqrt
    • Variance
    • Permute
Utilities.SQL.ExtensionMethods
  • DbCommand extensions
    • AddParameter
    • BeginTransaction
    • ClearParameters
    • Close
    • Commit
    • ExecuteDataSet
    • ExecuteScalar
    • GetOutputParameter
    • Open
    • Rollback
  • DbDataReader extensions
    • GetParameter
Utilities.Compression.ExtensionMethods
  • Compress (both byte arrays and strings)
  • Decompress (both byte arrays and strings)
Utilities.Encryption.ExtensionMethods
  • Hash (Now handles all hash algorithms in one function for both byte arrays and strings)
  • Encrypt (Handles any symmetric encryption algorithm inside .Net)
  • Decrypt (Handles any symmetric encryption algorithm inside .Net)
Utilities.IO.ExtensionMethods
  • DirectoryInfo extensions
    • CopyTo
    • DeleteAll
    • DeleteFiles
    • DeleteFilesNewerThan
    • DeleteFilesOlderThan
    • Size
    • SetAttribute
  • FileInfo extensions
    • Append
    • CompareTo
    • Read
    • ReadBinary
    • Save
    • SaveAsync
    • SetAttributes
  • String extensions
    • RemoveIllegalDirectoryNameCharacters
    • RemoveIllegalFileNameCharacters
Utilities.Web.ExtensionMethods
  • Web related extensions
    • AbsoluteRoot
    • AddScriptFile
    • ContainsHTML
    • HTTPCompress
    • IsEncodingAccepted
    • RelativeRoot
    • RemoveURLIllegalCharacters
    • SetEncoding
    • StripHTML
  • IPAddress extensions
    • GetHostName
  • Minification
    • Combine (can be used for HTML,JavaScript, or CSS)
    • Minify (can be used for HTML, JavaScript, or CSS)
  • HttpRequest extensions
    • IsMobile
Utilities.Image.ExtensionMethods
  • All Bitmap functions were moved
    • Added ToBase64 extension method
    • Added DrawRoundedRectangle extension
  • Screen extensions
    • TakeScreenShot
Utilities.Error.ExtensionMethods
  • Various error related extensions
    • DumpApplicationState
    • DumpCache
    • DumpCookies
    • DumpRequestVariable
    • DumpResponseVariable
    • DumpServerVars
    • DumpSession
Utilities.Reflection.ExtensionMethods
  • Various reflection related extensions
    • CallMethod
    • CreateInstance
    • DumpProperties
    • GetAttribute
    • GetAttributes
    • GetName
    • GetObjects
    • GetProperty
    • GetPropertyGetter
    • GetPropertyName
    • GetPropertyType
    • GetPropertySetter
    • GetTypes
    • IsIEnumerable
    • IsOfType
    • Load
    • LoadAssemblies
    • MarkedWith
    • MakeShallowCopy
    • SetProperty
    • ToLongVersionString
    • ToShortVersionString
Utilities.Environment.ExtensionMethods
  • Process related extensions
    • KillProcessAsync
    • GetInformation

I know that's a long list, but this isn't everything that has been updated. On top of all of that, there is now a set of tests that is available with the code. And I'm working on getting a nightly build going. With the nightly build, I'm going to automatically publish to NuGet. So if you're using NuGet to get it, you're going to be getting the nightly build. Anyway, that's it for this post. So download the code, leave comments, and happy coding.



Comments