/// <summary>
        /// Creates the specified interceptor type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        /// <remarks>The returned type will be wrapped by the message interceptor decorator for capturing metrics</remarks>
        public IMessageInterceptor Create(Type type)
        {
            var interceptor = (IMessageInterceptor)_container.Create().GetInstance(type);
            var decorator   = new MessageInterceptorDecorator(_container.Create().GetInstance <IMetrics>(), interceptor, _container.Create().GetInstance <IConnectionInformation>());

            return(decorator);
        }
        /// <summary>
        /// Creates new instances of <see cref="MessageProcessing" />
        /// </summary>
        /// <returns></returns>
        public IMessageProcessing Create()
        {
            if (_mode.Mode == MessageProcessingModes.Async)
            {
                return(_container.Create().GetInstance <MessageProcessingAsync>());
            }

            return(_container.Create().GetInstance <MessageProcessing>());
        }
        /// <summary>
        /// Creates the specified interceptor type.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        /// <remarks>The returned type will be wrapped by the message interceptor decorator for capturing metrics</remarks>
        public IMessageInterceptor Create(Type type)
        {
            var interceptor = (IMessageInterceptor)_container.Create().GetInstance(type);

            //HACK for now - it's not clear to me if simple injector supports this pattern
            var decorator  = new MessageInterceptorDecorator(_container.Create().GetInstance <IMetrics>(), interceptor, _container.Create().GetInstance <IConnectionInformation>());
            var decorator2 = new Trace.Decorator.MessageInterceptorDecorator(decorator, _container.Create().GetInstance <ITracer>(), _container.Create().GetInstance <IStandardHeaders>());

            return(decorator2);
        }
示例#4
0
        private void StartAlgorithm_Execute()
        {
            try
            {
                IAlgorithm algorithm;

                if (!CheckContainerSize())
                {
                    throw new InvalidContainerSizeException("Container is not big enough to contain biggest object. Enlarge the container.");
                }

                if (Dimensionality == AlgorithmDimensionality.TwoDimensional)
                {
                    Container2D startingContainer = containerFactory.Create(algorithmProperties, ContainerWidth, ContainerHeight);
                    algorithm = factory.Create(algorithmProperties, startingContainer);
                }
                else
                {
                    Container3D startingContainer = containerFactory.Create(algorithmProperties, ContainerWidth, ContainerHeight, ContainerDepth);
                    algorithm = factory.Create(algorithmProperties, startingContainer);
                }

                stopwatch.Reset();

                var sortedObjects = SortingHelper.Sort(objectsToPack, ObjectOrdering);

                stopwatch.Start();
                algorithm.Execute(sortedObjects);
                stopwatch.Stop();

                var endResults = algorithm.CreateResults();

                ExecutionTime                     = stopwatch.ElapsedMilliseconds;
                Quality                           = endResults.Quality;
                ContainersUsed                    = endResults.ContainersUsed;
                ObjectAmount                      = endResults.ObjectCount;
                ObjectTotalFullfilment            = endResults.ObjectsTotalFulfillment;
                ContainerFulfillment              = endResults.ContainerFulfillment;
                AverageFulfillmentRatio           = endResults.AverageFulfillmentRatio;
                FulfillmentRatioStandardDeviation = endResults.FulfillmentRatioStandardDeviation;
                WorstFulfillment                  = endResults.WorstFulfillment;

                System.Windows.MessageBox.Show("Program successfully packed input object set.", "End of packing.");
            }
            catch (Exception err)
            {
                System.Windows.MessageBox.Show("Error during executing algorithm: " + err.Message, "Error");
            }
        }
示例#5
0
        /// <inheritdoc />
        public IGetMessageId Create()
        {
            switch (_options.MessageIdLocation)
            {
            case MessageIdLocations.Uuid:
                return(_container.Create().GetInstance <GetUuidMessageId>());

            case MessageIdLocations.RedisIncr:
                return(_container.Create().GetInstance <GetRedisIncrId>());

            case MessageIdLocations.Custom:
                return(_container.Create().GetInstance <IGetMessageId>());

            default:
                throw new DotNetWorkQueueException($"unhandled type of {_options.MessageIdLocation}");
            }
        }
示例#6
0
        /// <inheritdoc />
        public IUnixTime Create()
        {
            switch (_options.TimeServer)
            {
            case TimeLocations.LocalMachine:
                return(_container.Create().GetInstance <LocalMachineUnixTime>());

            case TimeLocations.RedisServer:
                return(_container.Create().GetInstance <RedisServerUnixTime>());

            case TimeLocations.SntpServer:
                return(_container.Create().GetInstance <SntpUnixTime>());

            case TimeLocations.Custom:
                return(_container.Create().GetInstance <IUnixTime>());

            default:
                throw new DotNetWorkQueueException($"unhandled type of {_options.TimeServer}");
            }
        }
        /// <summary>
        /// Creates a new instance of <see cref="IWorkerHeartBeatNotification" />
        /// </summary>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>
        /// new instance of <see cref="IWorkerHeartBeatNotification" />
        /// </returns>
        public IWorkerHeartBeatNotification Create(CancellationToken cancellationToken)
        {
            if (!_configuration.Enabled)
            {
                return(new WorkerHeartBeatNotificationNoOp());
            }
            var notification = _container.Create().GetInstance <IWorkerHeartBeatNotification>();

            notification.ExceptionHasOccured = cancellationToken;
            return(notification);
        }
 /// <summary>
 /// Creates a new instance of <see cref="IMessageContext" />
 /// </summary>
 /// <returns></returns>
 public IMessageContext Create()
 {
     return(_container.Create().GetInstance <IMessageContext>());
 }
 public ITaskFactory Create()
 {
     return(_container.Create().GetInstance <ITaskFactory>());
 }
 public ATaskScheduler Create()
 {
     return(_container.Create().GetInstance <ATaskScheduler>());
 }
示例#11
0
 /// <summary>
 /// Creates a new instance of <see cref="IWorkerNotification" />
 /// </summary>
 /// <returns></returns>
 public IWorkerNotification Create()
 {
     return(_container.Create().GetInstance <IWorkerNotification>());
 }
 /// <summary>
 /// Creates new instance of <see cref="IPrimaryWorker" />
 /// </summary>
 /// <returns></returns>
 public IPrimaryWorker Create()
 {
     return _container.Create().GetInstance<IPrimaryWorker>();
 }
示例#13
0
 /// <summary>
 /// Returns instance of <see cref="IGetTime" />
 /// </summary>
 /// <returns></returns>
 public IGetTime Create()
 {
     return(_container.Create().GetInstance <IGetTime>());
 }
示例#14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DbFactory"/> class.
 /// </summary>
 /// <param name="container">The container.</param>
 public DbFactory(IContainerFactory container)
 {
     _container = container.Create();
 }
示例#15
0
 /// <summary>
 /// Creates a new instance of <see cref="IRetryDelay"/>
 /// </summary>
 public IRetryDelay Create()
 {
     return(_container.Create().GetInstance <IRetryDelay>());
 }
示例#16
0
 /// <summary>
 /// Creates a new <see cref="IWorker" />
 /// </summary>
 /// <returns></returns>
 public IWorker Create()
 {
     return(_container.Create().GetInstance <IWorker>());
 }
 /// <summary>
 /// Creates a new instance of <see cref="IReceiveMessages" />
 /// </summary>
 /// <returns></returns>
 public IReceiveMessages Create()
 {
     return(_container.Create().GetInstance <IReceiveMessages>());
 }
 public SqLiteTransactionFactory(IContainerFactory container)
 {
     _container = container.Create();
 }