Exemple #1
0
        public Consumer(
            Guid correlationId,
            Uri serviceUrl,
            string subscriptionName,
            string topic,
            IRegisterEvent eventRegister,
            IConsumerChannel <TMessage> initialChannel,
            IExecute executor,
            IStateChanged <ConsumerState> state,
            IConsumerChannelFactory <TMessage> factory)
        {
            _correlationId   = correlationId;
            ServiceUrl       = serviceUrl;
            SubscriptionName = subscriptionName;
            Topic            = topic;
            _eventRegister   = eventRegister;
            _channel         = initialChannel;
            _executor        = executor;
            _state           = state;
            _factory         = factory;
            _commandAckPool  = new DefaultObjectPool <CommandAck>(new DefaultPooledObjectPolicy <CommandAck>());
            _isDisposed      = 0;

            _eventRegister.Register(new ConsumerCreated(_correlationId));
        }
Exemple #2
0
        public static void ResetStateChanged(IStateChanged state)
        {
            if (state != null)
            {
                state.SetStateChanged(false);
            }

            var properties = state.GetType().GetProperties();

            foreach (var property in properties)
            {
                var value = property.GetValue(state, null);

                if (value != null && value is IStateChanged)
                {
                    var changedValue = (IStateChanged)value;
                    changedValue.SetStateChanged(false);
                }
            }

            var fields = state.GetType().GetFields();

            foreach (var field in fields)
            {
                var value = field.GetValue(state);
                if (value != null && value is IStateChanged)
                {
                    var changedValue = (IStateChanged)value;
                    changedValue.SetStateChanged(false);
                }
            }
        }
Exemple #3
0
        public Producer(
            Guid correlationId,
            Uri serviceUrl,
            string topic,
            ulong initialSequenceId,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state,
            IProducerChannelFactory factory,
            ISchema <TMessage> schema)
        {
            var messageMetadataPolicy = new DefaultPooledObjectPolicy <PulsarApi.MessageMetadata>();

            _messageMetadataPool = new DefaultObjectPool <PulsarApi.MessageMetadata>(messageMetadataPolicy);
            _correlationId       = correlationId;
            ServiceUrl           = serviceUrl;
            Topic          = topic;
            _sequenceId    = new SequenceId(initialSequenceId);
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _factory       = factory;
            _schema        = schema;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId));
        }
Exemple #4
0
        public BaseRecruitCommandParameter(IStateChanged stateChanged)
        {
            if (stateChanged == null)
            {
                throw new ArgumentNullException(nameof(stateChanged));
            }

            StateChanged = stateChanged;
        }
        public ExportRecruitCommandParameters(IEnumerable <long> recruitIds,
                                              IStateChanged stateChanged) : base(stateChanged)
        {
            if (recruitIds == null)
            {
                throw new ArgumentNullException(nameof(recruitIds));
            }

            RecruitIds = recruitIds;
        }
        public EditRecruitCommandParameters(RecruitInfo recruitInfo,
                                            IStateChanged stateChanged) : base(stateChanged)
        {
            if (recruitInfo == null)
            {
                throw new ArgumentNullException(nameof(recruitInfo));
            }

            RecruitInfo = recruitInfo;
        }
        public RemoveRecruitCommandParameters(RecruitShortUIModel recruitShortUIModel,
                                              IStateChanged stateChanged) : base(stateChanged)
        {
            if (recruitShortUIModel == null)
            {
                throw new ArgumentNullException(nameof(recruitShortUIModel));
            }

            RecruitShortUIModel = recruitShortUIModel;
        }
Exemple #8
0
        public ImportRecruitCommandParameters(DateTime?conscriptionDate,
                                              string selectedRegionalCollectionPoint,
                                              IStateChanged stateChanged) : base(stateChanged)
        {
            if (stateChanged == null)
            {
                throw new ArgumentNullException(nameof(stateChanged));
            }

            ConscriptionDate = conscriptionDate;
            SelectedRegionalCollectionPoint = selectedRegionalCollectionPoint;
        }
Exemple #9
0
        public ActionCommand(Action <object> execute, IStateChanged stateChanged = null,
                             Predicate <object> canExecute = null)
        {
            if (execute == null)
            {
                throw new ArgumentException("Parameter shouldn't be null", "execute");
            }

            _execute      = execute;
            _stateChanged = stateChanged;
            _canExecute   = canExecute;
        }
Exemple #10
0
        public AsyncCommand(Func <object, Task> asyncExecute,
                            IStateChanged stateChanged    = null,
                            Predicate <object> canExecute = null)
        {
            if (asyncExecute == null)
            {
                throw new ArgumentException("Parameter shouldn't be null", nameof(asyncExecute));
            }

            _asyncExecute = asyncExecute;
            _stateChanged = stateChanged;
            _canExecute   = canExecute;
        }
        public ExportTableRecruitCommandParameters(IEnumerable <RecruitShortUIModel> recruitShortUIModels,
                                                   string conscriptionDate,
                                                   string regionalCollectionPoint,
                                                   IStateChanged stateChanged) : base(stateChanged)
        {
            if (recruitShortUIModels == null)
            {
                throw new ArgumentNullException(nameof(recruitShortUIModels));
            }

            RecruitShortUIModels    = recruitShortUIModels;
            ConscriptionDate        = conscriptionDate;
            RegionalCollectionPoint = regionalCollectionPoint;
        }
Exemple #12
0
        // TODO: optimize
        public static bool ApplyStateChanged(IStateChanged oldState, IStateChanged newState)
        {
            if (oldState == null || newState == null)
            {
                return(oldState != null || newState != null);
            }

            bool stateChanged = false;

            var properties = newState.GetType().GetProperties();

            foreach (var property in properties)
            {
                var newValue = property.GetValue(newState, null);
                var oldValue = property.GetValue(oldState, null);

                if (newValue is IStateChanged)
                {
                    stateChanged |= ApplyStateChanged((IStateChanged)oldValue, (IStateChanged)newValue);
                }
                else if (newValue == null && oldValue != null || newValue != null && !newValue.Equals(oldValue))
                {
                    stateChanged = true;
                }
            }

            var fields = newState.GetType().GetFields();

            foreach (var field in fields)
            {
                var newValue = field.GetValue(newState);
                var oldValue = field.GetValue(oldState);

                if (newValue is IStateChanged)
                {
                    stateChanged |= ApplyStateChanged((IStateChanged)oldValue, (IStateChanged)newValue);
                }
                else if (newValue == null && oldValue != null || newValue != null && !newValue.Equals(oldValue))
                {
                    stateChanged = true;
                }
            }

            if (stateChanged)
            {
                newState.SetStateChanged();
            }

            return(stateChanged);
        }
Exemple #13
0
        public Reader(
            Guid correlationId,
            IRegisterEvent eventRegister,
            IReaderChannel initialChannel,
            IExecute executor,
            IStateChanged <ReaderState> state)
        {
            _correlationId = correlationId;
            _eventRegister = eventRegister;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _isDisposed    = 0;

            _eventRegister.Register(new ReaderCreated(_correlationId, this));
        }
Exemple #14
0
        public Consumer(
            Guid correlationId,
            IRegisterEvent eventRegister,
            IConsumerChannel initialChannel,
            IExecute executor,
            IStateChanged <ConsumerState> state)
        {
            _correlationId    = correlationId;
            _eventRegister    = eventRegister;
            _channel          = initialChannel;
            _executor         = executor;
            _state            = state;
            _cachedCommandAck = new CommandAck();
            _isDisposed       = 0;

            _eventRegister.Register(new ConsumerCreated(_correlationId, this));
        }
        public SaveRecruitCommandParameters(RecruitOperationEventArgs recruitOperationEventArgs,
                                            RecruitCardGroup recruitCardGroup,
                                            IStateChanged stateChanged) : base(stateChanged)
        {
            if (recruitOperationEventArgs == null)
            {
                throw new ArgumentNullException(nameof(recruitOperationEventArgs));
            }

            if (recruitCardGroup == null)
            {
                throw new ArgumentNullException(nameof(recruitCardGroup));
            }

            RecruitOperationEventArgs = recruitOperationEventArgs;
            RecruitCardGroup          = recruitCardGroup;
        }
Exemple #16
0
        public Producer(
            Guid correlationId,
            string topic,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state)
        {
            _correlationId = correlationId;
            Topic          = topic;
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId, this));
        }
Exemple #17
0
        public Consumer(
            Guid correlationId,
            string topic,
            IRegisterEvent eventRegister,
            IConsumerChannel initialChannel,
            IExecute executor,
            IStateChanged <ConsumerState> state)
        {
            _correlationId  = correlationId;
            Topic           = topic;
            _eventRegister  = eventRegister;
            _channel        = initialChannel;
            _executor       = executor;
            _state          = state;
            _commandAckPool = new DefaultObjectPool <CommandAck>(new DefaultPooledObjectPolicy <CommandAck>());
            _isDisposed     = 0;

            _eventRegister.Register(new ConsumerCreated(_correlationId, this));
        }
Exemple #18
0
        public Reader(
            Guid correlationId,
            Uri serviceUrl,
            string topic,
            IRegisterEvent eventRegister,
            IConsumerChannel initialChannel,
            IExecute executor,
            IStateChanged <ReaderState> state)
        {
            _correlationId = correlationId;
            ServiceUrl     = serviceUrl;
            Topic          = topic;
            _eventRegister = eventRegister;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _isDisposed    = 0;

            _eventRegister.Register(new ReaderCreated(_correlationId, this));
        }
        public UpdateRecruitsCommandParameters(DateTime?conscriptionDate,
                                               string selectedRegionalCollectionPoint,
                                               string surname,
                                               string selectedStorage,
                                               ObservableCollection <RecruitShortUIModel> recruitShortUIModels,
                                               IStateChanged stateChanged) : base(stateChanged)
        {
            if (recruitShortUIModels == null)
            {
                throw new ArgumentNullException(nameof(recruitShortUIModels));
            }

            if (stateChanged == null)
            {
                throw new ArgumentNullException(nameof(stateChanged));
            }

            ConscriptionDate = conscriptionDate;
            SelectedRegionalCollectionPoint = selectedRegionalCollectionPoint;
            Surname              = surname;
            SelectedStorage      = selectedStorage;
            RecruitShortUIModels = recruitShortUIModels;
        }
Exemple #20
0
        public Producer(
            Guid correlationId,
            string topic,
            ulong initialSequenceId,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state)
        {
            var messageMetadataPolicy = new DefaultPooledObjectPolicy <PulsarApi.MessageMetadata>();

            _messageMetadataPool = new DefaultObjectPool <PulsarApi.MessageMetadata>(messageMetadataPolicy);
            _correlationId       = correlationId;
            Topic          = topic;
            _sequenceId    = new SequenceId(initialSequenceId);
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId, this));
        }
Exemple #21
0
        public SubProducer(
            Guid correlationId,
            Uri serviceUrl,
            string topic,
            IRegisterEvent registerEvent,
            IProducerChannel initialChannel,
            IExecute executor,
            IStateChanged <ProducerState> state,
            IProducerChannelFactory factory,
            ISchema <TMessage> schema)
        {
            _correlationId = correlationId;
            ServiceUrl     = serviceUrl;
            Topic          = topic;
            _eventRegister = registerEvent;
            _channel       = initialChannel;
            _executor      = executor;
            _state         = state;
            _factory       = factory;
            _schema        = schema;
            _isDisposed    = 0;

            _eventRegister.Register(new ProducerCreated(_correlationId));
        }