PeanutButter
Loading...
Searching...
No Matches
PeanutButter.Utils Namespace Reference

Classes

class  ArrayExtensions
class  AssemblyExtensions
 Provides extension methods for Assemblies. More...
class  Async
 Provides methods to run async code synchronously and safely http://stackoverflow.com/questions/5095183/how-would-i-run-an-async-taskt-method-synchronously. More...
class  AsyncExtensionsForIEnumerables
 Useful extensions for IEnumerable<T> collections, with async in mind. More...
class  AttributeWalkStep
 Emitted at every stage of walking attributes per type in the ancestry tree. More...
class  AutoBarrier
 Provides an auto-signaller around a barrier: when this is disposed, it will SignalAndWait on the barrier, meaning you don't need to put required barrier unlocks in a finally clause. More...
class  AutoDeleter
 Provides a mechanism to autmatically delete one or more files using the IDisposable pattern. Use this when you'd like to clean up some temporary files after an operation completes without having to worry about exception handling, etc. Files which cannot be deleted (eg: locked for reading / writing) will be left behind. No exceptions are thrown. Files which have been removed in the interim do not cause any exceptions. More...
class  AutoDisposer
 Provides a mechanism to dispose of other disposables when it is disposed. This allows for flattening out nested using() blocks with an outer AutoDisposer which takes care of disposing registered items (in reverse order) when it is disposed. More...
class  AutoLocker
 Class to use the using() {} pattern to take care of locking / unlocking one of: More...
class  AutoResetter
 Provides a mechanism to run code on construction and disposal, irrespective of exception handling Use this, for example, to set up and tear down state required for a test – your constructionAction is called immediately upon construction and the using() pattern guarantees that your disposalAction is called at disposal, even if your test fails. More...
class  AutoResetter< T >
 Provides a mechanism to run code on construction and disposal, irrespective of exception handling Use this, for example, to set up and tear down state required for a test – your constructionAction is called immediately upon construction and the using() pattern guarantees that your disposalAction is called at disposal, even if your test fails. This is the variant of AutoResetter where: More...
class  AutoResettingFile
 Facilitates easily reverting a file to a prior state via the IDisposable pattern. More...
class  AutoTempEnvironmentVariable
 Provides a scoped, temporary environment variable. More...
class  AutoTempFile
 Provides a mechanism to create, read and write a temporary file which is automatically removed at disposal time. More...
class  AutoTempFolder
 Provides a mechanism for creating a temporary folder which is automatically deleted upon disposal. More...
class  AutoWorkFolder
 Performs work within the provided working folder and then skips out of there. Probably not a good idea to use whilst performing parallel processing as it changes the entire CWD for the current process! More...
class  Benchmark
 Provides a static Time method which times running the provided action the specified number of times. More...
class  BooleanExtensions
 Provides extensions for boolean values. More...
class  Builder< TBuilder, TEntity >
 Provides a base class with simple builder functionality. More...
class  ByteArrayExtensions
 Provides some extensions useful for byte arrays. More...
class  CannotZipNullException
 Thrown when an attempt is made to strict-zip null and anything else. More...
class  CircularList< T >
 Represents a list which circles back on itself such that enumerating over it produces an unending series. EG: if it was created with the numbers [ 1, 2, 3 ], then enumeration would yield [ 1, 2, 3, 1, 2, 3, 1 ... ] For all operations except enumeration and indexing, the collection will behave as an infinitely repeating series. For obvious reasons, CopyTo will copy the internal, limited collection. More...
class  Commandline
 Provides a wrapper around handling a commandline properly. More...
class  ConcurrentCollectionExtensions
 Provides some common functionality for concurrent collections. More...
class  ConsoleSteps
 Provides factory methods for basic console steps. More...
class  DateTimeExtensions
 Provides some useful extension methods for DateTime values. More...
class  DateTimeParser
class  DecimalDecorator
 Provides a relatively "safe" interchange between decimal and string notations for numbers, inspecting the input string to try to make the best decision based on the contents of the string instead of just relying on the current thread culture (which causes issues when communicating between machines with different ideas of what constitutes "correct" decimal notation a prime example being transport of decimals from Javascript into a ZA .net culture – but there are others) More...
class  DeepEqualityTester
 Provides a mechanism to test deep-equality of two objects with an optional list of properties to ignore by name. Deep equality testing bypasses reference-checking of container objects and compares primitive propertyt values. Use this to test whether or not two objects essentially contain the same data. More conveniently, use the following extension methods: More...
class  DefaultBackoffStrategy
 Default backoff strategy for retries: linear, 100ms per attempt. More...
class  DictionaryExtensions
 Provides extensions to convert from non-generic IDictionary to a generic one. More...
class  DisposableWrapper
 Provides an eventing wrapper around another disposable item, raising events before and after disposal and on disposal error. More...
class  DisposableWrapperErrorEventArgs
 The event args raised when the disposable .Dispose chucks an error. More...
class  DisposableWrapperEventArgs
 The event arguments raised with every DisposableWrapper event. More...
class  ElementNotFoundException
 thrown when a Find<T>() call finds no elements More...
class  EmptyEnumerator< T >
class  EnumerableWrapper
 Wraps an object which would be an acceptable enumerable in a foreach (due to .NET compile-time duck-typing) into an actual IEnumerator. More...
class  EnumerableWrapper< T >
 Provides the typed EnumerableWrapper. More...
class  EnumeratorWrapper< T >
 Wraps an object which would be an acceptable enumerator in a foreach (due to .NET compile-time duck-typing) into an actual IEnumerator. More...
class  Env
 Provides easy access to environment variables with fallback. More...
class  ExclusiveSynchronizationContext
class  ExpressionUtil
 Utility class to assist with dealing with expressions. More...
class  ExtensionsForIEnumerables
 Useful extensions for IEnumerable<T> collections. More...
class  FilePathResolver
class  Find
 Finds files. More...
class  FlagExtensions
 Provides extensions to help with common enum operations. More...
class  FluencyExtensions
 Add fluency anywhere - as if all things were buildable! More...
class  HttpEncoder
 This is adapted from the dotnet runtime to avoid having to depend on System.Web, which is not readily available for older targets (read: .NET Framework 4.5.2, which isn't really supported any more...) -> PB only needs UrlEncode, so a lot of the original source is stripped out but the source classes of interest are HttpEncoder HexConverter.
interface  IAutoTempFolder
 Describes the contract for an auto-deleting temporary folder. More...
interface  IBackoffStrategy
 Describes a service which backs off (ie, waits) according to the retry attempt number. More...
interface  IBuilder< TBuilder, TEntity >
 Most basic interface to implement to be considered a builder. More...
interface  ICircularList< T >
 Defines the Circular List, which should behave a lot like an IList<T> except that enumerating it (when there are any values) will be an infinite task, running through all the values over and over. More...
interface  IDateTimeParser
 Versatile DateTime parser. More...
interface  IEnumerableWrapper
 Used to describe a wrapper. More...
interface  IFilePathResolver
 Provides a service to resolve path files, including with globbing. More...
interface  ILazyWithContext< TValue >
 Provides a mechanism for lazy evaluation with a provider context. More...
class  InfiniteEnumerator< T >
class  InvalidEnvironmentVariableValue
interface  IParallelWorker
 Describes a parallel worker for actions. More...
interface  IParallelWorker< T >
 Describes a parallel worker for functions returning values. More...
interface  IPool< T >
 Describes a pooling service for the underlying type T. More...
interface  IPoolItem< T >
 Represents a pooled item of type T. More...
interface  IProcessIO
 Wraps process IO (stdout, stderr) into an easy-to-access disposable source. More...
interface  IPropertyOrField
 Represents a property or a field on an object. More...
interface  IRateLimiter
 Provides a mechanism for rate-limiting calls to blocks of code. Calls made within limits are executed, those which exceed limits are dropped. More...
interface  IRollingWindow< T >
 Provides a rolling window of data to the given size Disposing the RollingWindow immediately releases all references to items within the inner collection and renders the instance unusable from then on. More...
interface  ISingleItemCache< T >
 SingleItemCache provides a light, fast, caching wrapper around a function to generate a value with a provided TTL. More...
interface  ISlidingWindow< T >
 Provides an easy mechanism for a sliding window of data This collection is not thread-safe - you should add your own thread-safety as appropriate. More...
interface  ISlidingWindowItem< out T >
 Describes a sliding window item. More...
interface  ITextStatusSteps
 Describes the contract for textural feedback around running activities. More...
interface  IUnstartedProcessIO
 Provides the contract for an unstarted ProcessIO, as would be obtained from ProcessIO.In(workingDir) More...
interface  IWorker
 Describes a worker. More...
class  KeyValueCollectionExtensions
 Provides extension methods on KeyValuePairCollections. More...
class  LazyWithContext< TContext, TValue >
class  ListExtensions
 Provides methods on lists as one might expect from JavaScript. More...
class  MaxAttemptsRetryContext
 Provides a wrapping context around retried code. More...
class  MedianExtensions
 Provides .Median() extension methods for numeric collections. More...
class  MemberNotFoundException
 Exception thrown when a property cannot be found by name. More...
class  MetadataExtensions
 Provides extension methods to set and retrieve metadata on any object. Under the hood, these methods use a ConditionalWeakTable to store your metadata, so the metadata is garbage-collected when your managed objects are garbage-collected. More...
class  MIMEType
 Kept to maintain legacy code. More...
class  MimeTypes
 Provides a mechanism for guessing the MIME type of a file by its extension. Of course, this isn't perfect - magic bytes are probably more reliable - but also more effort. This code is largely copied from https://github.com/samuelneff/MimeTypeMap/blob/master/MimeTypeMap.cs The code in this file is licensed under the. More...
class  MockStoreExtensions
 Provides basic extensions for using a mocked store against any object, levering off of PeanutButter's metadata logic. More...
class  MostRecentlyUsedEnumerator< T >
class  MostRecentlyUsedList< T >
 Holds a list of most-recently-used items, up to the provided capacity. New items displace the older ones, and re-adding the same item will reposition that item at the top of the list. More...
class  NoPooledItemAvailableException
 Thrown when no item could be resolved from the pool with a pure Take. More...
class  NotFoundException
 Thrown when the caller expects to eject a message from a non-empty collection but no match was found. More...
class  ObjectExtensions
 Provides a set of convenience extensions on everything. More...
class  ParallelWorker
 Encapsulates some work which must be run in parallel. More...
class  ParallelWorker< T >
 Encapsulates some work which must be run in parallel. More...
class  Platform
 Platform abstractions. More...
class  Pool< T >
 Provides a generic pooling mechanism using the Disposable pattern. More...
class  PoolItem< T >
class  PortFinder
 Utility class to find open ports for binding to. More...
class  ProcessFailedToStartException
 Thrown when ProcessIO is unable to start the requested application. More...
class  ProcessIO
class  PropertyOrField
 Provides a single storage / representation for a Property or a Field. More...
class  PropertyOrFieldExtensions
class  PyLike
 Provides a Python-like Range method. More...
class  QueueExtensions
 Provides some useful extensions for Queues. More...
class  RandomNumber
 provides a singleton wrapper around Random.Next to reduce the chances of clashing More...
class  RateLimiter
class  RetriesExceededException
 Thrown when max retries are exceeded. More...
class  Retry
 Retries operations up to a specific number of times. More...
class  RetryExtensions
 Provides common functionality to retry logic with configurable delay. More...
class  RollingWindow< T >
class  RollingWindowSnapshotEnumerator< T >
class  Run
 Provides convenience wrapper functions to run small bits of work in parallel threads, not tasks. No async/await, no Tasks (unless you want to return them and await them yourself). No TPL. No handbrakes. No magic context. No guarantees, except that your work will be executed. May make the host machine very tired. More...
class  RunningAverage
 Provides a convenience class to keep a running average of values without storing the values in memory. More...
class  Runtime
 Used to determine what runtime we're currently running on. More...
class  SafeWalk
 Utility class to provide the ability to enumerate files without throwing exceptions on access errors. More...
class  SingleDebuggerBlock
 Provides a mechanism to make debugging an application a little easier: using the disposable pattern, surround a block of code with the scope for this item's disposal and you'll get: More...
class  SingleItemCache< T >
 SingleItemCache provides a light, fast, caching wrapper around a function to generate a value with a provided TTL. More...
class  SkipStringifyAttribute
 Signals to the .Stringify() extension that this property or field should be ignored in the output. More...
class  SlidingWindow< T >
class  SlidingWindowEstimatedTimeRemainingExtensions
 Provides convenience functions to predict an estimated time remaining based on a remaining item count. More...
class  SlidingWindowItem< T >
class  SlidingWindowRateExtensions
 Provides convenience extensions for sliding windows. More...
class  Steps
 Provides a mechanism to surround an action with a pre-action and post-action. More...
class  StreamExtensions
 Provides utility extensions on Stream objects. More...
class  StrictComparer< TKey >
class  StringExtensions
 Provides utility extensions for strings. More...
class  Stringifier
 Provides convenience functions to get reasonable string representations of objects and collections. More...
class  StringifierStringExtensions
class  SuppressedTextStatusSteps
 Provide a mechanism to swap out noisy steps for fully-suppressed ones, esp from testing. More...
class  TaskExtensions
 Extension methods for tasks Suggest: Use Async.RunSync, which does more cleverness. More...
class  TextStatusSteps
 Provides an easy mechanism for steps of a process with status feedback, ie "starting X..." / {does X} / {"completed" / "failed"}. More...
class  TimeBasedRetryContext
 Provides a wrapping context around retried code. More...
class  TimeSpanExtensions
 Adds methods similar to those found on DateTime to TimeSpan. More...
class  TypeEqualityTester
 Tests shape equality between two types (YMMV) More...
class  TypeExtensions
 Helper extensions for Types. More...
class  TypeFinder
 Find loaded types by name. More...
class  Types
class  UnableToFindOpenPortException
class  UnevenZipException
 Thrown when an attempt is made to zip two collections of uneven size. More...
class  UnevenZipException< T1, T2 >
 Thrown when an attempt is made to zip two collections of uneven size. Also includes references to the two collections. More...
class  UriExtensions
 Provides extensions for Uri objects and url strings. More...
class  Validate
 Common validations; perhaps someday this should be made public?
class  Validator< T >
class  ValidatorAnd< T >
class  WebObjectExtensions
 Provides some more object extensions, for webby usages. More...
class  Worker
 base class for parallel workers More...
class  WorkResult
 Stores the exception (or none) from a single piece of work. More...
class  WorkResult< T >
class  WorkResultExtensions
 Provides convenience extensions for work results. More...

Enumerations

enum  StorageTypes { Auto , InMemory , OnDisk }
 The types of storage supported by AutoResettingFile. More...
enum  MergeWithPrecedence { PreferFirstSeen , PreferLastSeen }
 Sets the precedence when merging data with the same keys. More...
enum  MergeIntoPrecedence { PreferTargetData , PreferNewData }
 Sets the precedence when merging new data into an existing dictionary. More...
enum  ErrorStrategies { Throw , Suppress }
 What to do when one or more errors are encountered in a collection of WorkResults. More...
enum  ExceptionHandlingStrategies { Throw , Suppress }
 When configuring exception handling for Run.*, your handler should return one of these values in response to being called with a thrown exception. More...
enum  ObjectComparisons { PropertiesAndFields , PropertiesOnly }
 Determines the comparison strategy for DeepEquals and friends. More...
enum  PathType { Auto , Unix , Windows }
 Specifies the kind of path required when joining collections of strings to form a path. More...
enum  OutputModes { BufferedCollections , Events }
 The two possible modes for consuming outputs from the process. More...
enum  StandardIo { StdOut , StdErr , StdOutOrStdErr }
enum  PropertyOrFieldTypes { Property , Field }
 Differentiates between PropertyOrField storage for properties or fields. More...
enum  ErrorHandlerResult { NoError , Rethrow , Suppress }
 What to do with an error. More...
enum  Eol { Lf , CrLf }
 Specifies the expected eol character for a text blob. More...

Functions

delegate void ActionRef< T1 > (ref T1 item)
 Defines an action to run on a reference to a value type.
delegate void DisposableWrapperEventHandler (object sender, DisposableWrapperEventArgs args)
 The delegate type for disposable wrapper event handling.
delegate void DisposableWrapperErrorEventHandler (object sender, DisposableWrapperErrorEventArgs args)
 The delegate type for disposable wrapper event handling.

Enumeration Type Documentation

◆ Eol

Specifies the expected eol character for a text blob.

Enumerator
Lf 

Line-feed only (eg Linux)

CrLf 

Carriage-return, Line-feed (eg Windows)

◆ ErrorHandlerResult

What to do with an error.

Enumerator
NoError 

Return this when you have no error to work with.

Rethrow 

Rethrow it.

Suppress 

Suppress it.

◆ ErrorStrategies

What to do when one or more errors are encountered in a collection of WorkResults.

Enumerator
Throw 

Throw all errors in an AggregateException.

Suppress 

Suppress the errors - just return the results.

◆ ExceptionHandlingStrategies

When configuring exception handling for Run.*, your handler should return one of these values in response to being called with a thrown exception.

Enumerator
Throw 

Re-throw the exception.

Suppress 

Suppress the exception.

◆ MergeIntoPrecedence

Sets the precedence when merging new data into an existing dictionary.

Enumerator
PreferTargetData 

Prefer target data over new data, ie discard the new value if already found in the target.

PreferNewData 

Prefer to new data over existing target data, ie overwrite the target value if found.

◆ MergeWithPrecedence

Sets the precedence when merging data with the same keys.

Enumerator
PreferFirstSeen 

Prefer the first value seen.

PreferLastSeen 

Prefer the last value seen.

◆ ObjectComparisons

Determines the comparison strategy for DeepEquals and friends.

Enumerator
PropertiesAndFields 

Test properties and fields (default behavior for DeepEquals)

PropertiesOnly 

Only test properties (behavior for PropertyAssert)

◆ OutputModes

The two possible modes for consuming outputs from the process.

Enumerator
BufferedCollections 

I/O is done via looping on one or more of the lazy collections.

  • StandardError
  • StandardOutput
  • StandardOutputAndErrorInterleaved => simply foreach on them - the loop will complete when the process exits This is the default, since it's the easiest to consume.
Events 

I/O is done via raised events. The buffered collections will not be updated. This is useful for streams of data which would consume a lot of memory (eg piping from a mysqldump)

◆ PathType

Specifies the kind of path required when joining collections of strings to form a path.

Enumerator
Auto 

Select the path type for the current platform.

Unix 

Unix path type, delimited by /.

Windows 

Windows path type, delimited by \.

◆ PropertyOrFieldTypes

Differentiates between PropertyOrField storage for properties or fields.

Enumerator
Property 

This member is a Property.

Field 

This member is a Field.

◆ StorageTypes

The types of storage supported by AutoResettingFile.

Enumerator
Auto 

Automatically select storage based on file size.

InMemory 

Store in memory.

OnDisk 

Store on disk.

Function Documentation

◆ ActionRef< T1 >()

delegate void PeanutButter.Utils.ActionRef< T1 > ( ref T1 item)

Defines an action to run on a reference to a value type.

Parameters
item
Template Parameters
T1