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
| void Main() | |
| { | |
| GetPersisterFor(new Foo()); | |
| } | |
| public interface IPersister { } | |
| public interface IEntity { } | |
| public class Foo : IEntity { } | |
| public class Bar : IEntity { } |
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
| void Main() | |
| { | |
| using(var kernel = new StandardKernel()) | |
| { | |
| kernel | |
| .Bind<IDocumentService>() | |
| .ToMethod(x => CoDocumentService.Create(x.Kernel.Get<IMessage>(),x.Kernel.Get<IClientChannel>("IClientChannel"))) | |
| .InTransientScope(); | |
| kernel |
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
| void Main() | |
| { | |
| // FindBaseClassWith | |
| Assert.That(typeof(DeriviedLeft).FindBaseClassWith(typeof(DeriviedLeft)), Is.EqualTo(typeof(DeriviedLeft))); | |
| Assert.That(typeof(DeriviedLeft).FindBaseClassWith(typeof(SubDeriviedLeft)), Is.EqualTo(typeof(DeriviedLeft))); | |
| Assert.That(typeof(DeriviedLeft).FindBaseClassWith(typeof(DeriviedRight)), Is.EqualTo(typeof(object))); | |
| Assert.That(typeof(DeriviedLeft).FindBaseClassWith(typeof(object)), Is.EqualTo(typeof(object))); | |
| Assert.That(typeof(DeriviedLeft).FindBaseClassWith(typeof(Another)), Is.EqualTo(typeof(object))); | |
| Assert.That(typeof(DeriviedRight).FindBaseClassWith(typeof(DeriviedRight)), Is.EqualTo(typeof(DeriviedRight))); | |
| Assert.That(typeof(DeriviedRight).FindBaseClassWith(typeof(DeriviedLeft)), Is.EqualTo(typeof(object))); |
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
| void Main() | |
| { | |
| TraceDecorator.Aspect(() => StaticLogic.SuccessfulCall()); | |
| TraceDecorator.Aspect(() => StaticLogic.ExceptionCall()); | |
| TraceDecorator.Aspect(() => StaticLogic.SuccessfulCallWithReturn(42)).Dump(); | |
| TraceDecorator.Aspect(() => StaticLogic.ExceptionCallWithReturn(42)).Dump(); | |
| } | |
| public static class TraceDecorator | |
| { |
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
| using System; | |
| using System.Reflection; | |
| using PostSharp.Aspects; | |
| using PostSharp.Extensibility; | |
| using NUnit.Framework; | |
| namespace Examples | |
| { | |
| public interface IServiceWithDependency | |
| { |
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
| void Main() | |
| { | |
| JsonConvert.DeserializeObject<Root>(testJson).Dump(); | |
| } | |
| readonly string testJson = | |
| "{\"Profile\": [{" + | |
| " \"Name\":\"Joe\"," + | |
| " \"Last\":\"Doe\"," + | |
| " \"Client\":" + |
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
| SQLiteConnection connection = boundSession.GetConnection(); | |
| using (var cmd = new SQLiteCommand("PRAGMA foreign_keys = OFF", connection)) | |
| { | |
| cmd.ExecuteNonQuery(); | |
| } | |
| var sqlLiteUnitTest = new SqlLiteDbUnitTest(connection); | |
| sqlLiteUnitTest.ReadXmlSchema(xsdFile); |
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
| [Serializable] | |
| public class TracingAspectAttribute : OnMethodBoundaryAspect | |
| { | |
| // Question #1: Is there any better way to design aspect | |
| // and to inject dependency into it? | |
| public Type AbstractFactoryType { get; set; } | |
| private ILogger Logger { get; set; } | |
| // Compile time validation. | |
| // Question #2: Better approach to ensure during post-compile time |
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
| void Main() | |
| { | |
| // 4 from your Compositon Root ... | |
| using(var kernel = InitializeKernel()) | |
| { | |
| // 4.1 resolve delivery services by names | |
| var upsWorldShip = kernel.Get<IShippingCompanyService>("ShippingUpsWorldShip"); | |
| var fedExDesktopApps = kernel.Get<IShippingCompanyService>("ShippingFedExDesktopApps"); | |
| // 4.2 delivery processing |
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
| void Main() | |
| { | |
| // create kernel with conventions | |
| using(var kernel = InitializeKernel()) | |
| { | |
| // ninject.extensions.conventions would not automaticaly select wich of | |
| // two implementations of IDependency to resolve | |
| var dependency = kernel.Get<IDependency>(); | |
| Assert.That(dependency, |