Voodoo.Patterns
Description
A c# library containing extension methods and reusable base classes, the automated tests in the project are probably the best documentation.
The project is hosted on Github and is available for use under the MIT software license.
You can report bugs and discuss features on the GitHub issues page.
Fork on Github »
Install from Nuget
PM> Install-Package Voodoo.Patterns
Requirements
.net 4.0, async support for .net 4.5+
Voodoo
CollectionExtensions
A set of utility extensions related to IEnumerable, IEnumerable<T> and ICollection <T>
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
Response |
|
Try<T>(Action action) |
|
static
|
T |
|
Execute<T>(Func<T> action) |
|
static
|
Task<T> |
|
ExecuteAsync<T>(Func<Task<T>> action) |
|
CollectionExtensions
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
CollectionReconciler<TExisting,TModified,TKey> |
ICollection<TExisting> |
Reconcile<TExisting,TModified,TKey>(ICollection<TModified> modified, Func<TExisting,TKey> existingKey, Func<TModified,TKey> modifiedKey) |
|
static
|
void |
ICollection<T> |
AddIfNotNull<T>(T item) |
|
static
|
void |
ICollection<String> |
AddIfNotNullOrWhiteSpace(object item) |
|
static
|
ListResponse<T> |
IEnumerable<T> |
ToListResponse<T>() |
|
static
|
T[] |
Array |
ToArray<T>() |
|
static
|
T[] |
IEnumerable |
ToArray<T>() |
|
static
|
IEnumerable<T> |
IEnumerable<T> |
ForEach<T>(Action<T> action) |
|
static
|
bool |
ICollection<T> |
ContainsAny<T>(ICollection<T> toFind) |
|
static
|
bool |
ICollection<T> |
ContainsAll<T>(ICollection<T> toFind) |
|
static
|
T[] |
ICollection |
ToArray<T>() |
|
static
|
T[] |
ICollection<T> |
ToArray<T>() |
|
ConversionExtensions
A set of utility extensions for converting or changing objects
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
T |
object |
As<T>() |
attempts to convert anything to anything else, may return null, see below |
static
|
T |
object |
To<T>() |
attempts to convert anything to anything else, never returns null, see below |
static
|
DateTime |
DateTime |
ToStartOfDay() |
sets the time component to 00:00:00:000 |
static
|
DateTime |
DateTime |
ToEndOfDay() |
sets the time component to 23:59:59:999 |
static
|
string |
object |
ToDebugString() |
returns the results of the ObjectStringificationQuery
listing out all properites and thier values of an object.
You can set the maximum number of items in a collection with VoodooGlobalConfiguration.
With default error handling behavior in place a Command or Query will include a stringified version of the request in the logs.
|
static
|
string |
object |
ToCode() |
returns the results of the .ObjectEmissionQuery, essentially serialize to c# |
static
|
string |
object |
ToFriendlyString() |
inserts a space before every capital letter in a string |
The To and As methods are used to work around boxing and conversion issues. Both methods will attempt to make the requested conversion. If To cannot
make the conversion it will return you a new T(), if As cannot make the conversion it will return a null if possible or a new T. Consider the following:
public interface IHaveAProperty
{
string AProperty { get; set; }
}
public class Foo : IHaveAProperty
{
public string AProperty { get; set; }
}
public class Bar : IHaveAProperty
{
public string AProperty { get; set; }
}
[TestMethod]
public void ToAndAs()
{
var foo = new Foo() {AProperty = "A"};
var bar = new Bar() {AProperty = "B" };
var toInterface = foo.To<IHaveAProperty>();
Assert.AreEqual(foo, toInterface);
var cantCast = bar.To<Foo>();
Assert.IsNotNull(bar);
Assert.AreNotEqual(bar, cantCast);
}
Foo is an IHaveAProperty so the call to To casts it as an IHaveAProperty and all is well. Bar is not a Foo, so the call to To<Foo> returns a new Foo because it cannot cast the bar. Primitives also require some special consideration:
decimal? number = null;
Assert.AreEqual(null, number.As<decimal?>());
Assert.AreEqual(0, number.As<decimal>());
Because you cannot set a decimal to a null value As<decimal> will return 0.
IoNic
A utility class for basic file operations.
Properties
|
Type |
Name |
Remarks |
|
bool |
IsWebHosted |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
string |
|
GetApplicationRootDirectory() |
|
static
|
string |
|
ResolveRelativePath(string path, string rootFolder) |
resolves a relative path to an actual path |
static
|
string |
|
GetTempFileNameAndPath(string fileExtensionNoDot) |
returns the path to the system temp directory with a file name generated from a guid |
static
|
string |
|
ExecuteAndReturnOutput(string path, string arguments) |
|
static
|
void |
|
ShellExecute(string path) |
spins off a process with Shell Execute, hiding all output |
static
|
string |
|
ReadFile(string fileName) |
reads the contents of a text file into a string |
static
|
void |
|
AppendToFile(string contents, string fileName) |
appends the string to an existing file, will create the file if it doesn't exist |
static
|
void |
|
WriteFile(string fileContents, string fileName) |
writes the string to a file, will delete the file if it already exists |
static
|
void |
|
MakeDir(string path) |
creats a directory, will not throw an expection if directory already exists |
static
|
void |
|
ClearDir(string path) |
deletes all files in a directory, works with read only files |
static
|
void |
|
KillDir(string path) |
deletes a directory, first recursively deleteing all files and folders, works with read only files |
static
|
void |
|
KillFile(string path) |
deletes a file, works with read only files |
NameValuePairExtensions
Utility extensions for working with INameValuePairs and NameValuePairs, includes dictionary emulation (for small collections only) and enum conversions. When debugging model binding I find myself using this
Request.Form.AsEnumerable();
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
void |
IList<INameValuePair> |
Add(string name, string value) |
|
static
|
void |
IList<INameValuePair> |
SetValue(string name, string value) |
|
static
|
void |
IList<INameValuePair> |
RemoveByName(string name) |
|
static
|
void |
IList<INameValuePair> |
RemoveByValue(string value) |
|
static
|
string |
IEnumerable<INameValuePair> |
GetValue(string name) |
|
static
|
bool |
IEnumerable<INameValuePair> |
ContainsValue(string value) |
|
static
|
bool |
IEnumerable<INameValuePair> |
ContainsName(string name) |
|
static
|
bool |
IEnumerable<INameValuePair> |
ContainsItem(string name, string value) |
|
static
|
IList<INameValuePair> |
IEnumerable<INameValuePair> |
Without(string name) |
|
static
|
IList<INameValuePair> |
Dictionary<TKey,TValue> |
ToINameValuePairList<TKey,TValue>() |
|
static
|
IList<INameValuePair> |
Type |
ToINameValuePairList() |
|
static
|
string |
|
GetEnumFriendlyName(Type type, object source) |
|
static
|
string |
|
GetEnumFriendlyName<T>(object source) |
|
static
|
IList<INameValuePair> |
Type |
ToINameValuePairListWithUnfriendlyNames() |
|
static
|
IEnumerable<INameValuePair> |
NameValueCollection |
AsEnumerable() |
|
Objectifyer
Serialization(Xml) and conversion helpers. If given a choice prefer Json (smaller payload and readable by javascirpt) or Protocol Buffers for the smallest possible payload.
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
TObject |
|
ShallowCopy<TObject>(TObject o) |
invokes MemberwiseClone creating a copy of the object, any nested objects or collections will still reference the origonal objects nested objects or colllections |
static
|
TObject |
|
DeepCopy<TObject>(TObject o) |
performs a binary serialization and deserialization of the object |
static
|
string |
|
Base64Encode(string data) |
|
static
|
string |
|
Base64Decode(string data) |
|
static
|
TObject |
|
DeepCopy<TObject>(TObject o) |
|
static
|
T |
|
FromXml<T>(string xml) |
|
static
|
T |
|
FromXml<T>(string xml, Type[] extraTypes) |
|
static
|
string |
|
ToDataContractXml<TObject>(TObject object) |
|
static
|
string |
|
ToDataContractXml<TObject>(TObject object, Type[] extraTypes) |
|
static
|
string |
|
ToXml<TObject>(TObject object) |
|
static
|
string |
|
ToXml<TObject>(TObject object, bool omitNamespaces) |
|
static
|
string |
|
ToXml<TObject>(TObject object, Type[] extraTypes, bool omitNamespaces) |
|
QueryableExtensions
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
IGridState |
IGridState |
Map(IGridState source) |
|
static
|
IQueryable<TQueryResult> |
IQueryable<TQueryResult> |
OrderByDescending<TQueryResult>(string sortExpression) |
|
static
|
IQueryable<TQueryResult> |
IQueryable<TQueryResult> |
OrderBy<TQueryResult>(string sortExpression) |
|
static
|
PagedResponse<TObject> |
IQueryable<TObject> |
ToPagedResponse<TObject>(IGridState paging) |
|
static
|
PagedResponse<TOut> |
IQueryable<TIn> |
ToPagedResponse<TIn,TOut>(IGridState paging, Expression<Func<TIn,TOut>> transform) |
|
static
|
PagedResponse<Grouping<TSource>> |
PagedResponse<TSource> |
GroupBy<TSource,TKey>(Func<TSource,TKey> keySelector) |
|
static
|
string |
T |
GetName<T>(Expression<Func<T,Object>> expression) |
|
static
|
Expression<T> |
Expression<T> |
Compose<T>(Expression<T> second, Func<Expression,Expression,Expression> merge) |
|
static
|
Expression<Func<T,Boolean>> |
Expression<Func<T,Boolean>> |
AndAlso<T>(Expression<Func<T,Boolean>> second) |
|
static
|
Expression<Func<T,Boolean>> |
Expression<Func<T,Boolean>> |
OrElse<T>(Expression<Func<T,Boolean>> second) |
|
static
|
Task<PagedResponse<TObject>> |
IQueryable<TObject> |
ToPagedResponseAsync<TObject>(IGridState paging) |
|
static
|
Task<PagedResponse<TOut>> |
IQueryable<TIn> |
ToPagedResponseAsync<TIn,TOut>(IGridState paging, Expression<Func<TIn,TOut>> transform) |
|
ReflectionExtensions
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
bool |
Type |
IsEnumerable() |
|
static
|
bool |
Type |
IsScalar() |
|
static
|
Type[] |
Assembly |
GetTypesSafetly() |
|
static
|
string |
Type |
GetTypeNameWithoutGenericArguments() |
|
static
|
string |
Type |
GetTypeFullNameWithoutGenericArguments() |
|
static
|
List<KeyValuePair<Type,String>> |
MethodInfo |
GetParameterDictionary() |
|
static
|
string |
MethodInfo |
GetParametersForCodeGeneration() |
|
static
|
string |
Type |
FixUpScalarTypeName() |
|
static
|
string |
Type |
FixUpTypeName() |
|
static
|
string |
MethodBase |
GetMethodName() |
|
static
|
bool |
Type |
DoesImplementInterfaceOf(Type interfaceType) |
|
static
|
bool |
Type |
IsGenericCollectionTypeOf(Type typeDefinition) |
|
Strings
Inheritance Hierarchy:
ValueType
Assorted constants and strings.
ValidationExtensions
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
bool |
object |
Validate() |
|
VoodooGlobalConfiguration
Properties
|
Type |
Name |
Remarks |
static
|
ErrorDetailLoggingMethodology |
ErrorDetailLoggingMethodology |
|
static
|
int |
LogMaximumNumberOfItemsInCollection |
number of items listed from collections in the ObjectStringificationQuery or the ToDebugString method of ConversionExtensions |
static
|
string |
LogFilePath |
Log file path if you are using the FallbackLogger defaults to site root for web applications and c:\Logs otherwise |
static
|
string |
ApplicationName |
If file system logging fails this will be the application name in the event log |
static
|
bool |
RemoveExceptionFromResponseAfterLogging |
Exceptions in
Command or
Query
failures are added to the Response. If you plan to serialize responses as xml or
JSON you should set this to true.
|
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
void |
|
RegisterLogger(ILogger logger) |
replaces the default FallbackLogger logging implementation with another |
static
|
void |
|
RegisterValidator(IValidator validator) |
replaces the default validation DataAnnotationsValidatorWithGenericMessage implementation with another |
static
|
void |
|
RegisterExceptionMapping<T>(ExceptionTranslation mapper) |
By default the Message of an exception is copied the response and IsOk is set to false |
Voodoo.Helpers
CollectionChangeSet
Instantiate this class with two sets of ids - a source set and a changed set. The class will return the ids that have been added or removed from the source set.
Properties
|
Type |
Name |
Remarks |
|
Int32[] |
Added |
|
|
Int32[] |
Deleted |
|
|
Int32[] |
Edited |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
AreDifferent() |
|
CollectionReconciler<TExisting,TModified,TKey>
Used to compare two collections of objects and segregate the changes.
Properties
|
Type |
Name |
Remarks |
|
EditedItem [] |
Edited |
neither added nor deleted |
|
TExisting[] |
Deleted |
in the existing list but not modified |
|
TModified[] |
Added |
in the modified list but not existing |
|
TKey[] |
AddedKeys |
keys for added items |
|
TKey[] |
DeletedKeys |
keys for deleted items |
|
TKey[] |
EditedKeys |
keys for items neither added or deleted |
EditedItem<TExisting,TModified,TKey>
Properties
|
Type |
Name |
Remarks |
|
TExisting |
Existing |
|
|
TModified |
Modified |
|
|
TKey |
Key |
|
ResponseExceptionDecorator
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Decorate() |
|
Voodoo.Infrastructure
ExceptionTranslater
Interfaces:
IDictionary<Type,
ExceptionTranslation>, ICollection<KeyValuePair<Type,ExceptionTranslation>>, IEnumerable<KeyValuePair<Type,ExceptionTranslation>>, IEnumerable, IDictionary, ICollection, IReadOnlyDictionary<Type,
ExceptionTranslation>, IReadOnlyCollection<KeyValuePair<Type,ExceptionTranslation>>, ISerializable, IDeserializationCallback
Inheritance Hierarchy:
Dictionary<Type,
ExceptionTranslation>
Used to alter the behavior or obfuscate exceptions caught during the execution of a Command or
Query
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
Contains<T>() |
|
|
bool |
|
DecorateResponseWithException<T>(Exception ex, IResponse response) |
|
|
bool |
|
DecorateResponseWithException(Exception ex, IResponse response) |
|
ExceptionTranslation
Provides special handling for certain exception types. Such as DbEntityValidationExceptionTranlator
this to copy the EntityValidationErrors into the details of the Response.
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
DecorateResponse(Exception exception, IResponse response) |
|
IStorageProvider
Properties
|
Type |
Name |
Remarks |
|
bool |
Exists |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Flush() |
|
|
bool |
|
Contains(string key) |
|
|
T |
|
Get<T>(string key) |
|
|
void |
|
Remove(string key) |
|
|
void |
|
Put<T>(string key, T value, int? durationInMinutes) |
|
LogicException
Interfaces:
ISerializable, _Exception
Inheritance Hierarchy:
Exception
During the validation phase of a Command or
Query if validation fails a LogicException
is thrown.
Properties
ReflectionTypeLoaderExceptionTranslation
Inheritance Hierarchy:
ExceptionTranslation
RestAttribute
Interfaces:
_Attribute
Inheritance Hierarchy:
Attribute
Properties
|
Type |
Name |
Remarks |
|
String[] |
Roles |
|
|
bool |
AllowAnonymous |
|
|
Verb |
Verb |
|
|
string |
Resource |
|
Verb
Interfaces:
IComparable, IFormattable, IConvertible
Inheritance Hierarchy:
Enum
ValueType
Voodoo.Infrastructure.Notations
FullDotNetOnly
Interfaces:
_Attribute
Inheritance Hierarchy:
Attribute
SecretAttribute
Interfaces:
_Attribute
Inheritance Hierarchy:
Attribute
ThirdPartyAttribute
Interfaces:
_Attribute
Inheritance Hierarchy:
Attribute
used to filter thrird party code from documentation
UnfinishedAttribute
Interfaces:
_Attribute
Inheritance Hierarchy:
Attribute
used to filter unfinished code from documentation
Voodoo.Linq
LinqHelper
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
IQueryable<T> |
IQueryable<T> |
OrderByDynamic<T>(string ordering) |
|
static
|
IQueryable |
IQueryable |
Take(int count) |
|
static
|
IQueryable |
IQueryable |
Skip(int count) |
|
static
|
bool |
IQueryable |
Any() |
|
static
|
int |
IQueryable |
Count() |
|
Voodoo.Logging
DebugLogger
Interfaces:
ILogger
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Log(string message) |
|
|
void |
|
Log(Exception ex) |
|
FallbackLogger
Interfaces:
ILogger
This is probably not the logger you're looking for. You can implment the ILogger interface and create an adapter for
Elmah, NLog
or whatever logging framework you use.
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Log(Exception ex) |
|
|
void |
|
Log(string log) |
|
|
void |
|
Log(string log, string logFilePath) |
|
IDetailedLogger
ILogger
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Log(string message) |
|
|
void |
|
Log(Exception ex) |
|
LogManager
Properties
|
Type |
Name |
Remarks |
static
|
ILogger |
Logger |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
void |
|
Log(string message) |
|
static
|
void |
|
Log(Exception ex) |
|
Voodoo.Messages
DefaultRequest
Properties
|
Type |
Name |
Remarks |
|
int? |
Id |
|
|
string |
SearchText |
|
A Command or Query
takes a request (which can be any object) and returns an IResponse. Several default IResponse
implementations Response, Response<T>, ListResponse<T> are available.
EmptyRequest
Grouping<T>
Properties
|
Type |
Name |
Remarks |
|
string |
Name |
|
|
Guid |
Id |
|
|
List<T> |
Data |
|
IdRequest
Properties
INameValuePair
Properties
|
Type |
Name |
Remarks |
|
string |
Name |
|
|
string |
Value |
|
|
string |
Key |
|
IResponse
Properties
|
Type |
Name |
Remarks |
|
bool |
IsOk |
|
|
string |
Message |
|
|
Exception |
Exception |
|
|
IList<INameValuePair> |
Details |
|
|
bool |
HasLogicException |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
SetExceptions(Exception ex) |
|
|
void |
|
AppendResponse(IResponse response) |
|
ListResponse<T>
Interfaces:
IResponse
Inheritance Hierarchy:
Response
Properties
|
Type |
Name |
Remarks |
|
List<T> |
Data |
|
NameValuePair
Interfaces:
INameValuePair
Properties
|
Type |
Name |
Remarks |
|
string |
Name |
|
|
string |
Value |
|
|
string |
Key |
|
NewItemResponse
Interfaces:
IResponse
Inheritance Hierarchy:
Response
Properties
|
Type |
Name |
Remarks |
|
int |
NewItemId |
|
OptionalIdRequest
Properties
|
Type |
Name |
Remarks |
|
int? |
Id |
|
PagedRequest
Interfaces:
IGridState
Inheritance Hierarchy:
Request
Properties
|
Type |
Name |
Remarks |
|
string |
DefaultSortMember |
|
|
string |
SortDirection |
|
|
bool |
ResetPaging |
|
|
int |
PageNumber |
|
|
int |
PageSize |
|
|
string |
SortMember |
|
|
int |
TotalRecords |
|
|
int |
TotalPages |
|
PagedResponse<TQueryResult>
Interfaces:
IResponse
Inheritance Hierarchy:
ListResponse<TQueryResult>
Response
Properties
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
From<TIn,TOut>(PagedResponse<TIn> source, Func<TIn,TOut> transform) |
|
Request
Response
Interfaces:
IResponse
Default implementation of the IResponse
Properties
|
Type |
Name |
Remarks |
|
int |
NumberOfRowsEffected |
|
|
bool |
IsOk |
|
|
bool |
HasLogicException |
|
|
string |
Message |
|
|
IList<INameValuePair> |
Details |
|
|
Exception |
Exception |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
SetExceptions(Exception ex) |
|
|
void |
|
AppendResponse(IResponse response) |
|
Response<T>
Interfaces:
IResponse
Inheritance Hierarchy:
Response
Properties
TextResponse
Interfaces:
IResponse
Inheritance Hierarchy:
Response
Properties
|
Type |
Name |
Remarks |
|
string |
Text |
|
Voodoo.Messages.Paging
GridConstants
Inheritance Hierarchy:
ValueType
GridState
Interfaces:
IGridState
Properties
|
Type |
Name |
Remarks |
|
int |
TotalPages |
|
|
int |
PageNumber |
|
|
int |
PageSize |
|
|
int |
TotalRecords |
|
|
string |
SortMember |
|
|
string |
SortDirection |
|
|
string |
DefaultSortMember |
|
|
bool |
ResetPaging |
|
IGridState
Properties
|
Type |
Name |
Remarks |
|
int |
PageNumber |
|
|
int |
PageSize |
|
|
int |
TotalRecords |
|
|
int |
TotalPages |
|
|
string |
SortMember |
|
|
string |
SortDirection |
|
|
string |
DefaultSortMember |
|
|
bool |
ResetPaging |
|
Voodoo.Operations
Operations provide a loose Command Query Responsibility Segragation structure.
Each operation takes a request (any arbitrary object) and return an IResponse.
This structure is very testable.
I also like to pretend that I'm doing Aspect Oriented Programming
by handling validation, logging and error handling in the base Executor class. The only functional difference between a Command
and Query is that commands are wrapped in a transaction scope which does not get committed if an exception occurs. Consider a simple query:
public class PersonQuery: Query<PersonRequest,ListResponse<Person>>
{
public PersonQuery(PersonRequest request) : base(request)
{
}
protected override ListResponse<Person> ProcessRequest()
{
using (var context = getContext())
{
response.Data = context.People
.Where (c=>c.FirstName.StartsWith(request.SearchString) ||
c=>c.LastName.StartsWith(request.SearchString)
.ToList();
}
return response;
}
}
Which you would consume with
var request = new PersonRequest{SearchString="j"};
var response = new PersonQuery(request).Execute();
There is no validation because the base Executor class invokes
DataAnnotations Validation including
IValidatableObject
to handle thing more complex than simple property
level validation. Though you can override protected virtual void Validate()
to add any custom validation or make a project specific query to use an entirely different validation mechanism.
There is no try in the query because the base Executor wraps the ProcessRequest() method in a try catch block.
There is no logging because the protected virtual void CustomErrorBehavior(Exception ex)
logs all exceptions to the registered ILogger.
A typical scenerio would be to execute your operations, check to see if
response.IsOk == true if it is go about your business, if it isn't display
the response.Message to your user.
Command<TRequest,TResponse>
Inheritance Hierarchy:
Executor<TRequest,TResponse>
Methods
|
Return Type |
Source |
Method |
Remarks |
|
TResponse |
|
Execute() |
|
ExceptionHelper
Executor<TRequest,TResponse>
Methods
|
Return Type |
Source |
Method |
Remarks |
|
TResponse |
|
Execute() |
|
ObjectEmissionQuery
Inheritance Hierarchy:
Query<Object,
TextResponse>
Executor<Object,
TextResponse>
ObjectStringificationQuery
Inheritance Hierarchy:
Query<Object,
TextResponse>
Executor<Object,
TextResponse>
Query<TRequest,TResponse>
Inheritance Hierarchy:
Executor<TRequest,TResponse>
Voodoo.Operations.Async
Async/Await ready operations. QueryAsync and ExecutorAsync require .net 4.5 ,CommandAsync requires .net 4.5.1 because of the TransactionScopeAsyncFlowOption constructor introduced in .net 4.5.1.
CommandAsync<TRequest,TResponse>
Inheritance Hierarchy:
ExecutorAsync<TRequest,TResponse>
Methods
|
Return Type |
Source |
Method |
Remarks |
|
Task<TResponse> |
|
ExecuteAsync() |
|
ExecutorAsync<TRequest,TResponse>
Methods
|
Return Type |
Source |
Method |
Remarks |
|
Task<TResponse> |
|
ExecuteAsync() |
|
QueryAsync<TRequest,TResponse>
Inheritance Hierarchy:
ExecutorAsync<TRequest,TResponse>
Voodoo.PCL.Validation.Infrastructure
EmptyValidator
Interfaces:
IValidator
Properties
|
Type |
Name |
Remarks |
|
bool |
IsValid |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Validate(object request) |
|
Voodoo.Validation
CollectionMustHaveAtLeastOneItemAttribute
Interfaces:
_Attribute
Inheritance Hierarchy:
SafeValidationAttribute
ValidationAttribute
Attribute
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
IsValueValid(object value) |
|
DataAnnotationsValidator
Properties
|
Type |
Name |
Remarks |
|
bool |
IsValid |
|
|
List<ValidationResult> |
ValidationResults |
|
|
List<INameValuePair> |
ValidationResultsAsNameValuePair |
|
EnumIsRequiredAttribute
Interfaces:
_Attribute
Inheritance Hierarchy:
SafeValidationAttribute
ValidationAttribute
Attribute
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
IsValueValid(object value) |
|
GreaterThanZeroIntegerIsRequired
Interfaces:
_Attribute
Inheritance Hierarchy:
SafeValidationAttribute
ValidationAttribute
Attribute
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
IsValueValid(object value) |
|
RequiredDateTimeAttribute
Interfaces:
_Attribute
Inheritance Hierarchy:
SafeValidationAttribute
ValidationAttribute
Attribute
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
IsValueValid(object value) |
|
RequiredGuid
Interfaces:
_Attribute
Inheritance Hierarchy:
SafeValidationAttribute
ValidationAttribute
Attribute
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
IsValueValid(object value) |
|
RequiredInt
Interfaces:
_Attribute
Inheritance Hierarchy:
SafeValidationAttribute
ValidationAttribute
Attribute
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
IsValueValid(object value) |
|
RequiredNonZeroInt
Interfaces:
_Attribute
Inheritance Hierarchy:
SafeValidationAttribute
ValidationAttribute
Attribute
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
IsValueValid(object value) |
|
SafeValidationAttribute
Interfaces:
_Attribute
Inheritance Hierarchy:
ValidationAttribute
Attribute
Methods
|
Return Type |
Source |
Method |
Remarks |
|
bool |
|
IsValid(object value) |
|
|
bool |
|
IsValueValid(object value) |
|
Voodoo.Validation.Infrastructure
DataAnnotationsValidatorWithFirstErrorAsMessage
Interfaces:
IValidator
Properties
|
Type |
Name |
Remarks |
|
bool |
IsValid |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Validate(object request) |
|
DataAnnotationsValidatorWithGenericMessage
Interfaces:
IValidator
This is the default IValidator used during validation of operations.
Properties
|
Type |
Name |
Remarks |
|
bool |
IsValid |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Validate(object request) |
|
IValidator
Properties
|
Type |
Name |
Remarks |
|
bool |
IsValid |
|
Methods
|
Return Type |
Source |
Method |
Remarks |
|
void |
|
Validate(object request) |
|
ValidationManager
Properties
Methods
|
Return Type |
Source |
Method |
Remarks |
static
|
IValidator |
|
GetDefaultValidatitor() |
|
static
|
void |
|
Validate(object object) |
|
Change Log
1.0.21
Added Extensibility point for validation
Tweaks to paging
1.0.23
.net 4.5 added ExecutorAsync and QueryAsync
.net 4.5.1 added CommandAsync (async transaction options not available in .net 4.5)
1.0.26
tweaks to paging, paged request
1.0.28
Rest attribute, new reflection extensions
1.0.29
collection reconciliation, new reflection extensions
1.0.30
ToPagedRequestAsync for .net 4.5 or higher
1.0.31
PagedResponse post materialization transformation
1.0.33
logging enhancements, ToCode extension method
2.0.3
CoreClr Support
Logger generates integration test to reproduce exceptions
breaking changes
the following items flagged with the Obsolete Attribute have been removed
IKeyValuePair ("Use INameValuePair instead")
KeyValuePair ("Name causes cognitive dissonance, use NameValuePair instead.")
Voodoo.Validation.Infrastructure.Messages ("Use Voodoo.Strings.Validation instead")
Voodoo.Constants ("Use Voodoo.Strings instead")
Voodoo.Constants.SortDirection ("Use Voodoo.Strings.SortDirection instead")
QueryableExtensions.PagedResponse ("Use ToPagedResponse")
Contributing
Take care to maintain the existing coding style. Add Microsoft.VisualStudio.TestTools unit tests for any new or changed functionality. Do not add dependancies outside of the .Net Framework.
After you have verified your code, send a pull request to the Voodoo.Patterns develop branch. After you send a pull request, you will hear back from me shortly after I review your code.
Extending
If you find that you need a feature that Voodoo.Patterns does not currently support, either let me know via the
Github issue tracker, or fork the project and and easily extend Voodoo.Patterns!
Copyright
Copyright © 2010 Shawn Doucet
Documentation build with api-documentor and Document-Bootstrap