public SimpleAppClient(IRequester requester, Dictionary<Type, object> services) : base(requester) { foreach (var pair in services) { Type iface = pair.Key; if (iface == null) { throw new ApplicationException(); // todo2[ak] } if (!iface.IsInterface) { throw new ApplicationException(); // todo2[ak] } object instance = pair.Value; if (instance == null) { throw new ApplicationException(); // todo2[ak] } if (!iface.IsAssignableFrom(instance.GetType())) { throw new ApplicationException(); // todo2[ak] } } _proxies = services.ToDictionary( pair => pair.Key.FullName, pair => new Tuple<Type, object>(pair.Key, pair.Value)); }
/// <summary> /// Create an implementation of the given interface, using the given requester /// </summary> /// <typeparam name="T">Type of interface to implement</typeparam> /// <param name="requester">Requester to be used by the generated implementation</param> /// <returns>An implementation of the given interface</returns> public T CreateImplementation <T>(IRequester requester) { if (requester == null) { throw new ArgumentNullException(nameof(requester)); } // We have to be careful here. The common case is going to be fetching an existing creator. However in the case // that one doesn't yet exist, we can't try and create two of the same type at the same time. // We have a lock around creating all types, as that's simpler and probably won't be noticable in practice. if (TypeCreatorRegistry <T> .Creator == null) { lock (this.implementationBuilderLockObject) { // Two threads can fail the null test and acquire this lock in order. The first one will create the type. // Therefore the second one has to check for this... if (TypeCreatorRegistry <T> .Creator == null) { var implementationType = this.BuildImplementationImpl(typeof(T)); var creator = this.BuildCreator <T>(implementationType); TypeCreatorRegistry <T> .Creator = creator; } } } T implementation = TypeCreatorRegistry <T> .Creator(requester); return(implementation); }
public Client(IResponseHandler responseHandler, Dictionary <string, FunctionInfo> functions = null) { this.requester = new TRequester(); this.ResponseHandler = responseHandler; this.serializer = new TSerializer(); Functions = functions; }
public Api() { searchParameters = new Parameters(); requiredValues = new List <RequiredValueType>(); requester = new Requester(); parser = new Parser(); }
public static IConfiguration WithMockRequester(this IConfiguration config, IRequester mockRequester) { return(config.With(mockRequester).WithDefaultLoader(new LoaderOptions { IsResourceLoadingEnabled = true, })); }
private void InitializeRequesterAgent(EntityConfigBase cfg) { if ((cfg.Interaction & InteractionTypes.Requester) != InteractionTypes.Requester) { return; } IRequester p = EntityInstance as IRequester; if (p == null) { return; } _requesterAgent = new PullSenderAgent(p, _log); foreach (PullChannelConfig c in cfg.RequestConfig.Channels) { _requesterAgent.RegisterChannel(c); } _requesterAgent.InitializeChannels(); if (cfg.RequestConfig.ProcessConfig.PreProcessConfig.IsEnable()) { _requesterAgent.OnPreProcessing += new DuplexMessagePreProcessHandler(_requesterAgent_OnPreProcessing); _log.Write(LogType.Debug, "Message pre processing handler is injected for requester. " + cfg.EntityID.ToString()); } if (cfg.RequestConfig.ProcessConfig.PostProcessConfig.IsEnable()) { _requesterAgent.OnPostProcessing += new DuplexMessagePostProcessHanlder(_requesterAgent_OnPostProcessing); _log.Write(LogType.Debug, "Message post processing handler is injected for requester. " + cfg.EntityID.ToString()); } }
/// <summary> /// Create an implementation of the given interface, using the given requester /// </summary> /// <typeparam name="T">Type of interface to implement</typeparam> /// <param name="requester">Requester to be used by the generated implementation</param> /// <returns>An implementation of the given interface</returns> public T CreateImplementation <T>(IRequester requester) { if (requester == null) { throw new ArgumentNullException("requester"); } // We have to be careful here. The common case is going to be fetching an existing creator. However in the case // that one doesn't yet exist, we can't try and create two of the same type at the same time. // We have a lock around creating all types, as that's simpler and probably won't be noticable in practice. Func <IRequester, object> creator; var key = typeof(T).TypeHandle; if (!this.creatorCache.TryGetValue(key, out creator)) { lock (this.implementationBuildLockObject) { // Two threads can fail the TryGetValue and acquire this lock in order. The first one will create the type. // Therefore the second one has to check for this... if (!this.creatorCache.TryGetValue(key, out creator)) { var implementationType = this.BuildImplementationImpl(typeof(T)); creator = this.BuildCreator(implementationType); this.creatorCache.TryAdd(key, creator); } } } T implementation = (T)creator(requester); return(implementation); }
public Client(Credentials credentials, IEnvironment env = null) { if (credentials == null) { throw new ArgumentNullException(nameof(credentials)); } environment = env ?? Environments.Production; requester = new Requester(credentials, environment, null, this.apiVersion); Account = new AccountResource(requester); Balance = new BalanceResource(requester); Charges = new ChargeResource(requester); Customers = new CustomerResource(requester); Disputes = new DisputeResource(requester); Events = new EventResource(requester); Forex = new ForexResource(requester); Links = new LinkResource(requester); Occurrences = new OccurrenceResource(requester); Sources = new PaymentSourceResource(requester); Receipts = new ReceiptResource(requester); Recipients = new RecipientResource(requester); Refunds = new RefundResource(requester); Schedules = new ScheduleResource(requester); Tokens = new TokenResource(requester); Transactions = new TransactionResource(requester); Transfers = new TransferResource(requester); }
public Program(IConsole console, string workingDirectory) { // We can register the MSBuild that is bundled with the SDK to perform MSBuild things. dotnet-watch is in // a nested folder of the SDK's root, we'll back up to it. // AppContext.BaseDirectory = $sdkRoot\$sdkVersion\DotnetTools\dotnet-watch\$version\tools\net6.0\any\ // MSBuild.dll is located at $sdkRoot\$sdkVersion\MSBuild.dll var sdkRootDirectory = Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "..", "..", ".."); #if DEBUG // In the usual case, use the SDK that contains the dotnet-watch. However during local testing, it's // much more common to run dotnet-watch from a different SDK. Use the ambient SDK in that case. MSBuildLocator.RegisterDefaults(); #else MSBuildLocator.RegisterMSBuildPath(sdkRootDirectory); #endif Ensure.NotNull(console, nameof(console)); Ensure.NotNullOrEmpty(workingDirectory, nameof(workingDirectory)); _console = console; _workingDirectory = workingDirectory; _cts = new CancellationTokenSource(); console.CancelKeyPress += OnCancelKeyPress; var suppressEmojis = ShouldSuppressEmojis(); _reporter = CreateReporter(verbose: true, quiet: false, console: _console, suppressEmojis); _requester = new ConsoleRequester(_console, quiet: false, suppressEmojis); // Register listeners that load Roslyn-related assemblies from the `Rosyln/bincore` directory. RegisterAssemblyResolutionEvents(sdkRootDirectory); }
public MatchClient Create( IRequestUrlBuilder requestUrlBuilder, IRequester requester, JsonSerializerSettings jsonSerializerSettings) { return(new MatchClient(requestUrlBuilder, requester, jsonSerializerSettings)); }
/// <summary> /// Registers the default loader service, if no other loader has been /// registered yet. /// </summary> /// <param name="configuration">The configuration to extend.</param> /// <param name="setup">Optional setup for the loader service.</param> /// <param name="requesters">Optional requesters to use.</param> /// <returns>The new instance with the service.</returns> public static IConfiguration WithDefaultLoader(this IConfiguration configuration, Action <LoaderService> setup = null, IEnumerable <IRequester> requesters = null) { if (configuration == null) { throw new ArgumentNullException("configuration"); } if (configuration.GetServices <ILoaderService>().Any() == false) { if (requesters == null) { requesters = new IRequester[] { new HttpRequester(), new DataRequester() } } ; var service = new LoaderService(requesters); if (setup != null) { setup(service); } return(configuration.With(service)); } return(configuration); }
public DisputeResource(IRequester requester) : base(requester, Endpoint.Api, "/disputes") { OpenDisputes = new StatusSpecificDispute(DisputeStatus.Open, requester); PendingDisputes = new StatusSpecificDispute(DisputeStatus.Pending, requester); ClosedDisputes = new StatusSpecificDispute(DisputeStatus.Closed, requester); }
/// <summary> /// Dependency injection constructor /// </summary> /// <param name="rateLimitedRequester">Rate limited requester for all endpoints except the static endpoint.</param> /// <param name="staticEndpointProvider">The static endpoint provider.</param> /// <param name="cache">The cache.</param> /// <exception cref="ArgumentNullException"> /// rateLimitedRequester /// or /// staticEndpointProvider /// </exception> public RiotApi(IRateLimitedRequester rateLimitedRequester, IRequester requester, IStaticEndpointProvider staticEndpointProvider, ICache cache = null) { if (rateLimitedRequester == null) { throw new ArgumentNullException(nameof(rateLimitedRequester)); } if (staticEndpointProvider == null) { throw new ArgumentNullException(nameof(staticEndpointProvider)); } _cache = cache ?? new PassThroughCache(); Summoner = new SummonerEndpoint(rateLimitedRequester, _cache); Champion = new ChampionEndpoint(rateLimitedRequester); League = new LeagueEndpoint(rateLimitedRequester); Match = new MatchEndpoint(rateLimitedRequester, _cache); Spectator = new SpectatorEndpoint(rateLimitedRequester); ChampionMastery = new ChampionMasteryEndpoint(rateLimitedRequester); ThirdParty = new ThirdPartyEndpoint(rateLimitedRequester); DataDragon = new DataDragonEndpoints(staticEndpointProvider); Status = new StatusEndpoint(requester); Clash = new ClashEndpoint(rateLimitedRequester, _cache); }
public static async Task <IList <VtmResponse> > GetProxyResponseAsync(int rbl) { IRequester requester = RequesterFactory.Instance; Response response = await requester.GetResponseAsync(rbl); return(_ModifyResponse(response)); }
async Task <IResponse> PrepareAsync(IRequester requester, Url url, CancellationToken cancel) { if (_parserInserted && !IsAsync) { if (IsDeferred) { Owner.AddScript(this); } } else if (!IsAsync && !_forceAsync) { //Add to end of list of scripts (in order) --> sufficient Owner.AddScript(this); } else { //Just add to the set of scripts Owner.AddScript(this); } var response = await requester.LoadWithCorsAsync(url, CrossOrigin.ToEnum(CorsSetting.None), Owner.Origin, OriginBehavior.Taint, cancel); if (_parserInserted && !IsAsync) { _readyToBeExecuted = true; } return(response); }
public void TestInitialize() { _TestRbl = 147; _TestRblSet = new HashSet <int>(new int[] { 7, 8, 9 }); _Requester = new RblRequester(); _DummyRequester = new DummyRequester(); }
public PlayerClient Create( IAssetClient assetClient, IRequestUrlBuilder requestUrlBuilder, IRequester requester, JsonSerializerSettings jsonApiSerializerSettings) { return(new PlayerClient(assetClient, requestUrlBuilder, requester, jsonApiSerializerSettings)); }
public GuestHandleFactory(IChannelFactory channelFactory) { ISerializer serializer = new ProtobufSerializer(); IChannel channel = channelFactory.CreateChannel(); // todo1[ak] check args _requester = new Requester(serializer, channel); }
/// <summary> /// Inicializa una nueva instancia de la clase <see cref="AspenRequest" />. /// </summary> /// <param name="requester">Instancia del solicitante.</param> /// <param name="url">URL del recurso solicitado.</param> /// <param name="method">Método o verbo HTTP para invocar el recurso.</param> /// <param name="addRequiredHeaders">Cuando es <see langword="true" /> se llama al método AddRequiredHeaders.</param> internal AspenRequest(IRequester requester, string url, Method method, bool addRequiredHeaders = true) : this(requester.AppScope, url, method, requester.DeviceInfo) { if (addRequiredHeaders) { requester.AddRequiredHeaders(this, null); } }
/// <summary> /// Loads the given URI by using an asynchronous GET request. /// </summary> /// <param name="requester">The requester to use.</param> /// <param name="url">The url that yields the path to the desired action.</param> /// <param name="cancel">The token which can be used to cancel the request.</param> /// <returns>The task which will eventually return the response.</returns> public static Task <IResponse> LoadAsync(this IRequester requester, Url url, CancellationToken cancel) { return(requester.RequestAsync(new DefaultRequest { Address = url, Method = HttpMethod.Get }, cancel)); }
public void TestInitialize() { _TestRbl = 147; _TestRblSet = new HashSet<int>(new int[]{7,8,9}); _Requester = new RblRequester(); _DummyRequester = new DummyRequester(); }
private void GetConverterDependencies() { _isoCodeHelper = new IsoCodeHelper(); _requester = new RateRequester(); _rateInteractor = new RateInteractor(_isoCodeHelper, _requester); _rateAdapter = new RateAdapter(_rateInteractor); }
public StatusRiotApi(IRequester requester) { if (requester == null) { throw new ArgumentNullException(nameof(requester)); } this.requester = requester; }
/// <summary> /// Initializes a new instance of the <see cref="StaticEndpointBase"/> class. /// </summary> /// <param name="requester">The requester.</param> /// <param name="cache">The cache.</param> /// <param name="slidingExpirationTime">The sliding expiration time.</param> /// <param name="useHttps">if set to <c>true</c> [use HTTPS].</param> protected StaticEndpointBase(IRequester requester, ICache cache, TimeSpan?slidingExpirationTime, bool useHttps = true) { this.requester = requester; this.cache = cache; this.useHttps = useHttps; this.SlidingExpirationTime = slidingExpirationTime ?? DefaultSlidingExpirationTime; }
protected AccountServiceProxyBase(Type interfaceType, IRequester requester) : base(interfaceType, requester) { if (!typeof(IAccountService).IsAssignableFrom(interfaceType)) { throw new ArgumentException(); // todo2[ak] } }
public MessageConsumer(string hostName, string exchangeName, string queueName, string routingKey, IRequester requester) { HostName = hostName; ExchangeName = exchangeName; QueueName = queueName; RoutingKey = routingKey; Requester = requester; InitializeExchange(); }
public FinamHistoryProvider(IRequester req, IConfig config, ILogger <FinamHistoryProvider> logger) { _tfds = new List <TimeframeData>(); _tickers = new List <TickerData>(); _baseUrl = ""; _requester = req; _config = config; _logger = logger; }
internal MatchClient( IRequestUrlBuilder builder, IRequester requester, JsonSerializerSettings jsonSerializerSettings) { this.builder = builder; this.requester = requester; this.jsonSerializerSettings = jsonSerializerSettings; }
/// <summary> /// Adds the given requester. /// </summary> /// <param name="requester">The requester to register.</param> /// <returns>The current instance for chaining.</returns> public Configuration Register(IRequester requester) { if (requester == null) { throw new ArgumentNullException("requester"); } _requesters.Add(requester); return(this); }
public XIVApi(IRequester requester, ICache cache = null) { if (requester == null) { throw new ArgumentNullException(nameof(requester)); } _cache = cache ?? new PassThroughCache(); Character = new CharacterEndpoint(requester, _cache); }
public BaseSetupClass() { var httpClient = new HttpClient() { BaseAddress = new Uri(BaseUrl), Timeout = new TimeSpan(0, 10, 0) }; requester = new Requester(httpClient); }
public DruidClient(IJsonSerializer jsonSerializer, string hostName, int port = 8082, string apiEndpoint = "druid/v2") { _configurationOptions = new ConfigurationOptions { JsonSerializer = jsonSerializer, QueryApiBaseAddress = new Uri($"{hostName}:{port}"), QueryApiEndpoint = apiEndpoint, }; _requester = new Requester(_configurationOptions); }
/// <summary> /// Performs a potentially CORS-enabled fetch from the given URI by using an asynchronous GET request. /// </summary> /// <param name="requester">The requester to use.</param> /// <param name="url">The url that yields the path to the desired action.</param> /// <param name="cors">The cross origin settings to use.</param> /// <param name="origin">The origin of the page that requests the loading.</param> /// <param name="defaultBehavior">The default behavior in case it is undefined.</param> /// <param name="cancel">The token which can be used to cancel the request.</param> /// <returns>The task which will eventually return the stream.</returns> public static Task <IResponse> LoadWithCorsAsync(this IRequester requester, Url url, CorsSetting cors, String origin, OriginBehavior defaultBehavior, CancellationToken cancel) { //TODO //http://www.w3.org/TR/html5/infrastructure.html#potentially-cors-enabled-fetch return(requester.RequestAsync(new DefaultRequest { Address = url, Method = HttpMethod.Get }, cancel)); }
/// <summary> /// Create a client using the given IRequester. This gives you the greatest ability to customise functionality /// </summary> /// <param name="type">Interface representing the API</param> /// <param name="requester">IRequester to use</param> /// <returns>An implementation of that interface which you can use to invoke the API</returns> public static object For(Type type, IRequester requester) { if (type == null) { throw new ArgumentNullException(nameof(type)); } var method = forStaticGenericMethodInfo.MakeGenericMethod(type); return(method.Invoke(null, new object[] { requester })); }
/// <summary> /// Adds a loader service that comes with all (improved) requesters. /// </summary> /// <param name="configuration">The configuration to use.</param> /// <param name="httpMessageHandler"> /// The HTTP handler stack to use for sending requests. /// </param> /// <param name="setup">Optional setup for the loader service.</param> /// <returns>The new configuration.</returns> public static IConfiguration WithRequesters(this IConfiguration configuration, HttpMessageHandler httpMessageHandler, Action<ConfigurationExtensions.LoaderSetup> setup = null) { var httpClient = new HttpClient(httpMessageHandler); var requesters = new IRequester[] { new HttpClientRequester(httpClient), new DataRequester(), new FtpRequester(), new FileRequester(), new AboutRequester() }; return configuration.WithDefaultLoader(setup, requesters); }
public static IAppClient CreateAppClient(IRequester requester) { IAppClient client = new SimpleAppClient( requester, new Dictionary<Type, object> { {typeof(IGuestService), new GuestServiceProxy(requester)}, {typeof(IAdminService), new AdminServiceProxy(requester)}, {typeof(IUserService), new UserServiceProxy(requester)}, }); return client; }
protected ServiceProxyBase(Type interfaceType, IRequester requester) { if (interfaceType == null) { throw new ArgumentNullException("interfaceType"); } if (!interfaceType.IsInterface) { throw new ArgumentException(); // todo2[ak] } if (requester == null) { throw new ArgumentNullException("requester"); } _serviceName = interfaceType.FullName; _requester = requester; }
public RepeatWarmer(IConfig config, IRequester requester, ILogger logger, int timesToRepeat) : base(config, requester, logger) { _timesToRepeat = timesToRepeat; _numberOfRuns = 0; }
public DoneDealApi(IRequester webRequester) : base(webRequester, BaseUrl) { }
public ApiBase(IRequester webRequester, string baseUrl) { Requester = webRequester; Requester.SetBaseUrl(baseUrl); }
public GameEngine(IUserInterface userInterface, ICommandManager commandManager, IRequester requester) { this.UserInterface = userInterface; this.CommandManager = commandManager; this.Requester = requester; }
/// <summary> /// Konstruktur /// </summary> /// <param name="requester">Antragsteller</param> /// <param name="password">Paßwort mit dem der private RSA-Schlüssel verschlüsselt werden soll</param> public Pkcs10Creator(IRequester requester, string password) { Requester = requester; Password = password; }
/// <summary> /// Konstruktor /// </summary> /// <param name="requester">Antragsteller</param> /// <param name="rsa">RSA-Schlüssel</param> public Pkcs10Creator(IRequester requester, AsymmetricCipherKeyPair rsa) { Requester = requester; RSA = rsa; }
internal AdminServiceProxy(IRequester requester) : base(typeof(IAdminService), requester) { }
public async Task HttpRequesterShouldNotHang() { if (Helper.IsNetworkAvailable()) { var address = "https://serverspace.ae"; var requesters = new IRequester[] { new DataRequester(), new HttpRequester() }; var cts = new CancellationTokenSource(); var config = Configuration.Default.WithCss().WithDefaultLoader(c => c.IsResourceLoadingEnabled = true, requesters); var context = BrowsingContext.New(config); var url = Url.Create(address); var document = await context.OpenAsync(url, cts.Token); Assert.IsNotNull(document); } }
public CommandExecutor(IRequester httpRequester, IConsoleOperator consoleOperator) { this.ConsoleOperator = consoleOperator; this.Requester = httpRequester; }
public void SetUp() { _requester = new Requester(); }
/// <summary> /// Instantiate new Warmer /// </summary> /// <param name="config">Configuraton of Check</param> /// <param name="requester">HTTP requester</param> /// <param name="logger">Logging strategy for Warmer</param> public Warmer(IConfig config, IRequester requester, ILogger logger) { _config = config; _warmer = new CustomWarmer(config, requester); _logger = logger; }
/// <summary> /// Creates a new event for starting a request. /// </summary> /// <param name="requester">The associated requester.</param> /// <param name="request">The data of the request.</param> public RequestStartEvent(IRequester requester, IRequest request) { Requester = requester; Request = request; }
internal UserServiceProxy(IRequester requester) : base(typeof(IUserService), requester) { }
public CustomWarmer(IConfig config, IRequester requester) { _config = config; _requester = requester; }
public CarsIrelandApi(IRequester requester) : base(requester, BaseUrl) { }
public Warmer(IConfig config, IRequester requester, ILogger logger) { _config = config; _requester = requester; _logger = logger; }
internal WagenGuestServiceProxy(IRequester requester) : base(typeof(IWagenGuestService), requester) { }
public static Warmer Create(Options options, IConfig config, IRequester requester, ILogger logger) { return options.Retries > 1 ? new RepeatWarmer(config, requester, logger, options.Retries) : new Warmer(config, requester, logger); }