Created
August 24, 2012 08:31
-
-
Save andreasohlund/3447500 to your computer and use it in GitHub Desktop.
New fluent api
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
| namespace NServiceBus.Config | |
| { | |
| /// <summary> | |
| /// Configuration class for Endpoint attributes. | |
| /// </summary> | |
| public class Endpoint : IContainRuntimeSettings | |
| { | |
| /// <summary> | |
| /// Requests that queues will be created as Volatile (non-transactional) hence sending and receiving will be outside a transaction | |
| /// </summary> | |
| /// <param name="config"></param> | |
| /// <returns></returns> | |
| public static Configure Volatile(this Configure config) | |
| { | |
| IsVolatile = true; | |
| DontUseDistributedTransactions = true; | |
| return config; | |
| } | |
| /// <summary> | |
| /// True queues should be created as Transactional (hence also sending will be within a transaction). | |
| /// </summary> | |
| public static bool IsVolatile { get; private set; } | |
| /// <summary> | |
| /// Initialized the bus in send only mode | |
| /// </summary> | |
| /// <returns></returns> | |
| public static IBus SendOnly(this Configure config) | |
| { | |
| IsSendOnly = true; | |
| config.Initialize(); | |
| return config.Builder.Build<IBus>(); | |
| } | |
| /// <summary> | |
| /// True if this endpoint is operating in send only mode | |
| /// </summary> | |
| public static bool IsSendOnly { get; private set; } | |
| } | |
| public class EndpointFluentApiMethods | |
| { | |
| //Endpoint(e=>{//e== EndpointFluentApiMethods}) | |
| public static EndpointFluentApiMethods Volatile() | |
| { | |
| return new EndpointFluentApiMethods(); | |
| } | |
| } | |
| //tranport = receiver|sender => implemented by "queuing" | |
| // code inside the "receiver feature project" | |
| public class Receiver:IContainRuntimeSettings | |
| { | |
| /// <summary> | |
| /// True if distributed transactions should not be used | |
| /// </summary> | |
| public static bool DontUseDistributedTransactions { get; set; } | |
| } | |
| public interface IContainRuntimeSettings | |
| { | |
| } | |
| public static class ReceiverConfigExtensions | |
| { | |
| public static Receiver Receiver(this Endpoint e) | |
| { | |
| return new Receiver(); | |
| } | |
| } | |
| public static class ReceiverEndpointFluentApiMethods | |
| { | |
| public static Receiver DontUseDTC(this EndpointFluentApiMethods e) | |
| { | |
| return new Receiver(); | |
| } | |
| } | |
| internal class MsmqReceiver | |
| { | |
| public void X() | |
| { | |
| //Configure.Endpoint.Receiver().DontUseDistributedTransactions | |
| //Receiver.DontUseDistributedTransactions | |
| //SLR.NumRetries -- inside SLR | |
| //Configure.Endpoint.SLR().NumRetries -- outside IF needed | |
| //Configure.Features.IsEnabled(TM) | |
| } | |
| } | |
| //inside SLR | |
| internal class SLRFeature : IFeature | |
| { | |
| Feature.IDependOn("TimeoutManager"); | |
| } | |
| class EndpointConfig:IConfigureThisEndpoint,As_aServer IWantCustomInitialization,IControlAsmScanning | |
| { | |
| public void Init() | |
| { | |
| Configure.With(); | |
| } | |
| public void Scanning(AsmFilter filter) | |
| { | |
| Filter | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment