Beispiel #1
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="MusicClient" /> class.
        /// </summary>
        /// <param name="clientId">The Application Client ID obtained during registration</param>
        /// <param name="countryCode"> The country code. </param>
        /// <param name="language"> The language code. </param>
        /// <param name="requestHandler"> The request handler. </param>
        /// <remarks>
        ///   Allows custom requestHandler for testing purposes
        /// </remarks>
        internal MusicClient(string clientId, string countryCode, string language, IApiRequestHandler requestHandler)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                throw new ApiCredentialsRequiredException();
            }

            this.ApiBaseUrl       = MusicClientCommand.DefaultBaseApiUri;
            this.SecureApiBaseUrl = MusicClientCommand.DefaultSecureBaseApiUri;

            this.ClientId       = clientId;
            this.Language       = language;
            this.RequestHandler = requestHandler;

            if (this.ValidateCountryCode(countryCode))
            {
                this.CountryCode = countryCode.ToLowerInvariant();
            }
            else
            {
                throw new InvalidCountryCodeException();
            }

            this.CurrentMusicClientSettings = this;
        }
Beispiel #2
0
        public CacheManager(StatelessServiceContext context)
            : base(context)
        {
            IConfigurationBuilder builder = new ConfigurationBuilder()
                                            .SetBasePath(Directory.GetCurrentDirectory())
                                            //.AddJsonFile("appsettings.json", true, true)
                                            //.AddServiceFabricConfig("Config")
                                            .AddEnvironmentVariables();

            Configuration = builder.Build();
            IDistributedCache cache = new RedisCache(new RedisCacheOptions
            {
                Configuration = Configuration.GetSection("Appsettings:ConnectionString").Value,
                InstanceName  = "master"
            });

            ApiRequestHandler = new ApiRequestHandler();
            IServiceCollection services = new ServiceCollection();

            services.AddSingleton(Configuration);
            services.AddScoped <IApiRequestHandler, ApiRequestHandler>();

            services.AddSingleton(CacheHandler.Instance);
            CacheHandler.Instance.InitCacheHandler(Configuration, ApiRequestHandler, cache);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CountryResolver" /> class.
        /// </summary>
        /// <param name="clientId">The Application Client ID obtained during registration</param>
        /// <param name="requestHandler">The request handler.</param>
        /// <remarks>
        /// Allows custom requestHandler for testing purposes
        /// </remarks>
        internal CountryResolver(string clientId, IApiRequestHandler requestHandler)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                throw new ApiCredentialsRequiredException();
            }

            this.ClientId = clientId;
            this.RequestHandler = requestHandler;
        }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CountryResolver" /> class.
        /// </summary>
        /// <param name="clientId">The Application Client ID obtained during registration</param>
        /// <param name="requestHandler">The request handler.</param>
        /// <remarks>
        /// Allows custom requestHandler for testing purposes
        /// </remarks>
        internal CountryResolver(string clientId, IApiRequestHandler requestHandler)
        {
            if (string.IsNullOrEmpty(clientId))
            {
                throw new ApiCredentialsRequiredException();
            }

            this.ClientId       = clientId;
            this.RequestHandler = requestHandler;
        }
Beispiel #5
0
 public EchoBot(ConversationState conversationState, UserState userState, IFileHandler fileHandler, IConfiguration configuration, IApiParameterHandler apiParameterHandler, IApiRequestHandler apiRequestHandler)
 {
     _conversationState   = conversationState;
     _userState           = userState;
     _fileHandler         = fileHandler;
     _configuration       = configuration;
     messageList          = new Dictionary <string, string>();
     _apiParameterHandler = apiParameterHandler;
     _apiRequestHandler   = apiRequestHandler;
 }
Beispiel #6
0
 /// <summary>
 ///     This is the constructor of the worker service
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="apiRequestHandler"></param>
 /// <param name="emailSender"></param>
 /// <param name="config"></param>
 public GraduationWorker(ILogger <GraduationWorker> logger,
                         IApiRequestHandler apiRequestHandler,
                         IEmailSender emailSender,
                         Config config)
 {
     this.logger      = logger;
     requestHandler   = apiRequestHandler;
     this.emailSender = emailSender;
     this.config      = config;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CountryResolver" /> class.
        /// </summary>
        /// <param name="appId">The App ID obtained from api.developer.nokia.com</param>
        /// <param name="appCode">The App Code obtained from api.developer.nokia.com</param>
        /// <param name="requestHandler">The request handler.</param>
        /// <remarks>
        /// Allows custom requestHandler for testing purposes
        /// </remarks>
        internal CountryResolver(string appId, string appCode, IApiRequestHandler requestHandler)
        {
            if (string.IsNullOrEmpty(appId) || string.IsNullOrEmpty(appCode))
            {
                throw new ApiCredentialsRequiredException();
            }

            this._appId = appId;
            this._appCode = appCode;
            this._requestHandler = requestHandler;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CountryResolver" /> class.
        /// </summary>
        /// <param name="appId">The App ID obtained from api.developer.nokia.com</param>
        /// <param name="requestHandler">The request handler.</param>
        /// <param name="requestId">A unique id to associate with this request.</param>
        /// <remarks>
        /// Allows custom requestHandler for testing purposes
        /// </remarks>
        internal CountryResolver(string appId, IApiRequestHandler requestHandler, Guid? requestId = null)
        {
            if (string.IsNullOrEmpty(appId))
            {
                throw new ApiCredentialsRequiredException();
            }

            this._requestHandler = requestHandler;
            this._command = new CountryResolverCommand(appId, requestHandler);
            if (requestId.HasValue)
            {
                this._command.RequestId = requestId.Value;
            }
        }
Beispiel #9
0
 internal void InitCacheHandler(IConfiguration configuration, IApiRequestHandler apiRequestHandler, IDistributedCache cache)
 {
     _dataApikey        = configuration.GetSection("Appsettings").GetSection("DataApikey").Value;
     _cache             = cache;
     _apiRequestHandler = apiRequestHandler;
 }
Beispiel #10
0
 public OrganizerAppProjectApiRequestHandler(IApiRequestHandler apiRequestHandler)
 {
     _apiRequestHandler = apiRequestHandler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MusicClientAsync" /> class.
 /// </summary>
 /// <param name="appId">The App ID obtained from api.developer.nokia.com</param>
 /// <param name="appCode">The App Code obtained from api.developer.nokia.com</param>
 /// <param name="countryCode">The country code.</param>
 /// <param name="requestHandler">The request handler.</param>
 /// <remarks>
 /// Allows custom requestHandler for testing purposes
 /// </remarks>
 internal MusicClientAsync(string appId, string appCode, string countryCode, IApiRequestHandler requestHandler)
 {
     this._musicClient = new MusicClient(appId, appCode, countryCode, requestHandler);
 }
Beispiel #12
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="MusicClient" /> class.
 /// </summary>
 /// <param name="clientId">The Application Client ID obtained during registration</param>
 /// <param name="requestHandler"> The request handler. </param>
 /// <remarks>
 ///   Allows custom requestHandler for testing purposes
 /// </remarks>
 internal MusicClient(string clientId, IApiRequestHandler requestHandler)
     : this(clientId, RegionInfo.CurrentRegion.TwoLetterISORegionName.ToLower(), null, requestHandler)
 {
     this.CountryCodeBasedOnRegionInfo = true;
 }
Beispiel #13
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="MusicClient" /> class.
 /// </summary>
 /// <param name="clientId">The Application Client ID obtained during registration</param>
 /// <param name="countryCode"> The country code. </param>
 /// <param name="requestHandler"> The request handler. </param>
 /// <remarks>
 ///   Allows custom requestHandler for testing purposes
 /// </remarks>
 internal MusicClient(string clientId, string countryCode, IApiRequestHandler requestHandler)
     : this(clientId, countryCode, null, requestHandler)
 {
 }
 public CountryResolverCommand(string appId, IApiRequestHandler handler)
 {
     this.ClientSettings = new CountryResolverSettings(appId);
     this.RequestHandler = handler;
 }
Beispiel #15
0
 public OrganizerAppTaskApiRequestHandler(IApiRequestHandler apiRequestHandler)
 {
     _apiRequestHandler = apiRequestHandler;
 }