public static object GetProxy(this IProxyProvider proxyProvider, Type interfaceType, Type classType) { if (interfaceType == null) { throw new ArgumentNullException(nameof(interfaceType)); } if (classType == null) { throw new ArgumentNullException(nameof(classType)); } return(proxyProvider.GetProxy(interfaceType, classType, (object[])null)); }
/// <summary> /// Initializes a new instance of the <see cref="JobsDataFromTalentLink" /> class. /// </summary> /// <param name="searchUrl">The search URL.</param> /// <param name="lookupValuesParser">The parser for lookup values in the TalentLink HTML.</param> /// <param name="proxy">The proxy (optional).</param> /// <exception cref="System.ArgumentNullException">sourceUrl</exception> public JobsLookupValuesFromTalentLink(Uri searchUrl, IJobLookupValuesParser lookupValuesParser, IProxyProvider proxy) { if (searchUrl == null) { throw new ArgumentNullException(nameof(searchUrl)); } if (lookupValuesParser == null) { throw new ArgumentNullException(nameof(lookupValuesParser)); } _searchUrl = searchUrl; _lookupValuesParser = lookupValuesParser; _proxy = proxy; }
public Application(ISearchEngine searchEngine, IProxyChecker checker, IHttpDownloaderContainer httpDownloaderContainer, IGeoIP geoIP = null, IProxyProvider proxyProvider = null, ITaskManager taskManager = null) { this.searchEngine = searchEngine; this.checker = checker; this.httpDownloaderContainer = httpDownloaderContainer; this.proxyProvider = proxyProvider ?? new ProxyProvider(); this.geoIP = geoIP ?? new TurnOffGeoIP(); this.taskManager = taskManager ?? new TaskManager(); }
public ProxyAuthenticationHandler(HttpClientHandler httpClientHandler, IProxyProvider proxyProvider) : base(httpClientHandler) { if (httpClientHandler == null) { throw new ArgumentNullException(nameof(httpClientHandler)); } if (proxyProvider == null) { throw new ArgumentNullException(nameof(proxyProvider)); } _clientHandler = httpClientHandler; _proxyProvider = proxyProvider; }
/// <summary> /// Initializes a new instance of the <see cref="LocateApiAddressLookup" /> class. /// </summary> /// <param name="locateApiUrl">The locate API URL.</param> /// <param name="authenticationToken">The authentication token.</param> /// <param name="proxyProvider">The proxy provider.</param> /// <exception cref="System.ArgumentNullException">authenticationToken</exception> public LocateApiAddressLookup(Uri locateApiUrl, string authenticationToken, IProxyProvider proxyProvider) { if (locateApiUrl == null) { throw new ArgumentNullException(nameof(locateApiUrl)); } if (String.IsNullOrEmpty(authenticationToken)) { throw new ArgumentNullException(nameof(authenticationToken)); } _locateApiUrl = locateApiUrl; _authenticationToken = authenticationToken; _proxyProvider = proxyProvider; }
public TelegramBot(ISettingsProvider settingsProvider, IProxyProvider proxyProvider = null) { _settingsProvider = settingsProvider; _proxyProvider = proxyProvider; _log = LogFactory.GetLog(GetType()); _settings = _settingsProvider.GetSettings().Telegram; _masterChatID = _settings.MasterChatID; _client = new TelegramBotClient(_settings.BotToken); _client.OnMessage += BotOnMessage; _client.OnCallbackQuery += BotCallbackQuery; _client.OnReceiveError += BotReceiveError; _client.OnReceiveGeneralError += BotReceiveGeneralError; }
public ProxyWorker( ISettingsService <CashlogSettings> cashlogSettingsService, IWorkerController workerController, IProxyProvider proxyProvider, ILogger logger, IProxyConsumer[] proxyConsumers) { _cashlogSettingsService = cashlogSettingsService ?? throw new ArgumentNullException(nameof(cashlogSettingsService)); _proxyProvider = proxyProvider ?? throw new ArgumentNullException(nameof(proxyProvider)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _proxyConsumers = proxyConsumers ?? throw new ArgumentNullException(nameof(proxyConsumers)); _cachedProxies = new Queue <WebProxy>(); _lastWorkingWebProxy = null; _worker = workerController.CreateWorker(() => RevalidateProxy().GetAwaiter().GetResult(), _proxyRevalidateInterval, true); }
public Application(ISearchEngine searchEngine, IProxyChecker checker, IHttpDownloaderContainer httpDownloaderContainer, IGeoIP geoIP = null, IRatingManager ratingManager = null, IProxyProvider proxyProvider = null, ITaskManager taskManager = null) { this.searchEngine = searchEngine; this.checker = checker; this.httpDownloaderContainer = httpDownloaderContainer; this.proxyProvider = proxyProvider ?? new ProxyProvider(); this.geoIP = geoIP ?? new TurnOffGeoIP(); this.taskManager = taskManager ?? new TaskManager(); this.ratingManager = ratingManager ?? new DisabledRatingManager(); }
public static IntPtr CreateDispatchProxy(IntPtr pOuter, IPseudoDispatch proxy) { IntPtr zero = IntPtr.Zero; IProxyProvider proxyProvider = proxySupport.GetProxyProvider(); if (proxyProvider == null) { throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL"); } int errorCode = proxyProvider.CreateDispatchProxyInstance(pOuter, proxy, out zero); Marshal.ReleaseComObject(proxyProvider); if (errorCode != HR.S_OK) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(System.ServiceModel.SR.GetString("FailedProxyProviderCreation"), errorCode)); } return(zero); }
public static IntPtr CreateOuterProxyInstance(IProxyManager proxyManager, ref Guid riid) { IntPtr zero = IntPtr.Zero; IProxyProvider proxyProvider = proxySupport.GetProxyProvider(); if (proxyProvider == null) { throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL"); } Guid guid = riid; int errorCode = proxyProvider.CreateOuterProxyInstance(proxyManager, ref guid, out zero); Marshal.ReleaseComObject(proxyProvider); if (errorCode != HR.S_OK) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(System.ServiceModel.SR.GetString("FailedProxyProviderCreation"), errorCode)); } return(zero); }
public Devourer(List<DevourTarget> initialTargets, IProxyProvider proxies, IPageValidator validator = null) { if (initialTargets == null || initialTargets.Count == 0 /*|| reader == null */ || proxies == null) throw new ArgumentException("Bad arguments"); PreventSimilarTargetDownload = false; CookieOptions = CookieOptions.Empty; _proxies = proxies; _validator = validator; _successTargets = new List<Uri>(); _faultTargets = new List<DevourTarget>(); _allTargets = new HashSet<string>(); InitializeStartTargets(initialTargets); SubscribeProxyProvider(); }
public ApiPortService(string endpoint, ProductInformation info, IProxyProvider proxyProvider) { if (string.IsNullOrWhiteSpace(endpoint)) { throw new ArgumentOutOfRangeException(nameof(endpoint), endpoint, LocalizedStrings.MustBeValidEndpoint); } if (proxyProvider == null) { throw new ArgumentNullException(nameof(proxyProvider)); } // Create the URI directly from a string (rather than using a hard-coded scheme or port) because // even though production use of ApiPort should always use HTTPS, developers using a non-production // portability service URL (via the -e command line parameter) may need to specify a different // scheme or port. var uri = new Uri(endpoint); var proxy = proxyProvider.GetProxy(uri); // replace the handler with the proxy aware handler var clientHandler = new HttpClientHandler { #if !FEATURE_SERVICE_POINT_MANAGER SslProtocols = CompressedHttpClient.SupportedSSLProtocols, #endif Proxy = proxy, AutomaticDecompression = (DecompressionMethods.GZip | DecompressionMethods.Deflate) }; // HTTP handler pipeline can be injected here, around the client handler HttpMessageHandler messageHandler = clientHandler; if (proxy != null) { messageHandler = new ProxyAuthenticationHandler(clientHandler, proxyProvider); } _client = new CompressedHttpClient(info, messageHandler) { BaseAddress = new Uri(endpoint), Timeout = Timeout }; }
public static IntPtr CreateDispatchProxy(IntPtr pOuter, IPseudoDispatch proxy) { IntPtr pInner = IntPtr.Zero; IProxyProvider proxyProvider = proxySupport.GetProxyProvider(); if (proxyProvider == null) { throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL"); } int hr = proxyProvider.CreateDispatchProxyInstance(pOuter, proxy, out pInner); Marshal.ReleaseComObject(proxyProvider); if (hr != HR.S_OK) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(SR.GetString(SR.FailedProxyProviderCreation), hr)); } return(pInner); }
public static IntPtr CreateOuterProxyInstance(IProxyManager proxyManager, ref Guid riid) { IntPtr pOuter = IntPtr.Zero; IProxyProvider proxyProvider = proxySupport.GetProxyProvider(); if (proxyProvider == null) { throw Fx.AssertAndThrowFatal("Proxy Provider cannot be NULL"); } Guid riid2 = riid; int hr = proxyProvider.CreateOuterProxyInstance(proxyManager, ref riid2, out pOuter); Marshal.ReleaseComObject(proxyProvider); if (hr != HR.S_OK) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new COMException(SR.GetString(SR.FailedProxyProviderCreation), hr)); } return(pOuter); }
/// <summary> /// Initializes a new instance of the <see cref="JobsDataFromTribePad" /> class. /// </summary> /// <param name="lookupValuesApiUrl">The search URL.</param> /// <param name="builtInLookupValuesParser">The parser for lookup values in built-in fields in the TribePad XML.</param> /// <param name="customFieldLookupValuesParser">The parser for lookup values in custom fields in the TribePad XML.</param> /// <param name="workPatternSplitter">A way to return work patterns that represent multiple values as multiple patterns; <c>null</c> if not required</param> /// <param name="proxy">The proxy (optional).</param> /// <exception cref="System.ArgumentNullException">lookupValuesApiUrl</exception> /// <exception cref="System.ArgumentNullException">builtInLookupValuesParser</exception> /// <exception cref="System.ArgumentNullException">customFieldLookupValuesParser</exception> public JobsLookupValuesFromTribePad(Uri lookupValuesApiUrl, IJobLookupValuesParser builtInLookupValuesParser, IJobLookupValuesParser customFieldLookupValuesParser, IWorkPatternSplitter workPatternSplitter, IProxyProvider proxy) { if (lookupValuesApiUrl == null) { throw new ArgumentNullException(nameof(lookupValuesApiUrl)); } if (builtInLookupValuesParser == null) { throw new ArgumentNullException(nameof(builtInLookupValuesParser)); } if (customFieldLookupValuesParser == null) { throw new ArgumentNullException(nameof(customFieldLookupValuesParser)); } _lookupValuesApiUrl = lookupValuesApiUrl; _builtInLookupValuesParser = builtInLookupValuesParser; _customFieldLookupValuesParser = customFieldLookupValuesParser; _workPatternSplitter = workPatternSplitter; _proxy = proxy; }
public Devourer(List <DevourTarget> initialTargets, IProxyProvider proxies, IPageValidator validator = null) { if (initialTargets == null || initialTargets.Count == 0 /*|| reader == null */ || proxies == null) { throw new ArgumentException("Bad arguments"); } PreventSimilarTargetDownload = false; CookieOptions = CookieOptions.Empty; _proxies = proxies; _validator = validator; _successTargets = new List <Uri>(); _faultTargets = new List <DevourTarget>(); _allTargets = new HashSet <string>(); InitializeStartTargets(initialTargets); SubscribeProxyProvider(); }
/// <summary> /// Creates a new <see cref="HttpWebRequest"/> for the specified URI, with proxy access configured. /// </summary> /// <param name="requestUri">The request URI.</param> /// <returns></returns> public HttpWebRequest CreateRequest(Uri requestUri, IProxyProvider proxyProvider) { var webRequest = (HttpWebRequest)WebRequest.Create(requestUri); webRequest.UserAgent = "Escc.Net.HttpRequestClient"; // Some apps require a user-agent to be present if (proxyProvider != null) { IWebProxy proxy = proxyProvider.CreateProxy(); if (proxy != null) { webRequest.Proxy = proxy; webRequest.Credentials = proxy.Credentials; } else { webRequest.Credentials = CredentialCache.DefaultCredentials; } } else { webRequest.Credentials = CredentialCache.DefaultCredentials; } return(webRequest); }
public SettingsController(IHostingEnvironment hostingEnvironment, IOptionsSnapshot <ProxySettings> proxySettings, IProxyProvider proxyProvider) { _proxySettings = proxySettings.Value; _hostingEnvironment = hostingEnvironment; _proxyProvider = proxyProvider; }
internal IProxyProvider GetProxyProvider() { if (null == monikerSupportLibrary) { lock (this) { if (null == monikerSupportLibrary) { getCODelegate = null; using (RegistryHandle regKey = RegistryHandle.GetCorrectBitnessHKLMSubkey((IntPtr.Size == 8), ServiceModelInstallStrings.WinFXRegistryKey)) { string file = regKey.GetStringValue(ServiceModelInstallStrings.RuntimeInstallPathName).TrimEnd('\0') + "\\" + fileName; SafeLibraryHandle tempLibrary = UnsafeNativeMethods.LoadLibrary(file); tempLibrary.DoNotFreeLibraryOnRelease(); monikerSupportLibrary = tempLibrary; if (monikerSupportLibrary.IsInvalid) { monikerSupportLibrary.SetHandleAsInvalid(); throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(Error.ServiceMonikerSupportLoadFailed(file)); } } } } } if (null == getCODelegate) { lock (this) { if (null == getCODelegate) { try { IntPtr procaddr = UnsafeNativeMethods.GetProcAddress(monikerSupportLibrary, functionName); getCODelegate = (DelegateDllGetClassObject)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(DelegateDllGetClassObject)); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ComPlusProxyProviderException(SR.GetString(SR.FailedProxyProviderCreation), e)); } } } } IClassFactory cf = null; IProxyProvider proxyProvider = null; try { getCODelegate(ClsidProxyInstanceProvider, typeof(IClassFactory).GUID, ref cf); proxyProvider = cf.CreateInstance(null, typeof(IProxyProvider).GUID) as IProxyProvider; Thread.MemoryBarrier(); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ComPlusProxyProviderException(SR.GetString(SR.FailedProxyProviderCreation), e)); } finally { if (null != cf) { Marshal.ReleaseComObject(cf); cf = null; } } return(proxyProvider); }
/// <summary> /// Initializes a new instance of the <see cref="GoogleCustomSearch" /> class. /// </summary> /// <param name="apiKey">The API key.</param> /// <param name="searchEngineId">The Google search engine id.</param> /// <param name="proxyProvider">The provider for proxy details for making the request to the API.</param> public GoogleCustomSearch(string apiKey, string searchEngineId, IProxyProvider proxyProvider) { _proxyProvider = proxyProvider; ApiKey = apiKey; SearchEngineId = searchEngineId; }
public void SetProxyProvider(IProxyProvider proxyProvider) { this._proxyProvider = proxyProvider; }
/// <summary> /// Initializes a new instance of the <see cref="JobsDataFromTalentLink" /> class. /// </summary> /// <param name="resultsUrl">The source URL.</param> /// <param name="advertUrl">The advert URL.</param> /// <param name="jobResultsParser">The job results parser.</param> /// <param name="jobAdvertParser">The job advert parser.</param> /// <param name="proxy">The proxy (optional).</param> /// <param name="saveHtml">Save a copy of the TalentLink HTML to App_Data</param> /// <exception cref="System.ArgumentNullException">sourceUrl</exception> public JobsDataFromTalentLink(Uri resultsUrl, Uri advertUrl, IJobResultsParser jobResultsParser, IJobAdvertParser jobAdvertParser, IProxyProvider proxy, bool saveHtml) { _resultsUrl = resultsUrl; _advertUrl = advertUrl; _proxy = proxy; _jobResultsParser = jobResultsParser; _jobAdvertParser = jobAdvertParser; _saveHtml = saveHtml; }
public object MarshalNativeToManaged(IntPtr pNativeData) { IProxyProvider prov = (IProxyProvider)Marshal.GetObjectForIUnknown(pNativeData); return(new ComProxy(prov).GetTransparentProxy()); }
public static object GetProxy(IProxyProvider provider) { return(new ComProxy(provider).GetTransparentProxy()); }
public ComProxy(IProxyProvider provider) : base(provider.Type == typeof(object) ? typeof(MarshalByRefObject) : provider.Type) { Provider = provider; }
/// <summary> /// /// </summary> /// <param name="proxyProvider"></param> public void SetProxyProvider(IProxyProvider proxyProvider) { this.httpClientDownloader.SetProxyProvider(proxyProvider); }
/// <summary> 创建代理 </summary> /// <param name="interfaceType"></param> /// <param name="baseType"></param> /// <param name="proxyProvider"></param> /// <param name="key"></param> /// <returns></returns> public object CreateProxy(Type interfaceType, Type baseType, IProxyProvider proxyProvider, object key = null) { var proxiedType = GetProxyType(baseType, interfaceType); return(Activator.CreateInstance(proxiedType, proxyProvider, key, new ProxyHandler(this))); }
public ApiPortService(string endpoint, ProductInformation info, IProxyProvider proxyProvider = null) : this(endpoint, BuildMessageHandler(endpoint, proxyProvider), info) { }
public ProxyExecutor(IProxyProvider provider, object serviceKey = null) { _proxyProvider = provider; _serviceKey = serviceKey; }
public static TClass GetProxy <TClass>(this IProxyProvider proxyProvider, params object[] parameters) where TClass : class { return(proxyProvider.GetProxy(typeof(TClass), parameters) as TClass); }
public static TClass GetProxy <TClass>(this IProxyProvider proxyProvider) where TClass : class { return(proxyProvider.GetProxy(typeof(TClass), (object[])null) as TClass); }
public GoogleAnalyticsKeywordSource(IProxyProvider proxyProvider) { _proxyProvider = proxyProvider; }
public static TInterface GetProxy <TInterface, TClass>(this IProxyProvider proxyProvider, params object[] parameters) where TInterface : class where TClass : TInterface { return(proxyProvider.GetProxy(typeof(TInterface), typeof(TClass), parameters) as TInterface); }
//RequestParams _params; public Devourer(DevourTarget initialTarget, IProxyProvider proxies, IPageValidator validator = null) : this(new List<DevourTarget>(new DevourTarget[] { initialTarget }), proxies, validator) { }