Skip to content

Instantly share code, notes, and snippets.

View shawnmclean's full-sized avatar
🐭
:)

Shawn Mclean shawnmclean

🐭
:)
View GitHub Profile
@shawnmclean
shawnmclean / Startup.Auth.cs
Last active August 29, 2015 14:05
Manually setting Data Protection Provider
userManager.UserTokenProvider = new EmailTokenProvider<IdentityUser, Guid>();
@shawnmclean
shawnmclean / HelpPageConfig.cs
Created August 31, 2014 18:19
HelpPageConfig modified for integration tests.
public static class HelpPageConfig
{
public static void Register(HttpConfiguration config)
{
var path = HostingEnvironment.MapPath("~/App_Data/XmlDocument.xml");
if (!string.IsNullOrWhiteSpace(path))
{
config.SetDocumentationProvider(
new XmlDocumentationProvider(path));
}
@shawnmclean
shawnmclean / IUnitOfWork.cs
Created July 4, 2013 16:00
Interface for Unit Of Work
/// <summary>
/// Interface for the unit of work pattern, inherits from IDisposable to dispose of the DbContext
/// </summary>
public interface IUnitOfWork: IDisposable
{
/// <summary>
/// Saves the changes of the DbContext wrapped by the UoW
/// </summary>
/// <returns></returns>
int SaveChanges();
@shawnmclean
shawnmclean / EntityRepository.cs
Created July 3, 2013 22:37
Generic Entity Framework Repository concrete class
public class EntityRepository<T> : IRepository<T>
where T : class
{
protected DbContext Context = null;
public EntityRepository(DbContext context)
{
if (context == null) throw new ArgumentNullException("context");
Context = context;
@shawnmclean
shawnmclean / IRepository.cs
Created July 3, 2013 22:32
Generic Repository Interface
public interface IRepository<T> where T : class
{
/// <summary>
/// Gets all objects from database
/// </summary>
IQueryable<T> All(params string[] includes);
/// <summary>
/// Gets objects from database by filter.
/// </summary>
@shawnmclean
shawnmclean / CameraView.cs
Created December 11, 2012 14:37
Code behind for full screen camera view
public partial class CameraView : PhoneApplicationPage
{
private PhotoCamera cam;
public CameraView()
{
InitializeComponent();
activateCamera();
}
private void activateCamera()
@shawnmclean
shawnmclean / CameraView.xaml
Created December 10, 2012 16:52
Xaml for full screen camera view
<Grid x:Name="LayoutRoot" VerticalAlignment="Stretch">
<Canvas x:Name="viewfinderCanvas">
<Canvas.Background>
<VideoBrush x:Name="viewfinderBrush">
<VideoBrush.RelativeTransform>
<CompositeTransform x:Name="previewTransform" CenterX=".5" CenterY=".5" />
</VideoBrush.RelativeTransform>
</VideoBrush>
</Canvas.Background>
</Canvas>
@shawnmclean
shawnmclean / IRepository.cs
Created August 24, 2012 04:09
Example of a generic repository interface
public interface IRepository<T> where T : class
{
/// <summary>
/// Gets all objects from database
/// </summary>
IQueryable<T> All();
/// <summary>
/// Gets objects from database by filter.
/// </summary>
@shawnmclean
shawnmclean / UserController.cs
Created April 29, 2012 18:59
controller utilizing HttpHeader
[HttpHeader("Access-Control-Allow-Origin", "*")]
public class UserController : ApiController
{
public IEnumerable<string> Get()
{
return new List<string> { "User1", "User2" };
}
}
@shawnmclean
shawnmclean / HttpHeaderAttribute.cs
Created April 29, 2012 18:55
Setting Http Headers via attributes for ASP.NET Webapi
public class HttpHeaderAttribute : ActionFilterAttribute
{
/// <summary>
/// The name of the Http Header
/// </summary>
public string Name { get; set; }
/// <summary>
/// The value of the Http Header
/// </summary>