This file contains hidden or 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
// class like this | |
public class Something | |
{ | |
public string Name{get;set;} | |
public string Zip {get;set;} | |
public string Street {get;set;} | |
} | |
// maps to json like this |
This file contains hidden or 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
// this... | |
<a href="@Model.GithubAddHookUrl" target="_blank" class="btn small">Go to Github</a> | |
// ...or this ... | |
@Html.ButtonLink(Model.GithubAddHookUrl, "Go to Github") | |
// ...or perhaps this? (via extension method) | |
@Model.GithubAddHookUrl.ButtonLink("Go to Github") |
This file contains hidden or 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 interface IFoo<T> | |
{} | |
public class SimpleFoo<T>: IFoo<T> | |
{} | |
public class StructOnlyFoo<T>: IFoo<T> where T : struct | |
{} | |
public class FooWithBar<T>:IFoo<T> |
This file contains hidden or 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 = from foo in session.Query<Foo>() | |
from bar in foo.Something.Bars | |
select anythingReally; | |
// LINQ provider throws exception complaining | |
// about second 'from', but in reality it complains about the 'Something' between foo and Bars | |
var result = query.ToList(); |
This file contains hidden or 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 fooMock = new Mock<IFoo>().Object; | |
fooMock.Bar = "bar"; | |
Debug.Assert(fooMock.Bar == "bar"); |
This file contains hidden or 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
// full doco for fluent API here: http://docs.castleproject.org/Windsor.Registering-components-by-conventions.ashx | |
public void Install(IWindsorContainer container, IConfigurationStore store) | |
{ | |
container.Register( | |
Component.For<IPocessor>() | |
.ImplementedBy<SomeProcessor>() | |
.Named("processor") // do you really request this by name? If no you don't need to set the name | |
.ServiceOverrides( | |
ServiceOverride.ForKey("repositoryB") | |
.Eq("CastleInstallersInv.Repository.RepositoryB"))); |
This file contains hidden or 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
/* this gets executed */ | |
SELECT this_.Id as Id0_0_, | |
this_.Author as Author0_0_, | |
this_.Title as Title0_0_, | |
this_1_.Comment as Comment1_0_, | |
this_1_.LanguageId as LanguageId1_0_ | |
FROM [Blog] this_ | |
inner join Comment this_1_ | |
on this_.Id = this_1_.Blog_id | |
WHERE (this_.LanguageId = 2 /* @p0 */) |
This file contains hidden or 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
[Test] | |
public void Implicitly_graph_scoped_component_instances_are_reused() | |
{ | |
Container.Register( | |
Component.For<A>().LifeStyle.ScopedPer<CBA>(), | |
Component.For<B>().LifeStyle.Transient, | |
Component.For<CBA>().LifeStyle.Transient); | |
var cba = Container.Resolve<CBA>(); | |
Assert.AreSame(cba.A, cba.B.A); |
This file contains hidden or 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 TransientScopedInWebRequestLifestyleModule : IHttpModule | |
{ | |
// Fields | |
private const string key = "trolls_and_goblins"; | |
public static IKernel kernel; | |
// Methods | |
public void Dispose() | |
{ |
This file contains hidden or 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
//in a per-web-request class | |
IKernel kernel; | |
List<object> tracked; | |
public object GetMeDaObject() | |
{ | |
var obj = kernel.Resolve<DaObject>(); | |
if(kernel.ReleasePolicy.HasTrack(obj)) | |
{ |