public static void Push(this IDispatcher dispatcher, CommandBase message, Action <MessageExecuteSetting> configurationSetting)
        {
            var setting = new MessageExecuteSetting();

            configurationSetting.Do(action => action(setting));
            dispatcher.Push(message, setting);
        }
        public static TResult Query <TResult>(this IDispatcher dispatcher, QueryBase <TResult> message, Action <MessageExecuteSetting> configurationSetting) where TResult : class
        {
            var setting = new MessageExecuteSetting();

            configurationSetting.Do(action => action(setting));
            return(dispatcher.Query(message, setting));
        }
Ejemplo n.º 3
0
        public TResult Query <TResult>(QueryBase <TResult> message, MessageExecuteSetting executeSetting = null) where TResult : class
        {
            var commandComposite = new CommandComposite();

            commandComposite.Quote(message, executeSetting);
            Push(commandComposite);
            return(message.Result);
        }
 internal MessageExecuteSetting(MessageExecuteSetting executeSetting)
 {
     DataBaseInstance = executeSetting.DataBaseInstance;
     Connection       = executeSetting.Connection;
     IsolationLevel   = executeSetting.IsolationLevel;
     UID = executeSetting.UID;
     //without IsOuter
 }
Ejemplo n.º 5
0
 public MessageDispatcher(IDispatcher dispatcher, MessageExecuteSetting setting)
 {
     if (dispatcher == null)
     {
         throw new Exception("External dispatcher should not be null on internal dispatcher creation");
     }
     this.dispatcher   = dispatcher;
     this.outerSetting = setting;
 }
Ejemplo n.º 6
0
        protected bool Equals(MessageExecuteSetting other)
        {
            if (other == null)
            {
                return(false);
            }

            return(string.Equals(DataBaseInstance, other.DataBaseInstance) &&
                   string.Equals(Connection, other.Connection));
        }
Ejemplo n.º 7
0
 public MessageExecuteSetting(MessageExecuteSetting executeSetting)
 {
     Mute             = executeSetting.Mute;
     OnBefore         = executeSetting.OnBefore;
     OnComplete       = executeSetting.OnComplete;
     OnAfter          = executeSetting.OnAfter;
     OnError          = executeSetting.OnError;
     OnError          = executeSetting.OnError;
     DataBaseInstance = executeSetting.DataBaseInstance;
     Connection       = executeSetting.Connection;
 }
Ejemplo n.º 8
0
            public void Push(CommandBase command, Action <MessageExecuteSetting> configuration = null)
            {
                var setting = new MessageExecuteSetting
                {
                    Connection       = outerSetting.Connection,
                    DataBaseInstance = outerSetting.DataBaseInstance
                };

                configuration.Do(action => action(setting));
                this.dispatcher.Push(command, new MessageExecuteSetting());
            }
Ejemplo n.º 9
0
            public TQueryResult Query <TQueryResult>(QueryBase <TQueryResult> query, Action <MessageExecuteSetting> configuration = null) where TQueryResult : class
            {
                var setting = new MessageExecuteSetting
                {
                    Connection       = outerSetting.Connection,
                    DataBaseInstance = outerSetting.DataBaseInstance
                };

                configuration.Do(action => action(setting));
                return(this.dispatcher.Query(query, setting));
            }
Ejemplo n.º 10
0
            public Lazy <IUnitOfWork> AddOrGet(MessageExecuteSetting setting, bool isFlush)
            {
                if (!ContainsKey(setting))
                {
                    Add(setting, new Lazy <IUnitOfWork>(() =>
                    {
                        var isoLevel = setting.IsolationLevel.GetValueOrDefault(isFlush ? IsolationLevel.ReadCommitted : IsolationLevel.ReadUncommitted);
                        return(_unitOfWorkFactory.Create(isoLevel, isFlush, setting.Connection));
                    }, LazyThreadSafetyMode.None));
                }

                return(this[setting]);
            }
Ejemplo n.º 11
0
        public ISettingCommandComposite Quote(IMessage <object> message, MessageExecuteSetting executeSetting = null)
        {
            if (executeSetting != null)
            {
                message.Setting = new MessageExecuteSetting(executeSetting);
            }
            else
            {
                message.Setting = message.GetType().FirstOrDefaultAttribute <MessageExecuteSettingAttribute>()
                                  .With(r => new MessageExecuteSetting(r))
                                  .Recovery(new MessageExecuteSetting());
            }

            this.parts.Add(message);
            return(this);
        }
Ejemplo n.º 12
0
            public Lazy <IUnitOfWork> AddOrGet(MessageExecuteSetting setting, bool isFlush)
            {
                if (!ContainsKey(setting))
                {
                    Add(setting, new Lazy <IUnitOfWork>(() =>
                    {
                        var unitOfWorkFactory = string.IsNullOrWhiteSpace(setting.DataBaseInstance)
                                                                                           ? IoCFactory.Instance.TryResolve <IUnitOfWorkFactory>()
                                                                                           : IoCFactory.Instance.TryResolveByNamed <IUnitOfWorkFactory>(setting.DataBaseInstance);

                        var isoLevel = setting.IsolationLevel.GetValueOrDefault(isFlush ? IsolationLevel.ReadCommitted : IsolationLevel.ReadUncommitted);
                        return(unitOfWorkFactory.Create(isoLevel, isFlush, setting.Connection));
                    }, LazyThreadSafetyMode.None));
                }

                return(this[setting]);
            }
Ejemplo n.º 13
0
 public MessageDispatcher(IDispatcher dispatcher, MessageExecuteSetting setting)
 {
     Guard.NotNull("dispatcher", dispatcher, errorMessage: "External dispatcher should not be null on internal dispatcher creation");
     this.dispatcher = dispatcher;
     outerSetting    = setting;
 }
 public CommandComposite(IMessage message, MessageExecuteSetting executeSetting = null)
 {
     Quote(message, executeSetting);
 }
 public static void Push(this IDispatcher dispatcher, CommandBase message, MessageExecuteSetting executeSetting = null)
 {
     dispatcher.Push(composite => composite.Quote(message, executeSetting));
 }
 protected bool Equals(MessageExecuteSetting other)
 {
     return(string.Equals(DataBaseInstance, other.DataBaseInstance) &&
            string.Equals(Connection, other.Connection) &&
            IsolationLevel.Equals(other.IsolationLevel));
 }
Ejemplo n.º 17
0
 public TResult Query <TResult>(QueryBase <TResult> message, MessageExecuteSetting executeSetting = null)
 {
     Push(new CommandComposite(message, executeSetting));
     return((TResult)message.Result);
 }
Ejemplo n.º 18
0
 internal MessageCompositePart(IMessage <object> message, MessageExecuteSetting executeSetting)
 {
     this.message = message;
     this.setting = executeSetting;
 }
Ejemplo n.º 19
0
        public void Quote(IMessage <object> message, MessageExecuteSetting executeSetting = null)
        {
            var part = new MessageCompositePart(message, executeSetting ?? new MessageExecuteSetting());

            this.parts.Add(part);
        }