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 addresses = new[] {new PostalAddress(), new PostalAddress()}; | |
var spec = new PersistenceSpecification<Contact>(session); | |
spec.CheckProperty(p => p.Name, "something") | |
.CheckProperty(p => p.GivenName, "something else") | |
.CheckInverseList(l => l.Addresses, addresses) | |
etc etc | |
.VerifyTheMappings(); |
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 class PostalAddressMap | |
: ClassMap<PostalAddress> | |
{ | |
public PostalAddressMap() | |
{ | |
Table("tblPostalAddresses"); | |
Id(x => x.Id); | |
Map(x => x.Address); | |
Map(x => x.AddressType); | |
Map(x => x.Owner); |
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 class MyViewEngine : RazorViewEngine | |
{ | |
/// <summary> | |
/// default ~/views | |
/// </summary> | |
/// <param name="startingPath"></param> | |
public MyViewEngine(string startingPath) | |
{ | |
var formats = new[] | |
{ |
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 class Impersonation : IDisposable | |
{ | |
public Impersonation(string username, string password, string domain) | |
{ | |
try | |
{ | |
IntPtr tokenHandle; // = IntPtr.Zero; | |
Int32 ret; | |
if ( |
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 (var imageFactory = new ImageFactory()) | |
{ | |
var layer = new ResizeLayer(new Size(800, 500), null, ResizeMode.Stretch); | |
imageFactory.Load(ms) | |
.Resize(layer) | |
.Format(ImageFormat.Jpeg) | |
.Quality(90) | |
.Save(path); | |
} |
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 class FubuRegistry : Registry | |
{ | |
public FubuRegistry() | |
{ | |
var htmlConventionLibrary | |
= new HtmlConventionLibrary(); | |
var conventions | |
= new OverrideHtmlConventions(); | |
htmlConventionLibrary.Import(conventions.Library); | |
For<HtmlConventionLibrary>().Use(htmlConventionLibrary); |
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 HtmlTag LabelWithInput<T>(this HtmlHelper<T> helper, Expression<Func<T, object>> expression) where T : class | |
{ | |
var generator = GetGenerator<T>(); | |
var label = generator.LabelFor(expression, model: helper.ViewData.Model); | |
var input = generator.InputFor(expression, model: helper.ViewData.Model); | |
var div = new DivTag(); | |
div.AddClass("form-group"); | |
div.Append(label); | |
div.Append(input); |
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
<rule name="Redirect to HTTPS" stopProcessing="true"> | |
<match url="(.*)" /> | |
<conditions logicalGrouping="MatchAll" trackAllCaptures="false"> | |
<add input="{HTTPS}" pattern="^OFF$" /> | |
</conditions> | |
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" /> | |
</rule> | |
courtesy of Sides of March | |
http://www.sidesofmarch.com/index.php/archive/2014/09/02/forcing-iis-to-rewrite-all-requests-to-https/ |
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 object GetService(Type serviceType) | |
{ | |
try | |
{ | |
return container.Resolve(serviceType); | |
} | |
catch | |
{ | |
return null; | |
} |
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 MvcHtmlString ActionButton<T>(this HtmlHelper helper, Expression<Action<T>> action, string text) where T : Controller | |
{ | |
return ActionButton(helper, action, text, null); | |
} | |
public static MvcHtmlString ActionButton<T>(this HtmlHelper helper, Expression<Action<T>> action, string text, object htmlAttributes) where T : Controller | |
{ | |
var routing = ExpressionHelper.GetRouteValuesFromExpression(action); | |
var vpd = helper.RouteCollection.GetVirtualPath(helper.ViewContext.RequestContext, routing); |
OlderNewer