InABox.Core
Observable object with INotifyPropertyChanged implemented
Get all the child properties of an object that match a given type
The class of property to search for
The object to search
A list of the objects found
Get all list properties of an object that are collections of a given type
The class of child object to search for
The object to search
A list of the collections found
[ public static object GetDefault(this Type type) ]
Retrieves the default value for a given Type
The Type for which to get the default value
The default value for
If a null Type, a reference Type, or a System.Void Type is supplied, this method always returns null. If
a value type
is supplied which is not publicly visible or which contains generic parameters, this method will fail
with an
exception.
To use this method in its native, non-extension form, make a call like:
object Default = DefaultValue.GetDefault(someType);
To use this method in its Type-extension form, make a call like:
object Default = someType.GetDefault();
[ public static T GetDefault< T >() ]
Retrieves the default value for a given Type
The Type for which to get the default value
The default value for Type T
If a reference Type or a System.Void Type is supplied, this method always returns null. If a value type
is supplied which is not publicly visible or which contains generic parameters, this method will fail
with an
exception.
[ public static bool IsObjectSetToDefault(this Type ObjectType, object ObjectValue) ]
Reports whether a value of type T (or a null reference of type T) contains the default value for that
Type
Reports whether the object is empty or unitialized for a reference type or nullable value type (i.e. is
null) or
whether the object contains a default value for a non-nullable value type (i.e. int = 0, bool = false,
etc.)
NOTE: For non-nullable value types, this method introduces a boxing/unboxing performance penalty.
Type of the object to test
The object value to test, or null for a reference Type or nullable value Type
true = The object contains the default value for its Type.
false = The object has been changed from its default value.
Get the deep clone of an object.
The type of the obj.
It is the object used to deep clone.
Return the deep clone.
The method implements deep clone using reflection.
It is the object used to deep clone.
Return the deep clone.
Compares two values and returns if they are the same.
Implements a 32-bit CRC hash algorithm compatible with Zip etc.
Crc32 should only be used for backward compatibility with older file formats
and algorithms. It is not secure enough for new applications.
If you need to call multiple times for the same data either use the HashAlgorithm
interface or remember that the result of one Compute call needs to be ~ (XOR) before
being passed in as the seed for the next Compute call.
Initializes an instance of the ObservableConcurrentDictionary class.
Event raised when the collection changes.
Event raised when a property on the collection changes.
Notifies observers of CollectionChanged or PropertyChanged of an update to the dictionary.
Attempts to add an item to the dictionary, notifying observers of any changes.
The item to be added.
Whether the add was successful.
Attempts to add an item to the dictionary, notifying observers of any changes.
The key of the item to be added.
The value of the item to be added.
Whether the add was successful.
Attempts to remove an item from the dictionary, notifying observers of any changes.
The key of the item to be removed.
The value of the item removed.
Whether the removal was successful.
Attempts to add or update an item in the dictionary, notifying observers of any changes.
The key of the item to be updated.
The new value to set for the item.
Whether the update was successful.
Begin an expression chain
Default return value if the chanin is ended early
A lambda expression stub
Blocks while condition is true or timeout occurs.
The condition that will perpetuate the block.
The frequency at which the condition will be check, in milliseconds.
Timeout in milliseconds.
Blocks until condition is true or timeout occurs.
The break condition.
The frequency at which the condition will be checked.
The timeout in milliseconds.
Custom string formatter for TimeSpan that allows easy retrieval of Total segments.
TimeSpan myTimeSpan = new TimeSpan(27, 13, 5);
string.Format("{0:th,###}h {0:mm}m {0:ss}s", myTimeSpan) -> "27h 13m 05s"
string.Format("{0:TH}", myTimeSpan) -> "27.2180555555556"
NOTE: myTimeSpan.ToString("TH") does not work. See Remarks.
Due to a quirk of .NET Framework (up through version 4.5.1),
TimeSpan.ToString(format, new TimeSpanFormatter())
will not work; it will always call
TimeSpanFormat.FormatCustomized() which takes a DateTimeFormatInfo rather than an
IFormatProvider/ICustomFormatter. DateTimeFormatInfo, unfortunately, is a sealed class.
Used to create a wrapper format string with the specified format.
IFormatProvider.GetFormat implementation.
Determines whether the specified format is looking for a total, and formats it accordingly.
If not, returns the default format for the given format of a TimeSpan.
The formatted string for the given TimeSpan.
ICustomFormatter.Format implementation.
Returns the formatted value when we don't know what to do with their specified format.
Loads a string through .Load() instead of .LoadXml()
This prevents character encoding problems.