MiscUtil Class allowing a user to choose a console application to run, after examining an assembly for all classes containing a static Main method, either parameterless or with a string array parameter. Displays entry points and prompts the user to choose one. Type within the assembly containing the applications. This type is not included in the list of entry points to run. Arguments to pass in for methods which have a single string[] parameter. Returns the entry point for a method, or null if no entry points can be used. An entry point taking string[] is preferred to one with no parameters. Exception thrown to indicate that a buffer of the desired size cannot be acquired. Creates an instance of this class with the given message. Type of buffer returned by CachingBufferManager. Interface encapsulating a byte array which may be managed by an IBufferManager implementation. When the buffer is disposed, some implementations of this interface may return the buffer to the IBufferManager which created it. Note that an IBuffer *must* always be disposed after use, or some implementations may leak memory. The buffer must not be used after being disposed, likewise the byte array must not be used after the buffer is disposed. Returns the byte array encapsulated by this buffer. Note that depending on the buffer manager providing the buffer, the array may or may not be cleared (i.e. with every byte 0) to start with. An implementation of IBufferManager which keeps a cache of buffers. The precise behaviour is controlled by the nested Options class. This class is safe to use from multiple threads, but buffers returned are not inherently thread safe (although they have no thread affinity). Interface for classes which manage instances of IBuffer. Returns a buffer of the given size or greater. The minimum size of buffer to return This manager is unable to return a buffer of the appropriate size minimumSize is less than or equal to 0 Options configurating this manager. List of bands. Each entry is an array of size MaxBuffersPerSizeBand. Each entry of that array is either null or a buffer, which may or may not be in use. The first entry in the list consists of buffers of size MinBufferSize, then MinBufferSize*ScalingFactor etc. Lock for member access. 5 seconds should be more than adequate as a timeout. Creates a caching buffer manager configured with the default options (as per a freshly created instance of Options). Creates a caching buffer manager configured with the specified options. Note that the options are cloned - any changes to the options passed in after construction will have no effect on the manager. The configuration options for this manager. The configuration is invalid Returns a buffer of the given size or greater. If the buffer could not be taken from a pool, and the ActionOnBufferUnavailable is set to ThrowException, or if the specified size is greater than the maximum buffer size. If minimumSize is less than 0. Works out the size of the next band up from the current size. This is based on the scaling factor in the options, the maximum buffer size, and the requirement that the returned size should always be greater than the original one. (This is achieved using Ceiling - the worst case is when size is 1 and the scaling factor is 1.25, whereupon Ceiling will return 2.) Finds an available buffer from the list, creating a new buffer where appropriate. Index into the list of buffer slots Size of buffer to create if necessary An available buffer, or null if none are available in the given band. Provides options for CachingBufferManager. Strongly typed Clone implementation. A clone of these options Weakly typed Clone implementation. The maximum number of buffers to keep for each size band. When a buffer is requested from one size band, if none are available and this many buffers have already been allocated, a buffer from the next size band is returned (using the same algorithm). Defaults to 16; must not be less than 1. The minimum buffer size to use, in bytes. If a buffer less than this size is requested, this is the size that will actually be used. Must be at least 1. On construction of the CachingBufferManager, this must not be greater than MaxBufferSize. Defaults to 1024. Whether buffers are cleared (i.e. all bytes set to 0) after they are disposed. Defaults to true. For situations where buffers do not contain any sensitive information, and all clients know to only use data they have specifically put into the buffer (e.g. when copying streams), this may be set to false for efficiency. The scaling factor for sizes of buffers. The smallest buffer is of size MinBufferSize, then the next smallest is MinBufferSize*ScalingFactor, and so forth. The default is 2.0, so with the default buffer size of 1K, buffers will be 1K, 2K, 4K, 8K etc. The value must be greater than or equal to 1.25. The maximum size of buffer to return, or 0 for no maximum. This is primarily used with an ActionOnBufferUnavailable of UseBigger, which could potentially create bigger and bigger buffers. If a buffer of a size greater than this is requested, a BufferAcquisitionException will be thrown. Defaults to Int32.MaxValue. The value must be greater than 0. On construction of the CachingBufferManager, this must not be less than MinBufferSize. Determines the action to take when a buffer of the most appropriate size is unavailable. Defaults to ReturnUncached. Enumeration of options available when a buffer of the most appropriate size is unavailable. A buffer of the next size band up is returned, or the size band above that, etc, until the maximum size is reached, at which point this fails over to ReturnUncached. A buffer of exactly the right size is returned, but one which when disposed does not return the buffer to a cache. A BufferAcquisitionException is thrown. Implementation of the Adler32 checksum routine. TODO: Derive from HashAlgorithm. Base for modulo arithmetic Number of iterations we can safely do before applying the modulo. Computes the Adler32 checksum for the given data. Initial value or previous result. Use 1 for the first transformation. The data to compute the checksum of Index of first byte to compute checksum for Number of bytes to compute checksum for The checksum of the given data Computes the Adler32 checksum for the given data. Initial value or previous result. Use 1 for the first transformation. The data to compute the checksum of The checksum of the given data Computes the checksum for a stream, starting from the current position and reading until no more can be read The stream to compute the checksum for The checksum for the stream Computes the checksum of a file The file to compute the checksum of The checksum for the file Utility to build an IComparer implementation from a Comparison delegate, and a static method to do the reverse. Creates a new instance which will proxy to the given Comparison delegate when called. Comparison delegate to proxy to. Must not be null. Implementation of IComparer.Compare which simply proxies to the originally specified Comparison delegate. Creates a Comparison delegate from the given Comparer. Comparer to use when the returned delegate is called. Must not be null. A Comparison delegate which proxies to the given Comparer. Map from types to instances of those types, e.g. int to 10 and string to "hi" within the same dictionary. This cannot be done without casting (and boxing for value types) as .NET cannot represent this relationship with generics in their current form. This class encapsulates the nastiness in a single place. Maps the specified type argument to the given value. If the type argument already has a value within the dictionary, ArgumentException is thrown. Maps the specified type argument to the given value. If the type argument already has a value within the dictionary, it is overwritten. Attempts to fetch a value from the dictionary, throwing a KeyNotFoundException if the specified type argument has no entry in the dictionary. Attempts to fetch a value from the dictionary, returning false and setting the output parameter to the default value for T if it fails, or returning true and setting the output parameter to the fetched value if it succeeds. Extensions to IComparer Reverses the original comparer; if it was already a reverse comparer, the previous version was reversed (rather than reversing twice). In other words, for any comparer X, X==X.Reverse().Reverse(). Combines a comparer with a second comparer to implement composite sort behaviour. Combines a comparer with a projection to implement composite sort behaviour. Extensions to IDictionary Returns the value associated with the specified key if there already is one, or inserts a new value for the specified key and returns that. Type of key Type of value, which must either have a public parameterless constructor or be a value type Dictionary to access Key to lookup Existing value in the dictionary, or new one inserted Returns the value associated with the specified key if there already is one, or calls the specified delegate to create a new value which is stored and returned. Type of key Type of value Dictionary to access Key to lookup Delegate to provide new value if required Existing value in the dictionary, or new one inserted Returns the value associated with the specified key if there already is one, or inserts the specified value and returns it. Type of key Type of value Dictionary to access Key to lookup Value to use when key is missing Existing value in the dictionary, or new one inserted Wrapper methods for SmartEnumerable[T]. Extension method to make life easier. Type of enumerable Source enumerable A new SmartEnumerable of the appropriate type Non-generic class to produce instances of the generic class, optionally using type inference. Creates an instance of ProjectionComparer using the specified projection. Type parameter for the elements to be compared Type parameter for the keys to be compared, after being projected from the elements Projection to use when determining the key of an element A comparer which will compare elements by projecting each element to its key, and comparing keys Creates an instance of ProjectionComparer using the specified projection. The ignored parameter is solely present to aid type inference. Type parameter for the elements to be compared Type parameter for the keys to be compared, after being projected from the elements Value is ignored - type may be used by type inference Projection to use when determining the key of an element A comparer which will compare elements by projecting each element to its key, and comparing keys Class generic in the source only to produce instances of the doubly generic class, optionally using type inference. Creates an instance of ProjectionComparer using the specified projection. Type parameter for the keys to be compared, after being projected from the elements Projection to use when determining the key of an element A comparer which will compare elements by projecting each element to its key, and comparing keys Comparer which projects each element of the comparison to a key, and then compares those keys using the specified (or default) comparer for the key type. Type of elements which this comparer will be asked to compare Type of the key projected from the element Creates a new instance using the specified projection, which must not be null. The default comparer for the projected type is used. Projection to use during comparisons Creates a new instance using the specified projection, which must not be null. Projection to use during comparisons The comparer to use on the keys. May be null, in which case the default comparer will be used. Compares x and y by projecting them to keys and then comparing the keys. Null values are not projected; they obey the standard comparer contract such that two null values are equal; any null value is less than any non-null value. Non-generic class to produce instances of the generic class, optionally using type inference. Creates an instance of ProjectionEqualityComparer using the specified projection. Type parameter for the elements to be compared Type parameter for the keys to be compared, after being projected from the elements Projection to use when determining the key of an element A comparer which will compare elements by projecting each element to its key, and comparing keys Creates an instance of ProjectionEqualityComparer using the specified projection. The ignored parameter is solely present to aid type inference. Type parameter for the elements to be compared Type parameter for the keys to be compared, after being projected from the elements Value is ignored - type may be used by type inference Projection to use when determining the key of an element A comparer which will compare elements by projecting each element to its key, and comparing keys Class generic in the source only to produce instances of the doubly generic class, optionally using type inference. Creates an instance of ProjectionEqualityComparer using the specified projection. Type parameter for the keys to be compared, after being projected from the elements Projection to use when determining the key of an element A comparer which will compare elements by projecting each element to its key, and comparing keys Comparer which projects each element of the comparison to a key, and then compares those keys using the specified (or default) comparer for the key type. Type of elements which this comparer will be asked to compare Type of the key projected from the element Creates a new instance using the specified projection, which must not be null. The default comparer for the projected type is used. Projection to use during comparisons Creates a new instance using the specified projection, which must not be null. Projection to use during comparisons The comparer to use on the keys. May be null, in which case the default comparer will be used. Compares the two specified values for equality by applying the projection to each value and then using the equality comparer on the resulting keys. Null references are never passed to the projection. Produces a hash code for the given value by projecting it and then asking the equality comparer to find the hash code of the resulting key. A class with a similar function to System.Collections.Queue, but allowing random access to the contents of the queue as well as the usual enqueuing at the end and dequeuing at the start. This implementation is not synchronized at all - clients should provide their own synchronization. A SyncRoot is provided for this purpose, although any other common reference may also be used. In order to provide an efficient implementation of both random access and the removal of items from the start of the queue, a circular buffer is used and resized when necessary. The buffer never shrinks unless TrimToSize is called. Default (and minimum) capacity for the buffer containing the elements in the queue. The circular buffer containing the items in the queue The "physical" index of item with logical index 0. Version information for the queue - this is incremented every time the contents of the queue is changed, so that enumerators can detect the change. Initializes a new instance of the RandomAccessQueue class which is empty and has the specified capacity (or the default capacity if that is higher). The initial capacity of the queue Initializes a new instance of the RandomAccessQueue class which is empty and has the default capacity. Private constructor used in cloning The buffer to clone for use in this queue The number of "valid" elements in the buffer The first valid element in the queue Clears the queue without resizing the buffer Resizes the buffer to just fit the current number of items in the queue. The buffer size is never set to less than the default capacity, however. Adds an item to the end of the queue. The item to add to the queue. The value can be a null reference. Adds an object at the specified index. The item to add to the queue. The value can be a null reference. The index of the newly added item Removes an T from the start of the queue, returning it. The item at the head of the queue Removes an item at the given index and returns it. The index of the item to remove The item which has been removed from the Copies the elements of the queue to the given array, beginning at the specified index in the array. The array to copy the contents of the queue into The zero-based index in array at which copying begins Performs a binary search using IComparable. If the value occurs multiple times, there is no guarantee as to which index will be returned. If the value does not occur at all, the bitwise complement of the first index containing a larger value is returned (or the bitwise complement of the size of the queue if the value is larger than any value in the queue). This is the location at which the value should be inserted to preserve sort order. If the list is not sorted according to the appropriate IComparable implementation before this method is calling, the result is not guaranteed. The value passed in must implement IComparable, unless it is null. The IComparable.CompareTo method will be called on the value passed in, with the values in the queue as parameters, rather than the other way round. No test is made to make sure that the types of item are the same - it is up to the implementation of IComparable to throw an exception if incomparable types are presented. A null reference is treated as being less than any item, (so passing in null will always return 0 or -1). The implementation of IComparable is never asked to compare to null. The item to search for A location in the queue containing the item, or the bitwise complement of the first index containing a larger value. Performs a binary search using the specified IComparer. If the value occurs multiple times, there is no guarantee as to which index will be returned. If the value does not occur at all, the bitwise complement of the first index containing a larger value is returned (or the bitwise complement of the size of the queue if the value is larger than any value in the queue). This is the location at which the value should be inserted to preserve sort order. If the list is not sorted according to the appropriate IComparer implementation before this method is calling, the result is not guaranteed. The CompareTo method will be called on the comparer passed in, with the specified value as the first parameter, and values in the queue as the second parameter, rather than the other way round. While a null reference should be treated as being less than any object in most implementations of IComparer, this is not required by this method. Any null references (whether in the queue or the specified value itself) are passed directly to the CompareTo method. This allow for IComparers to reverse the usual order, if required. The object to search for The comparator to use for searching. Must not be null. A location in the queue containing the object, or the bitwise complement of the first index containing a larger value. Performs a binary search using the specified Comparison. If the value occurs multiple times, there is no guarantee as to which index will be returned. If the value does not occur at all, the bitwise complement of the first index containing a larger value is returned (or the bitwise complement of the size of the queue if the value is larger than any value in the queue). This is the location at which the value should be inserted to preserve sort order. If the list is not sorted according to the appropriate IComparer implementation before this method is calling, the result is not guaranteed. The CompareTo method will be called on the comparer passed in, with the specified value as the first parameter, and values in the queue as the second parameter, rather than the other way round. While a null reference should be treated as being less than any object in most implementations of IComparer, this is not required by this method. Any null references (whether in the queue or the specified value itself) are passed directly to the CompareTo method. This allow for Comparisons to reverse the usual order, if required. The object to search for The comparison to use for searching. Must not be null. A location in the queue containing the object, or the bitwise complement of the first index containing a larger value. Returns an enumerator that can iterate through the queue. Note that due to the way C# 2.0 iterators work, we cannot spot changes to the queue after the enumerator was fetched but before MoveNext() is first called. Returns an enumerator for the entire queue. Returns an enumerator that can iterate through the queue. Returns an enumerator for the entire queue. Creates a new queue with the same contents as this queue. The queues are separate, however - adding an item to the returned queue doesn't affect the current queue or vice versa. A new sync root is also supplied. A clone of the current queue Strongly typed version of ICloneable.Clone. Creates a new queue with the same contents as this queue. The queues are separate, however - adding an item to the returned queue doesn't affect the current queue or vice versa. A new sync root is also supplied. A clone of the current queue Resizes the queue to a new capacity, optionally leaving a gap at a specified logical index so that a new item can be slotted in without further copying The new capacity The logical index at which to insert a gap, or -1 for no gap Adds an item to the queue The item to add Returns whether or not the queue contains the given item, using the default EqualityComparer if the item to find is non-null. Copies the elements of the queue to the given array, beginning at the specified index in the array. The array to copy the contents of the queue into The zero-based index in array at which copying begins Removes the given item from the queue, if it is present. The first equal value is removed. The number of items in the queue. Indexer for the class, allowing items to be retrieved by index and replaced. Current capacity of the queue - the size of the buffer. An object reference to synchronize on when using the queue from multiple threads. This reference isn't used anywhere in the class itself. The same reference will always be returned for the same queue, and this will never be the same as the reference returned for a different queue, even a clone. Returns false, to indicate that this queue is not synchronized. Returns false, to indicate that this queue is not read-only. Represents a range of values. An IComparer{T} is used to compare specific values with a start and end point. A range may be include or exclude each end individually. A range which is half-open but has the same start and end point is deemed to be empty, e.g. [3,3) doesn't include 3. To create a range with a single value, use an inclusive range, e.g. [3,3]. Ranges are always immutable - calls such as IncludeEnd() and ExcludeEnd() return a new range without modifying this one. Constructs a new inclusive range using the default comparer Constructs a new range including both ends using the specified comparer Constructs a new range, including or excluding each end as specified, with the given comparer. Returns a range with the same boundaries as this, but excluding the end point. When called on a range already excluding the end point, the original range is returned. Returns a range with the same boundaries as this, but excluding the start point. When called on a range already excluding the start point, the original range is returned. Returns a range with the same boundaries as this, but including the end point. When called on a range already including the end point, the original range is returned. Returns a range with the same boundaries as this, but including the start point. When called on a range already including the start point, the original range is returned. Returns whether or not the range contains the given value Returns an iterator which begins at the start of this range, applying the given step delegate on each iteration until the end is reached or passed. The start and end points are included or excluded according to this range. Delegate to apply to the "current value" on each iteration Returns an iterator which begins at the end of this range, applying the given step delegate on each iteration until the start is reached or passed. The start and end points are included or excluded according to this range. Delegate to apply to the "current value" on each iteration Returns an iterator which begins at the start of this range, adding the given step amount to the current value each iteration until the end is reached or passed. The start and end points are included or excluded according to this range. This method does not check for the availability of an addition operator at compile-time; if you use it on a range where there is no such operator, it will fail at execution time. Amount to add on each iteration Returns an iterator which begins at the end of this range, subtracting the given step amount to the current value each iteration until the start is reached or passed. The start and end points are included or excluded according to this range. This method does not check for the availability of a subtraction operator at compile-time; if you use it on a range where there is no such operator, it will fail at execution time. Amount to subtract on each iteration. Note that this is subtracted, so in a range [0,10] you would pass +2 as this parameter to obtain the sequence (10, 8, 6, 4, 2, 0). Returns an iterator which begins at the start of this range, adding the given step amount to the current value each iteration until the end is reached or passed. The start and end points are included or excluded according to this range. This method does not check for the availability of an addition operator at compile-time; if you use it on a range where there is no such operator, it will fail at execution time. Amount to add on each iteration Returns an iterator which begins at the end of this range, subtracting the given step amount to the current value each iteration until the start is reached or passed. The start and end points are included or excluded according to this range. This method does not check for the availability of a subtraction operator at compile-time; if you use it on a range where there is no such operator, it will fail at execution time. Amount to subtract on each iteration. Note that this is subtracted, so in a range [0,10] you would pass +2 as this parameter to obtain the sequence (10, 8, 6, 4, 2, 0). Returns an iterator which steps through the range, applying the specified step delegate on each iteration. The method determines whether to begin at the start or end of the range based on whether the step delegate appears to go "up" or "down". The step delegate is applied to the start point. If the result is more than the start point, the returned iterator begins at the start point; otherwise it begins at the end point. Delegate to apply to the "current value" on each iteration Returns an iterator which steps through the range, adding the specified amount on each iteration. If the step amount is logically negative, the returned iterator begins at the start point; otherwise it begins at the end point. This method does not check for the availability of an addition operator at compile-time; if you use it on a range where there is no such operator, it will fail at execution time. The amount to add on each iteration Returns an iterator which steps through the range, adding the specified amount on each iteration. If the step amount is logically negative, the returned iterator begins at the end point; otherwise it begins at the start point. This method is equivalent to Step(T stepAmount), but allows an alternative type to be used. The most common example of this is likely to be stepping a range of DateTimes by a TimeSpan. This method does not check for the availability of a suitable addition operator at compile-time; if you use it on a range where there is no such operator, it will fail at execution time. The amount to add on each iteration The start of the range. The end of the range. Comparer to use for comparisons Whether or not this range includes the start point Whether or not this range includes the end point Iterates over a range. Despite its name, this implements IEnumerable{T} rather than IEnumerator{T} - it just sounds better, frankly. Creates an ascending iterator over the given range with the given step function Creates an iterator over the given range with the given step function, with the specified direction. Returns an IEnumerator{T} running over the range. Returns an IEnumerator running over the range. Returns the range this object iterates over Returns the step function used for this range Returns whether or not this iterator works up from the start point (ascending) or down from the end point (descending) Implementation of IComparer{T} based on another one; this simply reverses the original comparison. Creates a new reversing comparer. The original comparer to use for comparisons. Returns the result of comparing the specified values using the original comparer, but reversing the order of comparison. Returns the original comparer; this can be useful to avoid multiple reversals. Static class to make creation easier. If possible though, use the extension method in SmartEnumerableExt. Extension method to make life easier. Type of enumerable Source enumerable A new SmartEnumerable of the appropriate type Type chaining an IEnumerable<T> to allow the iterating code to detect the first and last entries simply. Type to iterate over Enumerable we proxy to Constructor. Collection to enumerate. Must not be null. Returns an enumeration of Entry objects, each of which knows whether it is the first/last of the enumeration, as well as the current value. Non-generic form of GetEnumerator. Represents each entry returned within a collection, containing the value and whether it is the first and/or the last entry in the collection's. enumeration The value of the entry. Whether or not this entry is first in the collection's enumeration. Whether or not this entry is last in the collection's enumeration. The 0-based index of this entry (i.e. how many entries have been returned before this one) Cache used for encoding/decoding addresses. Table used to encode/decode instructions. Default code table specified in RFC 3284. Array of entries in the code table Builds the default code table specified in RFC 3284 The default code table. Contains the information for a single instruction Enumeration of the different instruction types. A few IO routines to make life easier. Most are basically available in EndianBinaryReader, but having them separately here makes VcdiffDecoder more easily movable to other places - and no endianness issues are involved in the first place. Decoder for VCDIFF (RFC 3284) streams. Reader containing original data, if any. May be null. If non-null, will be readable and seekable. Stream containing delta data. Will be readable. Stream containing target data. Will be readable, writable and seekable. Code table to use for decoding. Address cache to use when decoding; must be reset before decoding each window. Default to the default size. Sole constructor; private to prevent instantiation from outside the class. Decodes an original stream and a delta stream, writing to a target stream. The original stream may be null, so long as the delta stream never refers to it. The original and delta streams must be readable, and the original stream (if any) and the target stream must be seekable. The target stream must be writable and readable. The original and target streams are rewound to their starts before any data is read; the relevant data must occur at the beginning of the original stream, and any data already present in the target stream may be overwritten. The delta data must begin wherever the delta stream is currently positioned. The delta stream must end after the last window. The streams are not disposed by this method. Stream containing delta. May be null. Stream containing delta data. Stream to write resulting data to. Top-level decoding method. When this method exits, all decoding has been performed. Read the header, including any custom code table. The delta stream is left positioned at the start of the first window. Reads the custom code table, if there is one Reads and decodes a window, returning whether or not there was any more data to read. Whether or not the delta stream had reached the end of its data. Summary description for VcdiffFormatException. Implementation of EndianBitConverter which converts to/from big-endian byte arrays. Equivalent of System.BitConverter, but with either endianness. Indicates the byte order ("endianess") in which data is converted using this class. Different computer architectures store data using different byte orders. "Big-endian" means the most significant byte is on the left end of a word. "Little-endian" means the most significant byte is on the right end of a word. true if this converter is little-endian, false otherwise. Converts the specified double-precision floating point number to a 64-bit signed integer. Note: the endianness of this converter does not affect the returned value. The number to convert. A 64-bit signed integer whose value is equivalent to value. Converts the specified 64-bit signed integer to a double-precision floating point number. Note: the endianness of this converter does not affect the returned value. The number to convert. A double-precision floating point number whose value is equivalent to value. Converts the specified single-precision floating point number to a 32-bit signed integer. Note: the endianness of this converter does not affect the returned value. The number to convert. A 32-bit signed integer whose value is equivalent to value. Converts the specified 32-bit signed integer to a single-precision floating point number. Note: the endianness of this converter does not affect the returned value. The number to convert. A single-precision floating point number whose value is equivalent to value. Returns a Boolean value converted from one byte at a specified position in a byte array. An array of bytes. The starting position within value. true if the byte at startIndex in value is nonzero; otherwise, false. Returns a Unicode character converted from two bytes at a specified position in a byte array. An array of bytes. The starting position within value. A character formed by two bytes beginning at startIndex. Returns a double-precision floating point number converted from eight bytes at a specified position in a byte array. An array of bytes. The starting position within value. A double precision floating point number formed by eight bytes beginning at startIndex. Returns a single-precision floating point number converted from four bytes at a specified position in a byte array. An array of bytes. The starting position within value. A single precision floating point number formed by four bytes beginning at startIndex. Returns a 16-bit signed integer converted from two bytes at a specified position in a byte array. An array of bytes. The starting position within value. A 16-bit signed integer formed by two bytes beginning at startIndex. Returns a 32-bit signed integer converted from four bytes at a specified position in a byte array. An array of bytes. The starting position within value. A 32-bit signed integer formed by four bytes beginning at startIndex. Returns a 64-bit signed integer converted from eight bytes at a specified position in a byte array. An array of bytes. The starting position within value. A 64-bit signed integer formed by eight bytes beginning at startIndex. Returns a 16-bit unsigned integer converted from two bytes at a specified position in a byte array. An array of bytes. The starting position within value. A 16-bit unsigned integer formed by two bytes beginning at startIndex. Returns a 32-bit unsigned integer converted from four bytes at a specified position in a byte array. An array of bytes. The starting position within value. A 32-bit unsigned integer formed by four bytes beginning at startIndex. Returns a 64-bit unsigned integer converted from eight bytes at a specified position in a byte array. An array of bytes. The starting position within value. A 64-bit unsigned integer formed by eight bytes beginning at startIndex. Checks the given argument for validity. The byte array passed in The start index passed in The number of bytes required value is a null reference startIndex is less than zero or greater than the length of value minus bytesRequired. Checks the arguments for validity before calling FromBytes (which can therefore assume the arguments are valid). The bytes to convert after checking The index of the first byte to convert The number of bytes to convert Convert the given number of bytes from the given array, from the given start position, into a long, using the bytes as the least significant part of the long. By the time this is called, the arguments have been checked for validity. The bytes to convert The index of the first byte to convert The number of bytes to use in the conversion The converted number Returns a String converted from the elements of a byte array. An array of bytes. All the elements of value are converted. A String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A". Returns a String converted from the elements of a byte array starting at a specified array position. An array of bytes. The starting position within value. The elements from array position startIndex to the end of the array are converted. A String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A". Returns a String converted from a specified number of bytes at a specified position in a byte array. An array of bytes. The starting position within value. The number of bytes to convert. The length elements from array position startIndex are converted. A String of hexadecimal pairs separated by hyphens, where each pair represents the corresponding element in value; for example, "7F-2C-4A". Returns a decimal value converted from sixteen bytes at a specified position in a byte array. An array of bytes. The starting position within value. A decimal formed by sixteen bytes beginning at startIndex. Returns the specified decimal value as an array of bytes. The number to convert. An array of bytes with length 16. Copies the specified decimal value into the specified byte array, beginning at the specified index. A character to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Returns an array with the given number of bytes formed from the least significant bytes of the specified value. This is used to implement the other GetBytes methods. The value to get bytes for The number of significant bytes to return Returns the specified Boolean value as an array of bytes. A Boolean value. An array of bytes with length 1. Returns the specified Unicode character value as an array of bytes. A character to convert. An array of bytes with length 2. Returns the specified double-precision floating point value as an array of bytes. The number to convert. An array of bytes with length 8. Returns the specified 16-bit signed integer value as an array of bytes. The number to convert. An array of bytes with length 2. Returns the specified 32-bit signed integer value as an array of bytes. The number to convert. An array of bytes with length 4. Returns the specified 64-bit signed integer value as an array of bytes. The number to convert. An array of bytes with length 8. Returns the specified single-precision floating point value as an array of bytes. The number to convert. An array of bytes with length 4. Returns the specified 16-bit unsigned integer value as an array of bytes. The number to convert. An array of bytes with length 2. Returns the specified 32-bit unsigned integer value as an array of bytes. The number to convert. An array of bytes with length 4. Returns the specified 64-bit unsigned integer value as an array of bytes. The number to convert. An array of bytes with length 8. Copies the given number of bytes from the least-specific end of the specified value into the specified byte array, beginning at the specified index. This is used to implement the other CopyBytes methods. The value to copy bytes for The number of significant bytes to copy The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the given number of bytes from the least-specific end of the specified value into the specified byte array, beginning at the specified index. This must be implemented in concrete derived classes, but the implementation may assume that the value will fit into the buffer. The value to copy bytes for The number of significant bytes to copy The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified Boolean value into the specified byte array, beginning at the specified index. A Boolean value. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified Unicode character value into the specified byte array, beginning at the specified index. A character to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified double-precision floating point value into the specified byte array, beginning at the specified index. The number to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified 16-bit signed integer value into the specified byte array, beginning at the specified index. The number to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified 32-bit signed integer value into the specified byte array, beginning at the specified index. The number to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified 64-bit signed integer value into the specified byte array, beginning at the specified index. The number to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified single-precision floating point value into the specified byte array, beginning at the specified index. The number to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified 16-bit unsigned integer value into the specified byte array, beginning at the specified index. The number to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified 32-bit unsigned integer value into the specified byte array, beginning at the specified index. The number to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Copies the specified 64-bit unsigned integer value into the specified byte array, beginning at the specified index. The number to convert. The byte array to copy the bytes into The first index into the array to copy the bytes into Indicates the byte order ("endianess") in which data is converted using this class. Returns a little-endian bit converter instance. The same instance is always returned. Returns a big-endian bit converter instance. The same instance is always returned. Union used solely for the equivalent of DoubleToInt64Bits and vice versa. Int32 version of the value. Single version of the value. Creates an instance representing the given integer. The integer value of the new instance. Creates an instance representing the given floating point number. The floating point value of the new instance. Returns the value of the instance as an integer. Returns the value of the instance as a floating point number. Indicates the byte order ("endianess") in which data is converted using this class. Different computer architectures store data using different byte orders. "Big-endian" means the most significant byte is on the left end of a word. "Little-endian" means the most significant byte is on the right end of a word. true if this converter is little-endian, false otherwise. Copies the specified number of bytes from value to buffer, starting at index. The value to copy The number of bytes to copy The buffer to copy the bytes into The index to start at Returns a value built from the specified number of bytes from the given buffer, starting at index. The data in byte array format The first index to use The number of bytes to use The value built from the given bytes Indicates the byte order ("endianess") in which data is converted using this class. A class to allow the conversion of doubles to string representations of their exact decimal values. The implementation aims for readability over efficiency. Converts the given double to a string representation of its exact decimal value. The double to convert. A string representation of the double's exact decimal value. Private class used for manipulating sequences of decimal digits. Digits in the decimal expansion, one byte per digit How many digits are *after* the decimal point Constructs an arbitrary decimal expansion from the given long. The long must not be negative. Multiplies the current expansion by the given amount, which should only be 2 or 5. Shifts the decimal point; a negative value makes the decimal expansion bigger (as fewer digits come after the decimal place) and a positive value makes the decimal expansion smaller. Removes leading/trailing zeroes from the expansion. Converts the value to a proper decimal string representation. Endianness of a converter Little endian - least significant byte first Big endian - most significant byte first Implementation of EndianBitConverter which converts to/from little-endian byte arrays. Indicates the byte order ("endianess") in which data is converted using this class. Different computer architectures store data using different byte orders. "Big-endian" means the most significant byte is on the left end of a word. "Little-endian" means the most significant byte is on the right end of a word. true if this converter is little-endian, false otherwise. Copies the specified number of bytes from value to buffer, starting at index. The value to copy The number of bytes to copy The buffer to copy the bytes into The index to start at Returns a value built from the specified number of bytes from the given buffer, starting at index. The data in byte array format The first index to use The number of bytes to use The value built from the given bytes Indicates the byte order ("endianess") in which data is converted using this class. Generic event argument taking a single value Creates a new EventArgs<T> with the specified value. The Value of the EventArgs<T> instance. The typed value of the EventArgs<T> Extension methods to do with ranges. Creates an inclusive range between two values. The default comparer is used to compare values. Type of the values Start of range. End of range. An inclusive range between the start point and the end point. Returns a RangeIterator over the given range, where the stepping function is to step by the given number of characters. The range to create an iterator for How many characters to step each time A RangeIterator with a suitable stepping function Extension methods on all reference types. Throws an ArgumentNullException if the given data item is null. The item to check for nullity. The name to use when throwing an exception, if necessary Throws an ArgumentNullException if the given data item is null. No parameter name is specified. The item to check for nullity. Extension methods producing DateTime values. These are useful when writing unit tests with fixed dates which should be easily understandable. Returns a DateTime representing the specified day in January in the specified year. Returns a DateTime representing the specified day in February in the specified year. Returns a DateTime representing the specified day in March in the specified year. Returns a DateTime representing the specified day in April in the specified year. Returns a DateTime representing the specified day in May in the specified year. Returns a DateTime representing the specified day in June in the specified year. Returns a DateTime representing the specified day in July in the specified year. Returns a DateTime representing the specified day in August in the specified year. Returns a DateTime representing the specified day in September in the specified year. Returns a DateTime representing the specified day in October in the specified year. Returns a DateTime representing the specified day in November in the specified year. Returns a DateTime representing the specified day in December in the specified year. Extension methods producing TimeSpan values. Note: Ticks should really take a long, and the rest should all take doubles. It looks like extension methods don't quite work properly with implicit numeric conversions :( Returns a TimeSpan representing the specified number of ticks. Returns a TimeSpan representing the specified number of milliseconds. Returns a TimeSpan representing the specified number of seconds. Returns a TimeSpan representing the specified number of minutes. Returns a TimeSpan representing the specified number of hours. Returns a TimeSpan representing the specified number of days. Generic math equivalents of System.Math. (Calling this just Math makes far too much mess.) Returns the absolute value of a specified number. Type to calculate with Input to return the absolute value of. The input value if it is greater than or equal to the default value of T, or the negated input value otherwise Returns whether or not two inputs are "close" to each other with respect to a given delta. This implementation currently does no overflow checking - if (input1-input2) overflows, it could yield the wrong result. Type to calculate with First input value Second input value Permitted range (exclusive) True if Abs(input1-input2) is less than or equal to delta; false otherwise. Equivalent of System.IO.BinaryReader, but with either endianness, depending on the EndianBitConverter it is constructed with. No data is buffered in the reader; the client may seek within the stream at will. Whether or not this reader has been disposed yet. Decoder to use for string conversions. Buffer used for temporary storage before conversion into primitives Buffer used for temporary storage when reading a single character Minimum number of bytes used to encode a character Equivalent of System.IO.BinaryWriter, but with either endianness, depending on the EndianBitConverter it is constructed with. Converter to use when reading data Stream to read data from Constructs a new binary reader with the given bit converter, reading to the given stream, using the given encoding. Converter to use when reading data Stream to read data from Encoding to use when reading character data Closes the reader, including the underlying stream.. Seeks within the stream. Offset to seek to. Origin of seek operation. Reads a single byte from the stream. The byte read Reads a single signed byte from the stream. The byte read Reads a boolean from the stream. 1 byte is read. The boolean read Reads a 16-bit signed integer from the stream, using the bit converter for this reader. 2 bytes are read. The 16-bit integer read Reads a 32-bit signed integer from the stream, using the bit converter for this reader. 4 bytes are read. The 32-bit integer read Reads a 64-bit signed integer from the stream, using the bit converter for this reader. 8 bytes are read. The 64-bit integer read Reads a 16-bit unsigned integer from the stream, using the bit converter for this reader. 2 bytes are read. The 16-bit unsigned integer read Reads a 32-bit unsigned integer from the stream, using the bit converter for this reader. 4 bytes are read. The 32-bit unsigned integer read Reads a 64-bit unsigned integer from the stream, using the bit converter for this reader. 8 bytes are read. The 64-bit unsigned integer read Reads a single-precision floating-point value from the stream, using the bit converter for this reader. 4 bytes are read. The floating point value read Reads a double-precision floating-point value from the stream, using the bit converter for this reader. 8 bytes are read. The floating point value read Reads a decimal value from the stream, using the bit converter for this reader. 16 bytes are read. The decimal value read Reads a single character from the stream, using the character encoding for this reader. If no characters have been fully read by the time the stream ends, -1 is returned. The character read, or -1 for end of stream. Reads the specified number of characters into the given buffer, starting at the given index. The buffer to copy data into The first index to copy data into The number of characters to read The number of characters actually read. This will only be less than the requested number of characters if the end of the stream is reached. Reads the specified number of bytes into the given buffer, starting at the given index. The buffer to copy data into The first index to copy data into The number of bytes to read The number of bytes actually read. This will only be less than the requested number of bytes if the end of the stream is reached. Reads the specified number of bytes, returning them in a new byte array. If not enough bytes are available before the end of the stream, this method will return what is available. The number of bytes to read The bytes read Reads the specified number of bytes, returning them in a new byte array. If not enough bytes are available before the end of the stream, this method will throw an IOException. The number of bytes to read The bytes read Reads a 7-bit encoded integer from the stream. This is stored with the least significant information first, with 7 bits of information per byte of value, and the top bit as a continuation flag. This method is not affected by the endianness of the bit converter. The 7-bit encoded integer read from the stream. Reads a 7-bit encoded integer from the stream. This is stored with the most significant information first, with 7 bits of information per byte of value, and the top bit as a continuation flag. This method is not affected by the endianness of the bit converter. The 7-bit encoded integer read from the stream. Reads a length-prefixed string from the stream, using the encoding for this reader. A 7-bit encoded integer is first read, which specifies the number of bytes to read from the stream. These bytes are then converted into a string with the encoding for this reader. The string read from the stream. Checks whether or not the reader has been disposed, throwing an exception if so. Reads the given number of bytes from the stream, throwing an exception if they can't all be read. Buffer to read into Number of bytes to read Reads the given number of bytes from the stream if possible, returning the number of bytes actually read, which may be less than requested if (and only if) the end of the stream is reached. Buffer to read into Number of bytes to read Number of bytes actually read Disposes of the underlying stream. The bit converter used to read values from the stream The encoding used to read strings Gets the underlying stream of the EndianBinaryReader. Equivalent of System.IO.BinaryWriter, but with either endianness, depending on the EndianBitConverter it is constructed with. Whether or not this writer has been disposed yet. Buffer used for temporary storage during conversion from primitives Buffer used for Write(char) Constructs a new binary writer with the given bit converter, writing to the given stream, using UTF-8 encoding. Converter to use when writing data Stream to write data to Constructs a new binary writer with the given bit converter, writing to the given stream, using the given encoding. Converter to use when writing data Stream to write data to Encoding to use when writing character data Closes the writer, including the underlying stream. Flushes the underlying stream. Seeks within the stream. Offset to seek to. Origin of seek operation. Writes a boolean value to the stream. 1 byte is written. The value to write Writes a 16-bit signed integer to the stream, using the bit converter for this writer. 2 bytes are written. The value to write Writes a 32-bit signed integer to the stream, using the bit converter for this writer. 4 bytes are written. The value to write Writes a 64-bit signed integer to the stream, using the bit converter for this writer. 8 bytes are written. The value to write Writes a 16-bit unsigned integer to the stream, using the bit converter for this writer. 2 bytes are written. The value to write Writes a 32-bit unsigned integer to the stream, using the bit converter for this writer. 4 bytes are written. The value to write Writes a 64-bit unsigned integer to the stream, using the bit converter for this writer. 8 bytes are written. The value to write Writes a single-precision floating-point value to the stream, using the bit converter for this writer. 4 bytes are written. The value to write Writes a double-precision floating-point value to the stream, using the bit converter for this writer. 8 bytes are written. The value to write Writes a decimal value to the stream, using the bit converter for this writer. 16 bytes are written. The value to write Writes a signed byte to the stream. The value to write Writes an unsigned byte to the stream. The value to write Writes an array of bytes to the stream. The values to write Writes a portion of an array of bytes to the stream. An array containing the bytes to write The index of the first byte to write within the array The number of bytes to write Writes a single character to the stream, using the encoding for this writer. The value to write Writes an array of characters to the stream, using the encoding for this writer. An array containing the characters to write Writes a string to the stream, using the encoding for this writer. The value to write. Must not be null. value is null Writes a 7-bit encoded integer from the stream. This is stored with the least significant information first, with 7 bits of information per byte of value, and the top bit as a continuation flag. The 7-bit encoded integer to write to the stream Checks whether or not the writer has been disposed, throwing an exception if so. Writes the specified number of bytes from the start of the given byte array, after checking whether or not the writer has been disposed. The array of bytes to write from The number of bytes to write Disposes of the underlying stream. The bit converter used to write values to the stream The encoding used to write strings Gets the underlying stream of the EndianBinaryWriter. Reads a data source line by line. The source can be a file, a stream, or a text reader. In any case, the source is only opened when the enumerator is fetched, and is closed when the iterator is disposed. Means of creating a TextReader to read from. Creates a LineReader from a stream source. The delegate is only called when the enumerator is fetched. UTF-8 is used to decode the stream into text. Data source Creates a LineReader from a stream source. The delegate is only called when the enumerator is fetched. Data source Encoding to use to decode the stream into text Creates a LineReader from a filename. The file is only opened (or even checked for existence) when the enumerator is fetched. UTF8 is used to decode the file into text. File to read from Creates a LineReader from a filename. The file is only opened (or even checked for existence) when the enumerator is fetched. File to read from Encoding to use to decode the file into text Creates a LineReader from a TextReader source. The delegate is only called when the enumerator is fetched Data source Enumerates the data source line by line. Enumerates the data source line by line. Wraps a stream for all operations except Close and Dispose, which merely flush the stream and prevent further operations from being carried out using this wrapper. Creates a new instance of the class, wrapping the specified stream. The stream to wrap. Must not be null. stream is null Whether this stream has been closed or not Throws an InvalidOperationException if the wrapper is closed. Begins an asynchronous read operation. The buffer to read the data into. The byte offset in buffer at which to begin writing data read from the stream. The maximum number of bytes to read. An optional asynchronous callback, to be called when the read is complete. A user-provided object that distinguishes this particular asynchronous read request from other requests. An IAsyncResult that represents the asynchronous read, which could still be pending. Begins an asynchronous write operation. The buffer to write data from. The byte offset in buffer from which to begin writing. The maximum number of bytes to write. An optional asynchronous callback, to be called when the write is complete. A user-provided object that distinguishes this particular asynchronous write request from other requests. An IAsyncResult that represents the asynchronous write, which could still be pending. This method is not proxied to the underlying stream; instead, the wrapper is marked as unusable for other (non-close/Dispose) operations. The underlying stream is flushed if the wrapper wasn't closed before this call. Throws a NotSupportedException. The Type of the object that the new ObjRef will reference. n/a Waits for the pending asynchronous read to complete. The reference to the pending asynchronous request to finish. The number of bytes read from the stream, between zero (0) and the number of bytes you requested. Streams only return zero (0) at the end of the stream, otherwise, they should block until at least one byte is available. Ends an asynchronous write operation. A reference to the outstanding asynchronous I/O request. Flushes the underlying stream. Throws a NotSupportedException. n/a Reads a sequence of bytes from the underlying stream and advances the position within the stream by the number of bytes read. An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count- 1) replaced by the bytes read from the underlying source. The zero-based byte offset in buffer at which to begin storing the data read from the underlying stream. The maximum number of bytes to be read from the underlying stream. The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. The unsigned byte cast to an Int32, or -1 if at the end of the stream. Sets the position within the current stream. A byte offset relative to the origin parameter. A value of type SeekOrigin indicating the reference point used to obtain the new position. The new position within the underlying stream. Sets the length of the underlying stream. The desired length of the underlying stream in bytes. Writes a sequence of bytes to the underlying stream and advances the current position within the stream by the number of bytes written. An array of bytes. This method copies count bytes from buffer to the underlying stream. The zero-based byte offset in buffer at which to begin copying bytes to the underlying stream. The number of bytes to be written to the underlying stream. Writes a byte to the current position in the stream and advances the position within the stream by one byte. The byte to write to the stream. Stream wrapped by this wrapper Indicates whether or not the underlying stream can be read from. Indicates whether or not the underlying stream supports seeking. Indicates whether or not the underlying stream can be written to. Returns the length of the underlying stream. Gets or sets the current position in the underlying stream. Takes an encoding (defaulting to UTF-8) and a function which produces a seekable stream (or a filename for convenience) and yields lines from the end of the stream backwards. Only single byte encodings, and UTF-8 and Unicode, are supported. The stream returned by the function must be seekable. Buffer size to use by default. Classes with internal access can specify a different buffer size - this is useful for testing. Means of creating a Stream to read from. Encoding to use when converting bytes to text Size of buffer (in bytes) to read each time we read from the stream. This must be at least as big as the maximum number of bytes for a single character. Function which, when given a position within a file and a byte, states whether or not the byte represents the start of a character. Creates a LineReader from a stream source. The delegate is only called when the enumerator is fetched. UTF-8 is used to decode the stream into text. Data source Creates a LineReader from a filename. The file is only opened (or even checked for existence) when the enumerator is fetched. UTF8 is used to decode the file into text. File to read from Creates a LineReader from a filename. The file is only opened (or even checked for existence) when the enumerator is fetched. File to read from Encoding to use to decode the file into text Creates a LineReader from a stream source. The delegate is only called when the enumerator is fetched. Data source Encoding to use to decode the stream into text Returns the enumerator reading strings backwards. If this method discovers that the returned stream is either unreadable or unseekable, a NotSupportedException is thrown. Collection of utility methods which operate on streams. (With C# 3.0, these could well become extension methods on Stream.) Reads the given stream up to the end, returning the data as a byte array. The stream to read from input is null An error occurs while reading from the stream The data read from the stream Reads the given stream up to the end, returning the data as a byte array, using the given buffer size. The stream to read from The size of buffer to use when reading input is null bufferSize is less than 1 An error occurs while reading from the stream The data read from the stream Reads the given stream up to the end, returning the data as a byte array, using the given buffer for transferring data. Note that the current contents of the buffer is ignored, so the buffer needn't be cleared beforehand. The stream to read from The buffer to use to transfer data input is null buffer is null An error occurs while reading from the stream The data read from the stream Reads the given stream up to the end, returning the data as a byte array, using the given buffer for transferring data. Note that the current contents of the buffer is ignored, so the buffer needn't be cleared beforehand. The stream to read from The buffer to use to transfer data input is null buffer is null buffer is a zero-length array An error occurs while reading from the stream The data read from the stream Copies all the data from one stream into another. The stream to read from The stream to write to input is null output is null An error occurs while reading or writing Copies all the data from one stream into another, using a buffer of the given size. The stream to read from The stream to write to The size of buffer to use when reading input is null output is null bufferSize is less than 1 An error occurs while reading or writing Copies all the data from one stream into another, using the given buffer for transferring data. Note that the current contents of the buffer is ignored, so the buffer needn't be cleared beforehand. The stream to read from The stream to write to The buffer to use to transfer data input is null output is null buffer is null An error occurs while reading or writing Copies all the data from one stream into another, using the given buffer for transferring data. Note that the current contents of the buffer is ignored, so the buffer needn't be cleared beforehand. The stream to read from The stream to write to The buffer to use to transfer data input is null output is null buffer is null buffer is a zero-length array An error occurs while reading or writing Reads exactly the given number of bytes from the specified stream. If the end of the stream is reached before the specified amount of data is read, an exception is thrown. The stream to read from The number of bytes to read input is null bytesToRead is less than 1 The end of the stream is reached before enough data has been read An error occurs while reading from the stream The data read from the stream Reads into a buffer, filling it completely. The stream to read from The buffer to read into input is null The buffer is of zero length The end of the stream is reached before enough data has been read An error occurs while reading from the stream The data read from the stream Reads into a buffer, filling it completely. The stream to read from The buffer to read into input is null The buffer is of zero length The end of the stream is reached before enough data has been read An error occurs while reading from the stream The data read from the stream Reads into a buffer, for the given number of bytes. The stream to read from The buffer to read into The number of bytes to read input is null The buffer is of zero length, or bytesToRead exceeds the buffer length The end of the stream is reached before enough data has been read An error occurs while reading from the stream The data read from the stream Reads exactly the given number of bytes from the specified stream, into the given buffer, starting at position 0 of the array. The stream to read from The byte array to read into The number of bytes to read input is null bytesToRead is less than 1 The end of the stream is reached before enough data has been read An error occurs while reading from the stream Reads into a buffer, for the given number of bytes, from the specified location The stream to read from The buffer to read into The index into the buffer at which to start writing The number of bytes to read input is null The buffer is of zero length, or startIndex+bytesToRead exceeds the buffer length The end of the stream is reached before enough data has been read An error occurs while reading from the stream The data read from the stream Reads exactly the given number of bytes from the specified stream, into the given buffer, starting at position 0 of the array. The stream to read from The byte array to read into The index into the buffer at which to start writing The number of bytes to read input is null bytesToRead is less than 1, startIndex is less than 0, or startIndex+bytesToRead is greater than the buffer length The end of the stream is reached before enough data has been read An error occurs while reading from the stream A simple class derived from StringWriter, but which allows the user to select which Encoding is used. This is most likely to be used with XmlTextWriter, which uses the Encoding property to determine which encoding to specify in the XML. The encoding to return in the Encoding property. Initializes a new instance of the StringWriterWithEncoding class with the specified encoding. The encoding to report. Initializes a new instance of the StringWriter class with the specified format control and encoding. An IFormatProvider object that controls formatting. The encoding to report. Initializes a new instance of the StringWriter class that writes to the specified StringBuilder, and reports the specified encoding. The StringBuilder to write to. The encoding to report. Initializes a new instance of the StringWriter class that writes to the specified StringBuilder, has the specified format provider, and reports the specified encoding. The StringBuilder to write to. An IFormatProvider object that controls formatting. The encoding to report. Gets the Encoding in which the output is written. Simple non-unique map wrapper ApplyResultSelector (from Lookup[TKey, TElement] is not implemented, since the caller could just as easily (or more-so) use .Select() with a Func[IGrouping[TKey, TElement], TResult], since IGrouping[TKey, TElement] already includes both the "TKey Key" and the IEnumerable[TElement]. Creates a new EditableLookup using the default key-comparer Creates a new EditableLookup using the specified key-comparer Does the lookup contain any value(s) for the given key? Does the lookup the specific key/value pair? Adds a key/value pair to the lookup If the value is already present it will be duplicated Adds a range of values against a single key Any values already present will be duplicated Add all key/value pairs from the supplied lookup to the current lookup Any values already present will be duplicated Remove all values from the lookup for the given key True if any items were removed, else false Remove the specific key/value pair from the lookup True if the item was found, else false Trims the inner data-structure to remove any surplus space Returns the sequence of keys and their contained values Returns the number of dictinct keys in the lookup Returns the set of values for the given key Provides extension methods to List<T> Sorts the elements in the entire System.Collections.Generic.List{T} using a projection. Data source The projection to use to obtain values for comparison The comparer to use to compare projected values (on null to use the default comparer) Should the list be sorted ascending or descending? Sorts the elements in the entire System.Collections.Generic.List{T} using a projection. Data source The projection to use to obtain values for comparison Provides extension methods to System.Type to provide simple and efficient access to delegates representing reflection operations. Obtains a delegate to invoke a parameterless constructor The base/interface type to yield as the new value; often object except for factory pattern implementations The Type to be created A delegate to the constructor if found, else null Obtains a delegate to invoke a constructor which takes a parameter The type of the constructor parameter The base/interface type to yield as the new value; often object except for factory pattern implementations The Type to be created A delegate to the constructor if found, else null Obtains a delegate to invoke a constructor with multiple parameters The type of the first constructor parameter The type of the second constructor parameter The base/interface type to yield as the new value; often object except for factory pattern implementations The Type to be created A delegate to the constructor if found, else null Obtains a delegate to invoke a constructor with multiple parameters The type of the first constructor parameter The type of the second constructor parameter The type of the third constructor parameter The base/interface type to yield as the new value; often object except for factory pattern implementations The Type to be created A delegate to the constructor if found, else null Obtains a delegate to invoke a constructor with multiple parameters The type of the first constructor parameter The type of the second constructor parameter The type of the third constructor parameter The type of the fourth constructor parameter The base/interface type to yield as the new value; often object except for factory pattern implementations The Type to be created A delegate to the constructor if found, else null IProducerGrouping is to IDataProducer as IGrouping is to IEnumerable: it's basically a data producer with a key. It's used by the GroupBy operator. Interface to be implemented by sequences of data which have a "push" nature rather than "pull" - instead of the IEnumerable model of the client pulling data from the sequence, here the client registers an interest in the data being produced, and in the sequence reaching an end. The data producer than produces data whenever it wishes, and the clients can react. This allows other actions to occur between items being pulled, as well as multiple clients for the same sequence of data. Event which is raised when an item of data is produced. This will not be raised after EndOfData has been raised. The parameter for the event is the Event which is raised when the sequence has finished being produced. This will be raised exactly once, and after all DataProduced events (if any) have been raised. The key for this grouping. Simple implementation of IProducerGrouping which proxies to an existing IDataProducer. Constructs a new grouping with the given key Event which is raised when an item of data is produced. This will not be raised after EndOfData has been raised. The parameter for the event is the Event which is raised when the sequence has finished being produced. This will be raised exactly once, and after all DataProduced events (if any) have been raised. The key for this grouping. Comparer to daisy-chain two existing comparers and apply in sequence (i.e. sort by x then y) Create a new LinkedComparer The first comparison to use The next level of comparison if the primary returns 0 (equivalent) General purpose Expression utilities Create a function delegate representing a unary operation The parameter type The return type Body factory Compiled function delegate Create a function delegate representing a binary operation The first parameter type The second parameter type The return type Body factory Compiled function delegate Create a function delegate representing a binary operation If no matching operation is possible, attempt to convert TArg1 and TArg2 to TResult for a match? For example, there is no "decimal operator /(decimal, int)", but by converting TArg2 (int) to TResult (decimal) a match is found. The first parameter type The second parameter type The return type Body factory Compiled function delegate Extensions on IDataProducer Extensions on IDataProducer Returns the number of elements in a sequence, as a future value. The type of the elements of source. A sequence that contains elements to be counted. The number of elements in the input sequence, as a future value. The actual count can only be retrieved after the source has indicated the end of its data. Returns the number of elements in the specified sequence satisfy a condition, as a future value. The type of the elements of source. A sequence that contains elements to be tested and counted. A function to test each element for a condition. A number that represents how many elements in the sequence satisfy the condition in the predicate function, as a future value. The actual count can only be retrieved after the source has indicated the end of its data. Returns the number of elements in a sequence, as a future value. The type of the elements of source. A sequence that contains elements to be counted. The number of elements in the input sequence, as a future value. The actual count can only be retrieved after the source has indicated the end of its data. Returns the number of elements in the specified sequence satisfy a condition, as a future value. The type of the elements of source. A sequence that contains elements to be tested and counted. A function to test each element for a condition. A number that represents how many elements in the sequence satisfy the condition in the predicate function, as a future value. The actual count can only be retrieved after the source has indicated the end of its data. Returns the first element of a sequence, as a future value. The type of the elements of source. The sequence to return the first element of. The first element in the specified sequence, as a future value. The actual value can only be retrieved after the source has indicated the end of its data. Returns the first element in a sequence that satisfies a specified condition, as a future value. The type of the elements of source. The sequence to an element from. A function to test each element for a condition. The first element in the specified sequence that passes the test in the specified predicate function, as a future value. The actual value can only be retrieved after the source has indicated the end of its data. Returns the last element of a sequence, as a future value. The type of the elements of source. The sequence to return the last element of. The last element in the specified sequence, as a future value. The actual value can only be retrieved after the source has indicated the end of its data. Returns the last element in a sequence that satisfies a specified condition, as a future value. The type of the elements of source. The sequence to an element from. A function to test each element for a condition. The last element in the specified sequence that passes the test in the specified predicate function, as a future value. The actual value can only be retrieved after the source has indicated the end of its data. Returns a future to the first value from a sequence, or the default for that type if no value is produced. The source data-producer. Returns a future to the first value from a sequence that matches the given condition, or the default for that type if no matching value is produced. The source data-producer. The condition to be satisfied. Returns a future to the last value from a sequence, or the default for that type if no value is produced. The source data-producer. Returns the last value from a sequence that matches the given condition, or the default for that type if no matching value is produced. The source data-producer. The condition to be satisfied. Returns a future to a single value from a data-source; an exception is thrown if no values, or multiple values, are encountered. The source data-producer. Zero or multiple terms are encountered. Returns a future to a single value from a data-source that matches the specified condition; an exception is thrown if no matching values, or multiple matching values, are encountered. The source data-producer. The condition to be satisfied. Zero or multiple matching terms are encountered. Returns a future to a single value from a data-source or the default value if no values are encountered. An exception is thrown if multiple values are encountered. The source data-producer. Multiple terms are encountered. Returns a future to a single value from a data-source that matches the specified condition, or the default value if no matching values are encountered. An exception is thrown if multiple matching values are encountered. The source data-producer. The condition to be satisfied. Multiple matching terms are encountered. Returns a future to the element at the given position in the sequence The data-producer The index of the desired trem in the sequence If the specified index is negative or is never reached Returns a future to the element at the given position in the sequence, or the default-value if the specified index is never reached The data-producer The index of the desired trem in the sequence If the specified index is negative Returns a future that indicates whether all values yielded by the data-producer satisfy a given condition. The future will return true for an empty sequence or where all values satisfy the condition, else false (if any value value fails to satisfy the condition). The data-producer to be monitored. The condition that must be satisfied by all terms. Returns a future that indicates whether any values are yielded by the data-producer. The future will return false for an empty sequence, or true for a sequence with values. The data-producer to be monitored. Returns a future that indicates whether any suitable values are yielded by the data-producer. The future will return false for an empty sequence or one with no matching values, or true for a sequence with matching values. The data-producer to be monitored. The condition that must be satisfied. Returns a future to indicate whether the specified value is yielded by the data-source. The type of data to be yielded The data-source The value to detect from the data-source, checked with the default comparer Returns a future to indicate whether the specified value is yielded by the data-source. The type of data to be yielded The data-source The value to detect from the data-source The comparer to use to determine equality Applies an accumulator function over the values yielded from a data-producer. The first value in the seqnence is used as the initial accumulator value, and the specified function is used to select the result value. If the sequence is empty then the default value for TSource is returned. The type of data yielded by the data-source Accumulator function to be applied to each term in the sequence The data-source for the values Applies an accumulator function over the values yielded from a data-producer. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value The type of data yielded by the data-source The type to be used for the accumulator Accumulator function to be applied to each term in the sequence The initial value for the accumulator The data-source for the values Applies an accumulator function over the values yielded from a data-producer, performing a transformation on the final accululated value. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value The type of data yielded by the data-source The final result type (after the accumulator has been transformed) The type to be used for the accumulator Accumulator function to be applied to each term in the sequence Transformation to apply to the final accumulated value to produce the result The initial value for the accumulator The data-source for the values Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The return-type of the transform used to group the sequence The values to be yielded by the original data-source A function to extract the key for each element in hte original sequence. The data-source to be grouped This will force each unique grouping key to be buffered, but not the data itself Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The return-type of the transform used to group the sequence The values to be yielded by the original data-source Used to compare grouping keys A function to extract the key for each element in hte original sequence. The data-source to be grouped This will force each unique grouping key to be buffered, but not the data itself Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function. The return-type of the transform used to process the values within each grouping. The return-type of the transform used to group the sequence The values to be yielded by the original data-source A function to map each source element to an element in the appropriate group A function to extract the key for each element in hte original sequence. The data-source to be grouped This will force each unique grouping key to be buffered, but not the data itself Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The return-type of the transform used to group the sequence The final values to be yielded after processing The values to be yielded by the original data-source A function to extract the key for each element in hte original sequence. A function to create a result value from each group. The data-source to be grouped This will force each unique grouping key to be buffered, but not the data itself Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function. The return-type of the transform used to process the values within each grouping. The return-type of the transform used to group the sequence The values to be yielded by the original data-source Used to compare grouping keys A function to map each source element to an element in the appropriate group A function to extract the key for each element in hte original sequence. The data-source to be grouped This will force each unique grouping key to be buffered, but not the data itself Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function. The return-type of the transform used to process the values within each grouping. The return-type of the transform used to group the sequence The final values to be yielded after processing The values to be yielded by the original data-source A function to map each source element to an element in the appropriate group A function to extract the key for each element in hte original sequence. A function to create a result value from each group. The data-source to be grouped This will force each unique grouping key to be buffered, but not the data itself Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The return-type of the transform used to group the sequence The final values to be yielded after processing The values to be yielded by the original data-source Used to compare grouping keys A function to extract the key for each element in hte original sequence. A function to create a result value from each group. The data-source to be grouped This will force each unique grouping key to be buffered, but not the data itself Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key. The elements of each group are projected by using a specified function. The return-type of the transform used to process the values within each grouping. The return-type of the transform used to group the sequence The final values to be yielded after processing The values to be yielded by the original data-source Used to compare grouping keys A function to map each source element to an element in the appropriate group A function to extract the key for each element in hte original sequence. A function to create a result value from each group. The data-source to be grouped This will force each unique grouping key to be buffered, but not the data itself Filters a data-producer based on a predicate on each value The data-producer to be filtered The condition to be satisfied A filtered data-producer; only matching values will raise the DataProduced event Filters a data-producer based on a predicate on each value; the index in the sequence is used in the predicate The data-producer to be filtered The condition to be satisfied A filtered data-producer; only matching values will raise the DataProduced event Returns a data-producer that yeilds the values from the sequence, or which yields the given singleton value if no data is produced. The default value to be yielded if no data is produced. The source data-producer. Returns a data-producer that yeilds the values from the sequence, or which yields the default value for the Type if no data is produced. The source data-producer. Returns a projection on the data-producer, using a transformation to map each element into a new form. The source type The projected type The source data-producer The transformation to apply to each element. Returns a projection on the data-producer, using a transformation (involving the elements's index in the sequence) to map each element into a new form. The source type The projected type The source data-producer The transformation to apply to each element. Returns a data-producer that will yield a specified number of contiguous elements from the start of a sequence - i.e. "the first <x> elements". The source data-producer The maximum number of elements to return Returns a data-producer that will ignore a specified number of contiguous elements from the start of a sequence, and yield all elements after this point - i.e. "elements from index <x> onwards". The source data-producer The number of elements to ignore Returns a data-producer that will yield elements a sequence as long as a condition is satsified; when the condition fails for an element, that element and all subsequent elements are ignored. The source data-producer The condition to yield elements Returns a data-producer that will yield elements a sequence as long as a condition (involving the element's index in the sequence) is satsified; when the condition fails for an element, that element and all subsequent elements are ignored. The source data-producer The condition to yield elements Returns a data-producer that will ignore the elements from the start of a sequence while a condition is satsified; when the condition fails for an element, that element and all subsequent elements are yielded. The source data-producer The condition to skip elements Returns a data-producer that will ignore the elements from the start of a sequence while a condition (involving the elements's index in the sequence) is satsified; when the condition fails for an element, that element and all subsequent elements are yielded. The source data-producer The condition to skip elements Returns a data-producer that yields the first instance of each unique value in the sequence; subsequent identical values are ignored. The data-producer This will force the first instance of each unique value to be buffered Returns a data-producer that yields the first instance of each unique value in the sequence; subsequent identical values are ignored. The data-producer Used to determine equaility between values This will force the first instance of each unique value to be buffered Reverses the order of a sequence The data-producer A data-producer that yields the sequence in the reverse order This will force all data to be buffered Further orders the values from an ordered data-source by a transform on each term, ascending (the sort operation is only applied once for the combined ordering) The original data-producer and ordering Returns the value (for each term) by which to order the sequence A data-producer that yeilds the sequence ordered by the selected value This will force all data to be buffered Further orders the values from an ordered data-source by a transform on each term, ascending (the sort operation is only applied once for the combined ordering) The original data-producer and ordering Returns the value (for each term) by which to order the sequence Comparer to compare the selected values A data-producer that yeilds the sequence ordered by the selected value This will force all data to be buffered Further orders the values from an ordered data-source by a transform on each term, descending (the sort operation is only applied once for the combined ordering) The original data-producer and ordering Returns the value (for each term) by which to order the sequence A data-producer that yeilds the sequence ordered by the selected value This will force all data to be buffered Further orders the values from an ordered data-source by a transform on each term, descending (the sort operation is only applied once for the combined ordering) The original data-producer and ordering Returns the value (for each term) by which to order the sequence Comparer to compare the selected values A data-producer that yeilds the sequence ordered by the selected value This will force all data to be buffered Orders the values from a data-source by a transform on each term, ascending The original data-producer Returns the value (for each term) by which to order the sequence A data-producer that yeilds the sequence ordered by the selected value This will force all data to be buffered Orders the values from a data-source by a transform on each term, ascending The original data-producer Returns the value (for each term) by which to order the sequence Comparer to compare the selected values A data-producer that yeilds the sequence ordered by the selected value This will force all data to be buffered Orders the values from a data-source by a transform on each term, descending The original data-producer Returns the value (for each term) by which to order the sequence A data-producer that yeilds the sequence ordered by the selected value This will force all data to be buffered Orders the values from a data-source by a transform on each term, descending The original data-producer Returns the value (for each term) by which to order the sequence Comparer to compare the selected values A data-producer that yeilds the sequence ordered by the selected value This will force all data to be buffered Converts an IDataProducer into an IFuture[IEnumerable]. The results are buffered in memory (as a list), so be warned that this loses the "streaming" nature of most of the IDataProducer extension methods. The "future" nature of the result ensures that all results are produced before the enumeration can take place. This will force all values to be buffered Converts an IDataProducer into an IEnumerable. The results are buffered in memory (as a list), so be warned that this loses the "streaming" nature of most of the IDataProducer extension methods. The list is returned immediately, but further data productions add to it. You must therefore be careful when the list is used - it is a good idea to only use it after all data has been produced. This will force all values to be buffered Converts an IDataProducer into a list. An empty list is returned immediately, and any results produced are added to it. This will force all values to be buffered Converts an IDataProducer into a future array. This will force all values to be buffered Converts an IDataProducer into a lookup. A transform function to produce a result element value from each element. A function to extract a key from each element. Used to compare keys. The data source. This will force all values to be buffered Converts an IDataProducer into a lookup. A function to extract a key from each element. The data source. This will force all values to be buffered Converts an IDataProducer into a lookup. A function to extract a key from each element. Used to compare keys. The data source. This will force all values to be buffered Converts an IDataProducer into a lookup. A transform function to produce a result element value from each element. A function to extract a key from each element. The data source. This will force all values to be buffered Converts an IDataProducer into a dictionary. A transform function to produce a result element value from each element. A function to extract a key from each element. Used to compare keys. The data source. This will force all values to be buffered Converts an IDataProducer into a dictionary. A function to extract a key from each element. The data source. This will force all values to be buffered Converts an IDataProducer into a dictionary. A function to extract a key from each element. Used to compare keys. The data source. This will force all values to be buffered Converts an IDataProducer into a dictionary. A transform function to produce a result element value from each element. A function to extract a key from each element. The data source. This will force all values to be buffered Returns a future to the sum of a sequence of values that are obtained by taking a transform of the input sequence Null values are removed from the sum Returns a future to the sum of a sequence of values Null values are removed from the sum Returns a future to the average of a sequence of values that are obtained by taking a transform of the input sequence Null values are removed from the average Returns a future to the average of a sequence of values Null values are removed from the average Returns a future to the average of a sequence of values Returns a future to the average of a sequence of values Null values are removed from the average Returns a future to the average of a sequence of values Returns a future to the average of a sequence of values Null values are removed from the average Returns a future to the average of a sequence of values that are obtained by taking a transform of the input sequence Returns a future to the average of a sequence of values that are obtained by taking a transform of the input sequence Null values are removed from the average Returns a future to the average of a sequence of values that are obtained by taking a transform of the input sequence Returns a future to the average of a sequence of values that are obtained by taking a transform of the input sequence Null values are removed from the average Returns a future to the maximum of a sequence of values that are obtained by taking a transform of the input sequence, using the default comparer, using the default comparer Null values are removed from the maximum Returns a future to the maximum of a sequence of values, using the default comparer Null values are removed from the maximum Returns a future to the minumum of a sequence of values that are obtained by taking a transform of the input sequence, using the default comparer Null values are removed from the minimum Returns a future to the minumum of a sequence of values, using the default comparer Null values are removed from the minimum Further extensions to IEnumerable{T}. Groups and executes a pipeline for a single result per group Groups and executes a pipeline for a single result per group Groups and executes a pipeline for two results per group Groups and executes a pipeline for two results per group Groups and executes a pipeline for three results per group Groups and executes a pipeline for three results per group Groups and executes a pipeline for four results per group Groups and executes a pipeline for four results per group Computes the sum of a sequence of values The values in the sequence must support the Add operator Computes the sum of the sequence of values that are obtained by invoking a transform function on each element of the input sequence. The values returned by the transform function must support the Add operator Computes the mean average of a sequence of values The values in the sequence must support the Add and Divide(Int32) operators Computes the mean average of the sequence of values that are obtained by invoking a transform function on each element of the input sequence. The values returned by the transform function must support the Add and Divide(Int32) operators Computes the maximum (using a custom comparer) of a sequence of values. Computes the maximum (using a custom comparer) of the sequence of values that are obtained by invoking a transform function on each element of the input sequence. Computes the minimum (using a custom comparer) of a sequence of values. Computes the minimum (using a custom comparer) of the sequence of values that are obtained by invoking a transform function on each element of the input sequence. Poor-man's version of a Future. This wraps a result which *will* be available in the future. It's up to the caller/provider to make sure that the value has been specified by the time it's requested. Class representing a value which will be available some time in the future. Retrieves the value, if available, and throws InvalidOperationException otherwise. Returns a string representation of the value if available, null otherwise A string representation of the value if available, null otherwise Returns the value of the future, once it has been set If the value is not yet available Implementation of IFuture which retrieves it value from a delegate. This is primarily used for FromFuture, which will transform another Future's value on demand. Creates a new FutureProxy using the given method to obtain the value when needed Creates a new FutureProxy from an existing future using the supplied transformation to obtain the value as needed Returns the value of the Future Ordered variant of IDataProducer; note that generally this will force data to be buffered until the sequence is complete. The unlerlying producer that can push data The comparer used to order the sequence (once complete) Generic tuple for a key and a single value The Type of the key The Type of the value Creates a new tuple with the given key and value The key for the tuple The value for the tuple Generic tuple for a key and a pair of values The Type of the key The Type of the first value The Type of the second value Creates a new tuple with the given key and values The key for the tuple The first value The second value Generic tuple for a key and a trio of values The Type of the key The Type of the first value The Type of the second value The Type of the third value Creates a new tuple with the given key and values The key for the tuple The first value The second value The third value Generic tuple for a key and a quartet of values The Type of the key The Type of the first value The Type of the second value The Type of the third value The Type of the fourth value Creates a new tuple with the given key and values The key for the tuple The first value The second value The third value The fourth value Very simple implementation of IDataProducer. Signals a single item of data. Signals multiple items of data, one at a time, then ends. Note that this method only exists to support the params modifier. In every other way it's equivalent to the ProduceAndEnd(IEnumerable{T}). Signals multiple items of data, one at a time, then ends. Pumps the specified items into this data producer, yielding results as they are received. Before an item is pumped, an internal queue is created. Pumping an item may yield results at the other end of the pipeline - any such results are buffered in the queue. When the pumping of a particular item has finished, all results in the queue are yielded. This means that naturally streaming operations (projection and filtering) require only a single item buffer. This producer "ends" when all the items have been produced. If the result pipeline ends before all items have been pumped, the buffered results are yielded but no more items are pumped. Type of element in the result pipeline Items to insert into the pipeline The pipeline to subscribe to for items to yield A sequence of yielded items. Signal the end of data. This can only be called once, and afterwards the Produce method must not be called. Event which is raised when an item of data is produced. This will not be raised after EndOfData has been raised. The parameter for the event is the Event which is raised when the sequence has finished being produced. This will be raised exactly once, and after all DataProduced events (if any) have been raised. A DataProducer with ordering capabilities Note that this may cause data to be buffered Create a new OrderedDataProducer The base source which will supply data The comparer to use when sorting the data (once complete) Encapsulates a reference compatible with the type parameter. The reference is guaranteed to be non-null unless the value has been created with the parameterless constructor (e.g. as the default value of a field or array). Implicit conversions are available to and from the type parameter. The conversion to the non-nullable type will throw ArgumentNullException when presented with a null reference. The conversion from the non-nullable type will throw NullReferenceException if it contains a null reference. This type is a value type (to avoid taking any extra space) and as the CLR unfortunately has no knowledge of it, it will be boxed as any other value type. The conversions are also available through the Value property and the parameterised constructor. Type of non-nullable reference to encapsulate Creates a non-nullable value encapsulating the specified reference. Implicit conversion from the specified reference. Implicit conversion to the type parameter from the encapsulated value. Equality operator, which performs an identity comparison on the encapuslated references. No exception is thrown even if the references are null. Inequality operator, which performs an identity comparison on the encapuslated references. No exception is thrown even if the references are null. Equality is deferred to encapsulated references, but there is no equality between a NonNullable[T] and a T. This method never throws an exception, even if a null reference is encapsulated. Type-safe (and non-boxing) equality check. Type-safe (and non-boxing) static equality check. Defers to the GetHashCode implementation of the encapsulated reference, or 0 if the reference is null. Defers to the ToString implementation of the encapsulated reference, or an empty string if the reference is null. Retrieves the encapsulated value, or throws a NullReferenceException if this instance was created with the parameterless constructor or by default. The Operator class provides easy access to the standard operators (addition, etc) for generic types, using type inference to simplify usage. Indicates if the supplied value is non-null, for reference-types or Nullable<T> True for non-null values, else false Increments the accumulator only if the value is non-null. If the accumulator is null, then the accumulator is given the new value; otherwise the accumulator and value are added. The current total to be incremented (can be null) The value to be tested and added to the accumulator True if the value is non-null, else false - i.e. "has the accumulator been updated?" Evaluates unary negation (-) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates bitwise not (~) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates bitwise or (|) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates bitwise and (&) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates bitwise xor (^) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Performs a conversion between the given types; this will throw an InvalidOperationException if the type T does not provide a suitable cast, or for Nullable<TInner> if TInner does not provide this cast. Evaluates binary addition (+) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary addition (+) for the given type(s); this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary subtraction (-) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary subtraction(-) for the given type(s); this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary multiplication (*) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary multiplication (*) for the given type(s); this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary division (/) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary division (/) for the given type(s); this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary equality (==) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary inequality (!=) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary greater-than (>) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary less-than (<) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary greater-than-on-eqauls (>=) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates binary less-than-or-equal (<=) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Evaluates integer division (/) for the given type; this will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. This operation is particularly useful for computing averages and similar aggregates. Provides standard operators (such as addition) that operate over operands of different types. For operators, the return type is assumed to match the first operand. Returns a delegate to convert a value between two types; this delegate will throw an InvalidOperationException if the type T does not provide a suitable cast, or for Nullable<TInner> if TInner does not provide this cast. Returns a delegate to evaluate binary addition (+) for the given types; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary subtraction (-) for the given types; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary multiplication (*) for the given types; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary division (/) for the given types; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Provides standard operators (such as addition) over a single type Returns the zero value for value-types (even full Nullable<TInner>) - or null for reference types Returns a delegate to evaluate unary negation (-) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate bitwise not (~) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate bitwise or (|) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate bitwise and (&) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate bitwise xor (^) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary addition (+) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary subtraction (-) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary multiplication (*) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary division (/) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary equality (==) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary inequality (!=) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary greater-then (>) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary less-than (<) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary greater-than-or-equal (>=) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Returns a delegate to evaluate binary less-than-or-equal (<=) for the given type; this delegate will throw an InvalidOperationException if the type T does not provide this operator, or for Nullable<TInner> if TInner does not provide this operator. Class to provide partial comparisons, which can be useful when implementing full comparisons in other classes. Provides comparisons for just the references, returning 0 if the arguments are the same reference, -1 if just the first is null, and 1 if just the second is null. Otherwise, this method returns null. It can be used to make life easier for an initial comparison before comparing individual components of an object. The type of objects to compare The first object to compare The second object to compare Compares two instances of T using the default comparer for T, returning a non-null value in the case of inequality, or null where the default comparer would return 0. This aids chained comparisons (where if the first values are equal, you move on to the next ones) if you use the null coalescing operator. The type of objects to compare The first object to compare The second object to compare Compares two instances of T using the specified comparer for T, returning a non-null value in the case of inequality, or null where the comparer would return 0. This aids chained comparisons (where if the first values are equal, you move on to the next ones) if you use the null coalescing operator. The type of objects to compare The comparer to use The first object to compare The second object to compare Compares two instances of T, returning true if they are definitely the same (i.e. the same references), false if exactly one reference is null, or null otherwise. This aids implementing equality operations. The type of objects to compare The first object to compare The second object to compare Generic class which copies to its target type from a source type specified in the Copy method. The types are specified separately to take advantage of type inference on generic method arguments. Copies all readable properties from the source to a new instance of TTarget. Static class to efficiently store the compiled delegate which can do the copying. We need a bit of work to ensure that exceptions are appropriately propagated, as the exception is generated at type initialization time, but we wish it to be thrown as an ArgumentException. Thread-safe equivalent of System.Random, using just static methods. If all you want is a source of random numbers, this is an easy class to use. If you need to specify your own seeds (eg for reproducible sequences of numbers), use System.Random. Returns a nonnegative random number. A 32-bit signed integer greater than or equal to zero and less than Int32.MaxValue. Returns a nonnegative random number less than the specified maximum. A 32-bit signed integer greater than or equal to zero, and less than maxValue; that is, the range of return values includes zero but not maxValue. maxValue is less than zero. Returns a random number within a specified range. The inclusive lower bound of the random number returned. The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue. A 32-bit signed integer greater than or equal to minValue and less than maxValue; that is, the range of return values includes minValue but not maxValue. If minValue equals maxValue, minValue is returned. minValue is greater than maxValue. Returns a random number between 0.0 and 1.0. A double-precision floating point number greater than or equal to 0.0, and less than 1.0. Fills the elements of a specified array of bytes with random numbers. An array of bytes to contain random numbers. buffer is a null reference (Nothing in Visual Basic). Utility class providing a number of singleton instances of Range<char> to indicate the various ranges of unicode characters, as documented at http://msdn.microsoft.com/en-us/library/20bw873z.aspx. Note that this does not indicate the Unicode category of a character, merely which range it's in. TODO: Work out how to include names. Can't derive from Range[char]. Returns the unicode range containing the specified character. Character to look for The unicode range containing the specified character, or null if the character is not in a unicode range. String of UTF-32 characters (ints). This class is immutable, and so is thread-safe after copying, but copies must be originally made in a thread-safe manner so as to avoid seeing invalid data. Number of samples to take (at most) to form a hash code. An empty UTF-32 string. UTF-32 characters making up the string. Returns whether or not an integer value is a valid UTF-32 character, that is, whether it is non-negative and less than or equal to 0x10ffff. The value to test. Whether or not the given value is a valid UTF-32 character. Used inside this class to construct extra strings quickly, when validation isn't required and a reference copy is good enough. Creates a UTF-32 string from an array of integers, all of which must be less than 0x10ffff and non-negative. A copy of the array is taken so that further changes to the array afterwards are ignored. The array of characters to copy. Must not be null. Creates a UTF-32 string from a System.String (UTF-16), converting surrogates where they are present. The string in UTF-16 format. Takes a substring of this string, starting at the given index. Starting index of desired substring in this string A substring of this string Takes a substring of this string, starting at the given index and containing the given number of characters. Starting index of desired substring in this string The number of characters in the desired substring A substring of this string Finds the index of another Utf32String within this one. Value to find The index of value within this string, or -1 if it isn't found Finds the index of another Utf32String within this one, starting at the specified position. Value to find First position to consider when finding value within this Utf32String The index of value within this string, or -1 if it isn't found Finds the index of another Utf32String within this one, starting at the specified position and considering the specified number of positions. Value to find First position to consider when finding value within this Utf32String Number of positions to consider The index of value within this string, or -1 if it isn't found Finds the first index of the specified character within this string. Character to find The index of the first occurrence of the specified character, or -1 if it is not found. Finds the first index of the specified character within this string, starting at the specified position. Character to find First position to consider The index of the first occurrence of the specified character, or -1 if it is not found. Finds the first index of the specified character within this string, starting at the specified position and considering the specified number of positions. Character to find First position to consider Number of positions to consider The index of the first occurrence of the specified character, or -1 if it is not found. Compares two UTF-32 strings (in a culture-insensitive manner) for equality. The other string to compare this one to. Whether or not this string is equal to the other one. Compares one string with another for equality. The first string to compare The second string to compare true if the strings are equivalent; false otherwise Compares the two specified strings. The first string to compare The second string to compare 0 if both strings are null or they are equal; a negative number if strA is null or is lexicographically before strB; a positive number otherwise Concatenates an array of strings together. The array of strings to concatenate. Returns a concatenation of the given strings. The first string The second string A string consisting of the first string followed by the second Returns a concatenation of the given strings. The first string The second string The third string A string consisting of the first string followed by the second, followed by the third Returns a concatenation of the given strings. The first string The second string The third string The fourth string A string consisting of the first string followed by the second, followed by the third, followed by the fourth Copies the UTF-32 characters in this string to an int array. An array of integers representing the characters in this array. Converts the UTF-32 string into a UTF-16 string, creating surrogates if necessary. A UTF-16 string (System.String) representing the same character data as this UTF-32 string. Returns whether or not this UTF-32 string is equal to another object. The object to compare this UTF-32 string to. Whether or not this object is equal to the other one. Returns a hashcode formed from sampling some of the characters in this UTF-32 string. This gives a good balance between performance and hash collisions. A hashcode for this UTF-32 string. Returns a concatenation of the given strings. The first string The second string A string consisting of the first string followed by the second Determines whether two specified String objects have the same value. A string or a null reference A string or a null reference true if the value of strA is the same as the value of strB; otherwise, false Determines whether two specified String objects have different values. A string or a null reference A string or a null reference true if the value of strA is different from the value of strB; otherwise, false Enumerates the characters in the string. The enumerator for Compares this string to another Utf32String. The other Utf32String to compare this string to. <0 if this string <> obj; 0 if this==object; >0 if this string > obj, with the relation defines in a culture-insensitive way in lexicographic order. Creates a shallow copy of this string. A shallow copy of this string. The number of UTF-32 characters in this string. The character at the specified index. A thread pool implementation which allows policy decisions for the number of threads to run, etc, to be programatically set. Each instance runs with entirely separate threads, so one thread pool cannot "starve" another one of threads, although having lots of threads running may mean that some threads are starved of processor time. If the values for properties such as MinThreads, IdlePeriod etc are changed after threads have been started, it may take some time before their effects are noticed. For instance, reducing the idle time from 5 minutes to 1 minute will not prevent a thread which had only just started to idle from waiting for 5 minutes before dying. Any exceptions thrown in the work item itself are handled by the WorkerException event, but all other exceptions are propagated to the AppDomain's UnhandledException event. This includes exceptions thrown by the BeforeWorkItem and AfterWorkItem events. This class is thread-safe - any thread may call any method on any instance of it. Default idle period for new pools Default min threads for new pools Default max threads for new pools If the idle period is short but we have less than the minimum number of threads, idle for this long instead, so as to avoid tight-looping. We don't enforce this minimum if the thread will die if it idles for its IdlePeriod. If the idle period is long (or infinite) then we shouldn't actually wait that long, just in case the timeout etc changes. Lock around all static members. Total number of instances created Creates a new thread pool with an autogenerated name. Creates a new thread pool with the specified name The name of the new thread pool Lock around access to all state other than events and the queue. The queue lock may be acquired within this lock. Lock for the queue itself. The state lock must not be acquired within this lock unless it is already held by the thread. The queue itself. The number of threads started (in total) by this threadpool. Used for naming threads. Sets both the minimum and maximum number of threads, atomically. This prevents exceptions which might occur when setting properties individually (e.g. going from (min=5, max=10) to (min=15, max=20), if the minimum were changed first, an exception would occur. Lock around all access to events. Raises the WorkerException event. TODO: Write to the event log if no exception handlers are attached? Delegate for the BeforeWorkItem event. Raises the BeforeWorkItem event The work item which is about to execute Whether or not the work item was cancelled by an event handler Delegate for the AfterWorkItem event. Raises the AfterWorkItem event Delegate for the ThreadExit event. Raises the WorkerThreadExit event and decrements the number of total worker threads Ensures that the pool has at least the minimum number of threads. Adds a work item to the queue, starting a new thread if appropriate. The delegate representing the work item The parameters to pass to the delegate Adds a work item to the queue, starting a new thread if appropriate. The delegate representing the work item. Adds a work item to the queue and potentially start a new thread. A thread is started if there are no idle threads or if there is already something on the queue - but in each case, only if the total number of threads is less than the maximum. The actual work item to add to the queue. Cancels the first work item with the specified ID, if there is one. Note that items which have been taken off the queue and are running or about to be started cannot be cancelled. The ID of the work item to cancel Cancels all work items in the queue. Note that items which have been taken off the queue and are running or about to be started cannot be cancelled. Starts a new worker thread. Main worker thread loop. This picks jobs off the queue and executes them, until it's time to die. Work out how long to wait for in this iteration. If the thread isn't going to die even if the wait completes, make the idle timeout at least MinWaitPeriod so we don't end up with lots of threads stealing CPU by checking too often. The time this thread last finished executing a work item. Retrieves the next work item from the queue, pausing for at most the specified amount of time. The maximum amount of time to wait for a work item to arrive, in ms. The next work item, or null if there aren't any after waiting for the specified period. Checks whether or not this thread should exit, based on the current number of threads and the time that this thread last finished executing a work item. The time this thread last finished executing a work item. Whether or not the thread is "spare" and should thus quit Executes the given work item, firing the BeforeWorkItem and AfterWorkItem events, and incrementing and decrementing the number of working threads. The work item to execute How long a thread may be remain idle for before dying, in ms. Note that a thread will not die if doing so would reduce the number of threads below MinThreads. A value of 0 here indicates that threads should not idle at all (except if the number of threads would otherwise fall below MinThreads). A value of Timeout.Infinite indicates that a thread will idle until a new work item is added, however long that is. Gets the name of the thread pool. This is used to set the name of any new threads created by the pool. The minimum number of threads to leave in the pool. Note that the pool may contain fewer threads than this until work items have been placed on the queue. A call to StartMinThreads will make sure that at least MinThreads threads have been started. This value must be non-negative. Note that a MinThreads value of 0 introduces a possible (although very unlikely) race condition where a work item may be added to the queue just as the last thread decides to exit. In this case, the work item would not be executed until the next work item was added. TODO: Try to remove this race condition The maximum number of threads to allow to be in the pool at any one time. This value must be greater than or equal to 1. The number of work items currently awaiting execution. This does not include work items currently being executed. The number of threads currently executing work items or BeforeWorkItem/AfterWorkItem/WorkerException events. The total number of threads in the pool at the present time. The priority of worker threads. Each thread's priority is set before the BeforeWorkItem event and after the AfterWorkItem event. The priority of an individual thread may be changed in the BeforeWorkItem event, and that changed priority will remain active for the duration of the work item itself. The default is ThreadPriority.Normal. Whether or not worker threads should be created and set as background threads. This is set for the thread before the BeforeWorkItem event and after the AfterWorkItem event. The background status of a thread may be changed in the BeforeWorkItem event, and that changed status will remain active for the duration of the work item itself. Default is true. Event which is fired if a worker thread throws an exception in its work item. Event fired before a worker thread starts a work item. Event fired after a worker thread successfully finishes a work item. This event is not fired if the work item throws an exception. Event called just before a thread dies. Comparer which compares an integer priority with the priority of a work item. Must only be used in the appropriate order (CompareTo(int, WorkItem)). Also, 0 is never returned by the method - effectively, the given priority is raised by 0.5, so that when a binary search is used, the value is never found but the returned index is always the bitwise complement of the correct insertion point. Access to single instance of PriorityComparer. Private constructor to prevent instantiation Implementation of IComparer.Compare - see class remarks for details. Delegate for handling exceptions. Delegate for handling exceptions thrown by work items executing in a custom thread pool. The pool which created the worker thread The work item which threw the exception The exception thrown Whether or not the exception has been handled by this delegate. The value of this parameter will be false on entry, and changing it to true will prevent any further delegates in the event from being executed. Delegate for handling the event that a thread is about to execute a work item. The pool which created the worker thread The work item which is about to execute Whether or not the work item should be cancelled. The value of this parameter will be false on entry, and changing it to true will prevent any further delegates in the event from being executed, and prevent the work item itself from being executed. Delegate for handling the event that a thread has executed a work item. The pool which created the worker thread The work item which has executed Delegate for handling the event that a thread has changed state (e.g. it's about to execute a work item, it's just executed one, etc). Also used for requests for a thread to change state (e.g. if a stop request has been received). Represents the method that is executed by a ThreadController. Exception thrown when a Lock method on the SyncLock class times out. Constructs an instance with the specified message. The message for the exception Constructs an instance by formatting the specified message with the given parameters. The message, which will be formatted with the parameters. The parameters to use for formatting. Exception thrown when a Lock method on the SyncLock class times out. Constructs an instance with the specified message. The message for the exception Constructs an instance by formatting the specified message with the given parameters. The message, which will be formatted with the parameters. The parameters to use for formatting. A lock token returned by a Lock method call on a SyncLock. This effectively holds the lock until it is disposed - a slight violation of the IDisposable contract, but it makes for easy use of the SyncLock system. This type itself is not thread-safe - LockTokens should not be shared between threads. The lock this token has been created by. Constructs a new lock token for the specified lock. The internal monitor used for locking. Releases the lock. Subsequent calls to this method do nothing. Class used for locking, as an alternative to just locking on normal monitors. Allows for timeouts when locking, and each Lock method returns a token which must then be disposed of to release the internal monitor (i.e. to unlock). All properties and methods of this class are thread-safe. Class used for locking, as an alternative to just locking on normal monitors. Allows for timeouts when locking, and each Lock method returns a token which must then be disposed of to release the internal monitor (i.e. to unlock). All properties and methods of this class are thread-safe. Lock for static mutable properties. The default timeout for new instances of this class where the default timeout isn't otherwise specified. Defaults to Timeout.Infinite. Creates a new lock with no name, and the default timeout specified by DefaultDefaultTimeout. Creates a new lock with the specified name, and the default timeout specified by DefaultDefaultTimeout. The name of the new lock Creates a new lock with no name, and the specified default timeout Default timeout, in milliseconds Creates a new lock with the specified name, and an infinite default timeout. The name of the new lock Default timeout, in milliseconds. Use Timeout.Infinite for an infinite timeout, or a non-negative number otherwise. Locks the monitor, with the default timeout. A lock token which should be disposed to release the lock The operation times out. Locks the monitor, with the specified timeout. The timeout duration. When converted to milliseconds, must be Timeout.Infinite, or non-negative. A lock token which should be disposed to release the lock The operation times out. Locks the monitor, with the specified timeout. Derived classes may override this method to change the behaviour; the other calls to Lock all result in a call to this method. This implementation checks the validity of the timeout, calls Monitor.TryEnter (throwing an exception if appropriate) and returns a new LockToken. The timeout, in milliseconds. Must be Timeout.Infinite, or non-negative. A lock token which should be disposed to release the lock The operation times out. Unlocks the monitor. This method may be overridden in derived classes to change the behaviour. This implementation simply calls Monitor.Exit. The default timeout for the The name of this lock. The internal monitor used for locking. While this is owned by the thread, it can be used for waiting and pulsing in the usual way. Note that manually entering/exiting this monitor could result in the lock malfunctioning. Lock count (incremented with Lock, decremented with Unlock). Creates a new lock with no name, and the default timeout specified by DefaultDefaultTimeout. Creates a new lock with the specified name, and the default timeout specified by DefaultDefaultTimeout. The name of the new lock Creates a new lock with no name, and the specified default timeout Default timeout, in milliseconds Creates a new lock with the specified name, and an infinite default timeout. The name of the new lock Default timeout, in milliseconds. Use Timeout.Infinite for an infinite timeout, or a non-negative number otherwise. Sets the "inner" lock for this lock, returning this lock. This is a convenience method for setting InnerLock as part of a variable declaration. OrderedLock inner = new OrderedLock(); OrderedLock outer = new OrderedLock().SetInnerLock(inner); The inner This lock is returned. Locks the monitor, with the specified timeout. This implementation validates the ordering of locks, and maintains the current owner. The timeout, in milliseconds. Must be Timeout.Infinite, or non-negative. A lock token which should be disposed to release the lock The operation times out. The lock order would be violated if this lock were taken out. (i.e. attempting to acquire the lock could cause deadlock.) Unlocks the monitor, decreasing the count and setting the owner to null if the count becomes 0. The current owner of the lock, if any. Gets or sets the "inner" lock for this lock. This lock must not be acquired after the inner one, unless it has already been acquired previously. Inner locks are transitive - if A has an inner lock B, and B has an inner lock C, then C is also effectively an inner lock of A. If this property to null, this lock is considered not to have an inner lock. Class designed to control a worker thread (co-operatively). Lock used throughout for all state management. (This is unrelated to the "state" variable.) The delegate to be invoked when the thread is started. State to pass to the "starter" delegate when the thread is started. This reference is discarded when the new thread is started, so it won't prevent garbage collection. Creates a new controller. The delegate to invoke when the thread is started. Must not be null. The state to pass to the delegate. May be null. Creates a new controller without specifying a state object to pass when the delegate is invoked. The delegate to invoke when the thread is started. Creates the thread to later be started. This enables properties of the thread to be manipulated before the thread is started. The thread has already been created. Starts the task in a separate thread, creating it if it hasn't already been created with the CreateThread method. The thread has already been started. Tell the thread being controlled by this controller to stop. This call does not throw an exception if the thread hasn't been created, or has already been told to stop - it is therefore safe to call at any time, regardless of other information about the state of the controller. Depending on the way in which the controlled thread is running, it may not take notice of the request to stop for some time. Runs the task specified by starter, catching exceptions and propagating them to the Exception event. Whether the thread has been started. A thread can only be started once. Thread being controlled. May be null if it hasn't been created yet. Whether or not the thread is stopping. This may be used by the thread itself to test whether or not to stop, as well as by clients checking status. To see whether the thread has actually finished or not, use the IsAlive property of the thread itself. Event raised if the controlled thread throws an unhandled exception. The exception is not propagated beyond the controller by default, however by adding an ExceptionHandler which simply rethrows the exception, it will propagate. Note that in this case any further ExceptionHandlers added after the propagating one will not be executed. This event is raised in the worker thread. Event raised when the thread has finished and all exception handlers have executed (if an exception was raised). Note that this event is raised even if one of the exception handlers propagates the exception up to the top level. This event is raised in the worker thread. Event raised when a stop is requested. Worker threads may register for this event to allow them to respond to stop requests in a timely manner. The event is raised in the thread which calls the Stop method. Class encapsulating an item of work to be executed in a CustomThreadPool. Creates a new instance of this class. The ID of the work item. May be null. Whether or not the parameter array should be preserved during the work item's execution to allow the information to be retrieved in the WorkerException and AfterWorkItem events. Whether or not the parameter array provided should be cloned. This should be true if the contents of the passed array will be changed by the caller afterwards, but false in the common case of creating the array solely for the purpose of constructing this work item. Note that the values within the array are not cloned - just the array itself. The priority of this work item. The delegate to run when the work item is executed. Must not be null. The parameters to pass to the target delegate. May be null if the delegate takes no parameters. Creates a new work item with the given target delegate and parameters. The parameters (if any) are cloned on construction and preserved during the work item's execution. The ID of the constructed work item is null, and the priority is 0. The delegate to run when the work item is executed. Must not be null. The parameters to pass to the target delegate. May be null if the delegate takes no parameters. Invokes the work item. The target delegate for the work item. This is the delegate which is run when the work item is executed. The parameters passed to the delegate. This may be null, and will definitely be null if PreserveParameters is false and the work item has started executing. The contents of the returned array should not be changed. The priority of this work item compared with others. Note that this is entirely independent of the thread priority - it serves only to specify the order of execution of a work item. Items with a higher priority are added ahead of items with a lower priority in the queue. Whether or not to preserve parameters during and after execution. If this is true, the parameters are available in the AfterWorkItem and WorkerException events of the containing CustomThreadPool. However, this means that the contents cannot be garbage collected until after the work item has finished executing, which may be costly in some situations. The ID of the work item, which may be null. This is provided by the caller when the work item is constructed, and is used for cancellation purposes. Extensions to System.Object for LINQ to XML purposes. Returns the properties of the given object as XElements. Properties with null values are still returned, but as empty elements. Underscores in property names are replaces with hyphens. Returns the properties of the given object as XElements. Properties with null values are returned as empty attributes. Underscores in property names are replaces with hyphens.