This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mapper.CreateMap<SourceRequest, DestRequest>() | |
.ForMember(dest => dest.AppId, opt => opt.ResolveUsing<ApiKeyToAppId>() | |
.FromMember(src => src.ApiToken) | |
.FromMember(src => src.ConsumerId)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class AssertionExtensions | |
{ | |
public static void should_be_equal_to<T>(this T actual, T expected) | |
{ | |
Assert.That(actual, Is.EqualTo(expected)); | |
} | |
public static void should_be_equal_to(this double actual, double expected, int precision) | |
{ | |
Assert.That(Math.Round(actual, precision), Is.EqualTo(expected)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void RunSnippet() | |
{ | |
Mapper.CreateMap<FirstClass,SecondClass>(); | |
Mapper.CreateMap<FirstEnum,SecondEnum>(); | |
var firstClass = new FirstClass(); | |
firstClass.EnumValue = FirstEnum.NamedEnum; | |
Mapper.Map<FirstClass,SecondClass>(firstClass); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public sealed class Mediator | |
{ | |
private static readonly Mediator _instance = new Mediator(); | |
private Dictionary<MediatedEvent, List<Action<EventArgs>>> _handlers; | |
/// <summary> | |
/// Thread-safe synchronization lock. | |
/// </summary> | |
private volatile Object _syncLock = new Object(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// POST: /Package/Edit/5 | |
[AcceptVerbs(HttpVerbs.Post), UnitOfWork] | |
public ActionResult Edit(int id, Model.Package vm) { | |
try { | |
var package = _packageRepository.GetById(id); | |
package = Mapper.Map<Model.Package, Persistence.Package>(vm, package); | |
return RedirectToAction("Index"); | |
} catch (Exception up) { | |
throw up; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var query = context.Songs | |
.WhereIf(request.Artist.IsNotNull(), b => b.Artist == request.Artist) | |
.WhereIf(request.Genre.IsNotNull(), b => b.Genre == request.Genre) | |
.WhereIf(request.Title.IsNotNull(), b => b.Title == request.Title) | |
.WhereIf(request.Label.IsNotNull(), b => b.Label == request.Label); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class QueryableExtensions { | |
public static IQueryable<TSource> WhereIf<TSource>( | |
this IQueryable<TSource> source, bool condition, | |
Expression<Func<TSource, bool>> predicate) { | |
if (condition) | |
return source.Where(predicate); | |
else | |
return source; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ApiValidationAttribute21] | |
public bool Authenticate(ExternalDataContractRequestBase request) | |
{ | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Text; | |
namespace System.Web.Mvc { | |
public static class FlashHelpers { | |
public static void FlashInfo(this Controller controller,string message) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Core.Impersonation | |
{ | |
public class UserCredentials | |
{ | |
private readonly string _domain; | |
private readonly string _password; | |
private readonly string _username; | |
public UserCredentials(string domain, string username, string password) | |
{ |
OlderNewer