Exemplo n.º 1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="globalTimeProvider">The global time provider for providing the current
        /// time for various events such as when a connection is requested.</param>
        public AbstractRoutingDataManager(GlobalTimeProvider globalTimeProvider = null)
        {
            GlobalTimeProvider = globalTimeProvider ?? new GlobalTimeProvider();
#if DEBUG
            LastMessageRouterResults = new List <MessageRouterResult>();
#endif
        }
Exemplo n.º 2
0
        public void Initialize()
        {
            Trace.WriteLine("--- Starting test initialization");

            TestSettings testSettings = new TestSettings();
            string       azureTableStorageConnectionString = testSettings[SettingsKeyAzureTableStorageConnectionString];

            _globalTimeProvider = new TestGlobalTimeProvider();

            _routingDataManagers = new List <IRoutingDataManager>()
            {
                new LocalRoutingDataManager(_globalTimeProvider)
            };

            if (!string.IsNullOrEmpty(azureTableStorageConnectionString))
            {
                AzureTableStorageRoutingDataManager azureTableStorageRoutingDataManager =
                    new AzureTableStorageRoutingDataManager(
                        azureTableStorageConnectionString, _globalTimeProvider);

                azureTableStorageRoutingDataManager.DeleteAll();

                _routingDataManagers.Add(azureTableStorageRoutingDataManager);
            }
            else if (_firstInitialization)
            {
                Console.Out.Write(SettingsInstructions);
                Trace.WriteLine($"Cannot test {nameof(AzureTableStorageRoutingDataManager)} class due to missing connectiong string");
                _firstInitialization = false;
            }

            Trace.WriteLine("--- Test initialization done");
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="routingDataStore">The routing data store implementation.</param>
 /// <param name="globalTimeProvider">The global time provider for providing the current
 /// time for various events such as when a connection is requested.</param>
 /// <param name="logger">Logger to use.</param>
 public RoutingDataManager(
     IRoutingDataStore routingDataStore,
     GlobalTimeProvider globalTimeProvider = null,
     ILogger logger = null)
 {
     RoutingDataStore   = routingDataStore ?? throw new ArgumentNullException("Routing data store missing");
     GlobalTimeProvider = globalTimeProvider ?? new GlobalTimeProvider();
     _logger            = logger ?? new DebugLogger();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="globalTimeProvider">The global time provider for providing the current
 /// time for various events such as when a connection is requested.</param>
 public LocalRoutingDataManager(GlobalTimeProvider globalTimeProvider = null)
     : base(globalTimeProvider)
 {
     AggregationParties = new List <Party>();
     UserParties        = new List <Party>();
     BotParties         = new List <Party>();
     PendingRequests    = new List <Party>();
     ConnectedParties   = new Dictionary <Party, Party>();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="routingDataStore">The routing data store implementation.</param>
 /// <param name="microsoftAppCredentials">The bot application credentials.
 /// May be required, depending on the setup of your app, for sending messages.</param>
 /// <param name="globalTimeProvider">The global time provider for providing the current
 /// <param name="ILogger">Logger to use. Defaults to DebugLogger.</param>
 /// time for various events such as when a connection is requested.</param>
 public MessageRouter(
     IRoutingDataStore routingDataStore,
     MicrosoftAppCredentials microsoftAppCredentials,
     GlobalTimeProvider globalTimeProvider = null,
     ILogger logger = null)
 {
     Logger                   = logger ?? new DebugLogger();
     RoutingDataManager       = new RoutingDataManager(routingDataStore, globalTimeProvider, Logger);
     _microsoftAppCredentials = microsoftAppCredentials;
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="connectionString">The connection string associated with an Azure Table Storage.</param>
        /// <param name="globalTimeProvider">The global time provider for providing the current
        /// time for various events such as when a connection is requested.</param>
        public AzureTableStorageRoutingDataManager(string connectionString, GlobalTimeProvider globalTimeProvider = null)
            : base(globalTimeProvider)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("The connection string cannot be null or empty");
            }

            _partiesTable     = AzureStorageHelper.GetTable(connectionString, TableNameParties);
            _connectionsTable = AzureStorageHelper.GetTable(connectionString, TableNameConnections);

            MakeSureTablesExist();
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="connectionString">The connection string associated with an Azure Table Storage.</param>
        /// <param name="globalTimeProvider">The global time provider for providing the current
        /// time for various events such as when a connection is requested.</param>
        public AzureTableStorageRoutingDataManager(string connectionString, GlobalTimeProvider globalTimeProvider = null)
            : base(globalTimeProvider)
        {
            if (string.IsNullOrEmpty(connectionString))
            {
                throw new ArgumentNullException("The connection string cannot be null or empty");
            }

            _botPartiesTable         = AzureStorageHelper.GetTable(connectionString, TableNameBotParties);
            _userPartiesTable        = AzureStorageHelper.GetTable(connectionString, TableNameUserParties);
            _aggregationPartiesTable = AzureStorageHelper.GetTable(connectionString, TableNameAggregationParties);
            _pendingRequestsTable    = AzureStorageHelper.GetTable(connectionString, TableNamePendingRequests);
            _connectionsTable        = AzureStorageHelper.GetTable(connectionString, TableNameConnections);

            MakeSureTablesExistAsync();
        }
Exemplo n.º 8
0
 /// <returns>The current global "now" time.</returns>
 protected virtual DateTime GetCurrentGlobalTime()
 {
     return((GlobalTimeProvider == null) ? DateTime.UtcNow : GlobalTimeProvider.GetCurrentTime());
 }
Exemplo n.º 9
0
 public Manager(string connectionString, GlobalTimeProvider globalTimeProvider = null) : base(connectionString, globalTimeProvider)
 {
     _waitingConnectionsTable = AzureStorageHelper.GetTable(connectionString, TableWaitingConnections);
 }