Skip to content

Instantly share code, notes, and snippets.

_AuthenticationFailure_
@AlexArchive
AlexArchive / StartupController.cs
Created August 5, 2014 08:26
Limit your Windows Forms application to a single instance (run once).
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace Screenshot
{
public static class StartupController
{
using GoBlog.AutoMapper;
using GoBlog.Controllers;
using GoBlog.Data;
using GoBlog.Data.Entities;
using GoBlog.Models;
using GoBlog.Paging;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.ObjectModel;
@AlexArchive
AlexArchive / AccountController.cs
Last active August 29, 2015 14:04
Minimal Identity Authenticator
public class AccountController : Controller
{
private readonly Authenticator authenticator = new Authenticator();
public ActionResult Login()
{
return View();
}
[HttpPost, ValidateAntiForgeryToken]
Public Class GrandExchange
Public Structure GrandExchangeItem
#Region "Public Read-Only Properties"
Public ReadOnly Property ItemName As String
Get
Return privItemName
End Get
End Property
Public ReadOnly Property ItemPrice As String
Get
public class Counter
{
public static int CountLines(string path)
{
return
File.ReadLines(path)
.Count(Predicate);
}
private static bool Predicate(string line)
using GoBlog.AutoMapper;
using GoBlog.Controllers;
using GoBlog.Data;
using GoBlog.Data.Entities;
using GoBlog.Models;
using GoBlog.Paging;
using Moq;
using NUnit.Framework;
using System;
using System.Collections.ObjectModel;
.centered-container {
width: 800px;
height: 270px;
top: 50%;
left: 50%;
margin-left: -400px;
margin-top: -135px;
position: fixed;
}
public static void SetFakeControllerContext(this Controller controller, NameValueCollection querystring = null)
{
var context = new Mock<HttpContextBase>();
context.Setup(c => c.Request.QueryString).Returns(querystring ?? new NameValueCollection());
controller.ControllerContext = new ControllerContext(context.Object, new RouteData(),
new Mock<ControllerBase>().Object);
public static class Serializer
{
public static string Serialize(object graph)
{
var document = new XDocument();
var type = graph.GetType();
document.Add(new XElement(type.Name));
var properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.GetProperty);
foreach (var property in properties)