Beispiel #1
0
        public static async Task InitializeAsync(string projectId, string secretKey, string userName = "", bool newUser = true)
        {
            LoggerFactory           = new LoggerFactory();
            ConfigurationProvider   = new ConfigurationProvider();
            HmacService             = new HmacService();
            CancellationTokenSource = new CancellationTokenSource();
            ProjectId = projectId;
            SecretKet = secretKey;
            var handler = new HttpClientHandler();

            handler.ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => { return(true); };
            mainClient = new HttpClient(handler);
            UnitOfWork = new UnitOfWork(LoggerFactory.Logger);
            var c = await ConfigurationProvider.LoadConfigurationAsync();

            if (!c)
            {
                throw new Exception("Configuration not found!!!");
            }
            ProbaHttpClient    = new ProbaHttpClient(LoggerFactory.Logger, mainClient, SecretKet, ProjectId, HmacService, CancellationTokenSource, ConfigurationProvider.Configuration);
            AsyncTaskScheduler = new AsyncTaskScheduler(CancellationTokenSource, ProbaHttpClient);
            AsyncTaskScheduler.StartAsync();
            UserName = userName != "" ? userName : Guid.NewGuid().ToString();
            NewUser  = newUser;
            await RegisterAsync();
        }
 public ProbaHttpClient(ILogger logger, HttpClient client, string secretKet, string projectId, HmacService hmacService, CancellationTokenSource cancellationTokenSource, ConfigurationModel configuration)
 {
     Logger                  = logger;
     Client                  = client;
     SecretKet               = secretKet;
     ProjectId               = projectId;
     HmacService             = hmacService;
     CancellationTokenSource = cancellationTokenSource;
     Configuration           = configuration;
 }