EventHubListenerLib.EventHubListenerOptions.PrepareAsync C# (CSharp) Метод

PrepareAsync() приватный Метод

private PrepareAsync ( ) : System.Threading.Tasks.Task
Результат System.Threading.Tasks.Task
        internal async Task PrepareAsync()
        {
            if (IsStartUTCDateTime && IsOffset)
                throw new InvalidOperationException("can not have start utc date && start offset at the same time, either one of them or none of them");


            if (EventHubListenerMode.Single == ListenerMode && string.IsNullOrEmpty(AssignedEventHubPartitionId))
                throw new InvalidOperationException("Listener is in Single mode and no assigned event hub partition id");

            if (null != OrderedServicePartitionIds)
            {

                if (OrderedServicePartitionIds.Where(p => null == p).Count() > 0)
                    throw new InvalidOperationException("Partiton list contains one or more null entries");

            }
            else
            {
                if (null == mServiceName)
                    throw new InvalidOperationException("Can not resolve partitions list with no service fabric service name assigned");

                await SetServicePartitionListAsync();
            }


            if (null == Processor)
                throw new InvalidOperationException("processor is null");


            if (null == StateFactory)
                throw new InvalidOperationException("state factor is null");


            if (string.IsNullOrEmpty(EventHubName))
                throw new InvalidOperationException("Event hub name is null or empty");

            if (string.IsNullOrEmpty(EventHubConnectionString))
                throw new InvalidOperationException("Event hub connection string is null or empty");

            if (null == EventHubConsumerGroupName)
                EventHubConsumerGroupName = string.Empty;
        }
        

Usage Example

        public async Task <string> OpenAsync(CancellationToken cancellationToken)
        {
            await mOptions.PrepareAsync();

            var useDefaultConsumerGroup = !string.IsNullOrEmpty(mOptions.EventHubConsumerGroupName);


            mMessagingFactory = MessagingFactory.CreateFromConnectionString(mOptions.EventHubConnectionString);
            mEventHubClient   = mMessagingFactory.CreateEventHubClient(mOptions.EventHubName);
            mConsumerGroup    = useDefaultConsumerGroup ?
                                mEventHubClient.GetConsumerGroup(mOptions.EventHubConsumerGroupName)
                              : mEventHubClient.GetDefaultConsumerGroup();



            return(string.Concat(mEventHubNamespace, "/",
                                 mOptions.EventHubName, "/",
                                 useDefaultConsumerGroup ? "<default group>" : mOptions.EventHubConsumerGroupName));
        }