Example #1
0
        private static void Main(string[] args)
        {

            //new design
            //simple
            var service = new ProxyService();
            service.BeforeCall += (p) =>
            {
                Console.WriteLine("Before Call");
            };
            service.AfterCall += (p) =>
            {
                Console.WriteLine("After Call");
                if (p.ProxiedMethod.Name.IndexOf("Name") != -1)
                    p.ReturnValue = 100;
            };
            var item = service.Create<TestWrapper>();
            item.GetAll(1, "213");
            item.Name = 5;
            item.Name1 = null;
            Console.WriteLine(item.Name);

            //service.AfterCall = () => { Console.WriteLine("After Call2"); };
            //var item2 = service.Create<TestWrapper2>();
            //item2.Test("213");
        }
Example #2
0
        public Dashboard(ProxyService.ProxyService p)
        {
            this.proxy = p;

            InitializeComponent();
            this.doUpdate = true;
            this.updateThread = new Thread(new ThreadStart(this.updateServerList));
            this.updateThread.Start();
        }
        public void SetUp()
        {
            var mocker = new AutoMocker();
            dataManipulator = mocker.GetMock<IHmrcDataManipulator>();
            configRepository = mocker.GetMock<IConfigurationRepository>();
            messageSender = mocker.GetMock<IMessageSender>();

            messageSender.Setup(x => x.PostXml(It.IsAny<string>(), It.IsAny<string>())).Returns(GetPostResult());

            proxyService = mocker.CreateInstance<ProxyService>();
        }
 public void CrossDomainSampleTestWithSerializableClass()
 {
     try
     {
         ProxyService service = new ProxyService();
         var wrapper = service.Create<TestWrapper0>();
         wrapper.Test();
         Assert.Fail("should throw exception");
     }
     catch (Exception e)
     {
     }
 }
Example #5
0
 public MessageCreated(LastMessageCacheService lastMessageCache, LoggerCleanService loggerClean,
                       IMetrics metrics, ProxyService proxy,
                       CommandTree tree, ILifetimeScope services, IDatabase db, BotConfig config,
                       ModelRepository repo, IDiscordCache cache,
                       Bot bot, Cluster cluster, DiscordApiClient rest, PrivateChannelService dmCache)
 {
     _lastMessageCache = lastMessageCache;
     _loggerClean      = loggerClean;
     _metrics          = metrics;
     _proxy            = proxy;
     _tree             = tree;
     _services         = services;
     _db      = db;
     _config  = config;
     _repo    = repo;
     _cache   = cache;
     _bot     = bot;
     _cluster = cluster;
     _rest    = rest;
     _dmCache = dmCache;
 }
Example #6
0
        static async Task /*void*/ Main(string[] args)
        {
            LogManager log = new LogManager();

            log.Info("123");

            ServicePointManager.DefaultConnectionLimit = 200;

            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            ProxyService proxyService = new ProxyService();
            var          models       = proxyService.GetListByRemote();

            Console.WriteLine("远程获取IP总数:" + models.Count);
            var newmodels = proxyService.GetLiveData(models);

            stopwatch.Stop();
            Console.WriteLine("总数:" + newmodels.Count + "   耗时:" + stopwatch.Elapsed);
            foreach (var item in newmodels)
            {
                Console.WriteLine(item.ToString());
            }
            Console.Read();


            #region 延迟测试
            //Proxy_89ip p = new Utils.Proxy_89ip();
            //var ls = p.Parse(p.GetHtml());
            //ls.ForEach(item =>
            //{
            //    Task.Run(() =>
            //    {
            //        Console.WriteLine(HttpHelper.ProxyCheck(ref item)); ;
            //    });
            //});

            #endregion
            Console.Read();
        }
 public void Can_Proxy_Normal_Class()
 {
     ProxyService service = new ProxyService();
     service.BeforeCall += (p) =>
     {
         if (p.Method.Name == "TestParams")
         {
             Assert.AreEqual(p.Arguments[0].GetType(), typeof(int[]));
         }
     };
     service.AfterCall += (p) =>
     {
     };
     var ac = service.Create<Normal>();
     var r = ac.WithDuplexName(true, 1, "abc");
     ac.Do(5);
     ac.Do("abc");
     ac.Do(5, "abc");
     ac.Do(new object[] { });
     ac.TestParams(1, 2, 3);
     ac.Name = "Name";
 }
 public void Can_Proxy_Function_Class()
 {
     ProxyService service = new ProxyService();
     service.BeforeCall += (p) =>
     {
         Assert.AreEqual(2, p.Arguments.Length);
         Assert.AreEqual("aaa", p.Arguments[0]);
         Assert.AreEqual(100, p.Arguments[1]);
         p.Arguments[0] = p.Arguments[0] + "_BeforeCall_";
         p.Arguments[1] = (int)p.Arguments[1] + 100;
     };
     service.AfterCall += (p) =>
     {
         Assert.AreEqual("aaa_BeforeCall_200", p.ReturnValue);
         p.ReturnValue = p.ReturnValue + "_AfterCall";
     };
     var ac = service.Create<InheritClass>();
     var r = ac.Do("aaa", 100);
     Assert.AreEqual("aaa_BeforeCall_200_AfterCall", r);
     r = ac.DoNotProxy("aaa", 100);
     Assert.AreEqual("aaa100", r);
 }
Example #9
0
            public async Task OnStoppingServiceAsync(OperationContext context)
            {
                // Not passing cancellation token since it will already be signaled

                // WebHost is null for out-of-proc casaas case.
                if (WebHost != null)
                {
                    await WebHost.StopAsync();
                }

                if (ProxyService != null)
                {
                    await ProxyService.ShutdownAsync(context).IgnoreFailure();
                }

                if (ContentCacheService != null)
                {
                    await ContentCacheService.ShutdownAsync(context).IgnoreFailure();
                }

                WebHost?.Dispose();
            }
Example #10
0
        public async Task Start(string address, int port)
        {
            try
            {
                await Stop();

                Server = new Server
                {
                    Services = { ProxyService.BindService(this) },
                    Ports    = { new ServerPort(address, port, ServerCredentials.Insecure) }
                };
                Server.Start();
                SetListening(address, port);
                OnStart(address, port);
            }
            catch
            {
                Server = null;
                ResetListening();
                throw;
            }
        }
Example #11
0
        private async void goButton_Click(object sender, EventArgs e)
        {
            try
            {
                var text = decklistTextBox.Text;
                Cards              = ProxyService.ParseImport(text);
                messageLabel.Text  = "Running";
                loadingBox.Visible = true;
                await ProxyService.RunAsync(Cards, SavePath);

                loadingBox.Visible     = false;
                messageLabel.Text      = "Finished";
                messageLabel.ForeColor = Color.Green;
            }
            catch (Exception ex)
            {
                messageLabel.Text      = $"Error";
                messageLabel.ForeColor = Color.Red;
                loadingBox.Visible     = false;
                MessageBox.Show($"Error: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Cards = null;
            }
        }
Example #12
0
        public Route53(
            LookupClientProvider dnsClient,
            DomainParseService domainParser,
            ILogService log,
            ProxyService proxy,
            ISettingsService settings,
            Route53Options options)
            : base(dnsClient, log, settings)
        {
            var region = RegionEndpoint.USEast1;
            var config = new AmazonRoute53Config()
            {
                RegionEndpoint = region
            };

            config.SetWebProxy(proxy.GetWebProxy());
            _route53Client = !string.IsNullOrWhiteSpace(options.IAMRole)
                ? new AmazonRoute53Client(new InstanceProfileAWSCredentials(options.IAMRole), config)
                : !string.IsNullOrWhiteSpace(options.AccessKeyId) && !string.IsNullOrWhiteSpace(options.SecretAccessKey.Value)
                    ? new AmazonRoute53Client(options.AccessKeyId, options.SecretAccessKey.Value, config)
                    : new AmazonRoute53Client(config);
            _domainParser = domainParser;
        }
Example #13
0
            public async Task OnStartedServiceAsync(OperationContext context, ICacheServerServices cacheServices)
            {
                CacheServiceStartup.UseExternalServices(WebHostBuilder, context, HostParameters);

                WebHostBuilder.ConfigureServices(services =>
                {
                    if (ServiceConfiguration.ContentCache != null)
                    {
                        if (cacheServices.PushFileHandler != null && cacheServices.StreamStore != null)
                        {
                            services.AddSingleton <ContentCacheService>(sp =>
                            {
                                return(new ContentCacheService(
                                           ServiceConfiguration.ContentCache,
                                           cacheServices.PushFileHandler,
                                           cacheServices.StreamStore));
                            });
                        }
                    }
                });

                WebHost = WebHostBuilder.Build();
                ConfigurationSource.Configuration = WebHost.Services.GetService <ProxyServiceConfiguration>();

                // Get and start the DeploymentProxyService
                ProxyService        = WebHost.Services.GetService <DeploymentProxyService>();
                ContentCacheService = WebHost.Services.GetService <ContentCacheService>();

                await ProxyService.StartupAsync(context).ThrowIfFailureAsync();

                if (ContentCacheService != null)
                {
                    await ContentCacheService.StartupAsync(context).ThrowIfFailureAsync();
                }

                await WebHost.StartAsync(context.Token);
            }
Example #14
0
        /// <summary>
        /// Creates a new instance of Application
        /// <param name="enableProxyService">try to get a running application first before create a new application</param>
        /// </summary>
        public Application(Core factory = null, bool enableProxyService = false) : base()
        {
            object proxy = null;

            if (enableProxyService)
            {
                proxy = ProxyService.GetActiveInstance("Publisher", "Application", false);
                if (null != proxy)
                {
                    CreateFromProxy(proxy, true);
                    FromProxyService = true;
                }
            }

            if (null == proxy)
            {
                CreateFromProgId("Publisher.Application", true);
            }

            _callQuitInDispose = null == ParentObject;
            Factory            = null != factory ? factory : Core.Default;
            OnCreate();
            ModulesLegacy.ApplicationModule.Instance = this;
        }
Example #15
0
 public WebDav(
     WebDavOptions options, HttpValidationParameters pars,
     RunLevel runLevel, ProxyService proxy) :
     base(options, runLevel, pars) => _webdavClient = new WebDavClientWrapper(_options.Credential, pars.LogService, proxy);
 public SelfHosting(ScheduledRenewal renewal, Target target, string identifier, ILogService log, IInputService input, ProxyService proxy) :
     base(log, input, proxy, renewal, target, identifier)
 {
     try
     {
         var prefix = $"http://+:{target.ValidationPort ?? 80}/.well-known/acme-challenge/";
         _files    = new Dictionary <string, string>();
         _listener = new HttpListener();
         _listener.Prefixes.Add(prefix);
         _listener.Start();
         _listeningTask = Task.Run(RecieveRequests);
     }
     catch
     {
         _log.Error("Unable to activate HttpListener, this may be due to non-Microsoft webserver using port 80");
         throw;
     }
 }
Example #17
0
 public ProxyController(ProxyService proxyService)
 {
     _proxyService = proxyService;
 }
Example #18
0
        // Ribbon Loading event
        private void TexxtoorRibbon_Load(object sender, RibbonUIEventArgs e)
        {
            //Loading Items To Menus

            DDLBinding(1, Semantics.abbreviation);
            DDLBinding(1, Semantics.cite);
            DDLBinding(1, Semantics.definition);
            DDLBinding(1, Semantics.idiom);
            DDLBinding(1, Semantics.links);
            DDLBinding(1, Semantics.variable);
            String strResult = ProxyService.GetAllChapterIds();

            Globals.ThisAddIn.Application.WindowSelectionChange += new ApplicationEvents4_WindowSelectionChangeEventHandler(Application_WindowSelectionChange);
            if (_CurrentSelection.Font.Bold == 0)
            {
                toggleBtnBold.Checked = false;
            }
            else
            {
                toggleBtnBold.Checked = true;
            }
            if (_CurrentSelection.Font.Italic == 0)
            {
                toggleBtnItalic.Checked = false;
            }
            else
            {
                toggleBtnItalic.Checked = true;
            }
            if (_CurrentSelection.Font.Underline == WdUnderline.wdUnderlineNone)
            {
                toggleBtnUnderline.Checked = false;
            }
            else
            {
                toggleBtnUnderline.Checked = true;
            }
            if (_CurrentSelection.Font.StrikeThrough == 0)
            {
                toggleBtnStrikeThrough.Checked = false;
            }
            else
            {
                toggleBtnStrikeThrough.Checked = true;
            }
            if (_CurrentSelection.Paragraphs.Alignment != WdParagraphAlignment.wdAlignParagraphLeft)
            {
                toggleBtnAlignLeft.Checked = false;
            }
            else
            {
                toggleBtnAlignLeft.Checked = true;
            }
            if (_CurrentSelection.Paragraphs.Alignment != WdParagraphAlignment.wdAlignParagraphCenter)
            {
                toggleBtnAlignCenter.Checked = false;
            }
            else
            {
                toggleBtnAlignCenter.Checked = true;
            }
            if (_CurrentSelection.Paragraphs.Alignment != WdParagraphAlignment.wdAlignParagraphRight)
            {
                toggleBtnAlignRight.Checked = false;
            }
            else
            {
                toggleBtnAlignRight.Checked = true;
            }
            //15Oct Added
            if (_CurrentSelection.Range.ListFormat.ListType == WdListType.wdListBullet)
            {
                toggleButtonBullets.Checked = true;
            }
            else
            {
                toggleButtonBullets.Checked = false;
            }
            if (_CurrentSelection.Range.ListFormat.ListType == WdListType.wdListOutlineNumbering)
            {
                toggleButtonNumbering.Checked = true;
            }
            else
            {
                toggleButtonNumbering.Checked = false;
            }
        }
Example #19
0
        public INdmConsumerServices Init(INdmServices services)
        {
            AddDecoders();
            var logManager = services.RequiredServices.LogManager;
            var logger     = logManager.GetClassLogger();

            var disableSendingDepositTransaction  = HasEnabledVariable("SENDING_DEPOSIT_TRANSACTION_DISABLED");
            var instantDepositVerificationEnabled = HasEnabledVariable("INSTANT_DEPOSIT_VERIFICATION_ENABLED");
            var backgroundServicesDisabled        = HasEnabledVariable("BACKGROUND_SERVICES_DISABLED");

            if (disableSendingDepositTransaction)
            {
                if (logger.IsWarn)
                {
                    logger.Warn("*** NDM sending deposit transaction is disabled ***");
                }
            }

            if (instantDepositVerificationEnabled)
            {
                if (logger.IsWarn)
                {
                    logger.Warn("*** NDM instant deposit verification is enabled ***");
                }
            }

            if (backgroundServicesDisabled)
            {
                if (logger.IsWarn)
                {
                    logger.Warn("*** NDM background services are disabled ***");
                }
            }

            var ndmConfig       = services.RequiredServices.NdmConfig;
            var configId        = ndmConfig.Id;
            var dbConfig        = services.RequiredServices.ConfigProvider.GetConfig <IDbConfig>();
            var contractAddress = string.IsNullOrWhiteSpace(ndmConfig.ContractAddress)
                ? Address.Zero
                : new Address(ndmConfig.ContractAddress);
            var rocksDbProvider = new ConsumerRocksDbProvider(services.RequiredServices.BaseDbPath, dbConfig,
                                                              logManager);
            var depositDetailsRlpDecoder  = new DepositDetailsDecoder();
            var depositApprovalRlpDecoder = new DepositApprovalDecoder();
            var receiptRlpDecoder         = new DataDeliveryReceiptDetailsDecoder();
            var sessionRlpDecoder         = new ConsumerSessionDecoder();
            var receiptRequestValidator   = new ReceiptRequestValidator(logManager);

            IDepositDetailsRepository          depositRepository;
            IConsumerDepositApprovalRepository depositApprovalRepository;
            IProviderRepository        providerRepository;
            IReceiptRepository         receiptRepository;
            IConsumerSessionRepository sessionRepository;

            switch (ndmConfig.Persistence?.ToLowerInvariant())
            {
            case "mongo":
                var database = services.RequiredServices.MongoProvider.GetDatabase();
                depositRepository         = new DepositDetailsMongoRepository(database);
                depositApprovalRepository = new ConsumerDepositApprovalMongoRepository(database);
                providerRepository        = new ProviderMongoRepository(database);
                receiptRepository         = new ReceiptMongoRepository(database, "consumerReceipts");
                sessionRepository         = new ConsumerSessionMongoRepository(database);
                break;

            case "memory":
                if (logger.IsWarn)
                {
                    logger.Warn("*** NDM is using in memory database ***");
                }
                var depositsDatabase = new DepositsInMemoryDb();
                depositRepository         = new DepositDetailsInMemoryRepository(depositsDatabase);
                depositApprovalRepository = new ConsumerDepositApprovalInMemoryRepository();
                providerRepository        = new ProviderInMemoryRepository(depositsDatabase);
                receiptRepository         = new ReceiptInMemoryRepository();
                sessionRepository         = new ConsumerSessionInMemoryRepository();
                break;

            default:
                depositRepository = new DepositDetailsRocksRepository(rocksDbProvider.DepositsDb,
                                                                      depositDetailsRlpDecoder);
                depositApprovalRepository = new ConsumerDepositApprovalRocksRepository(
                    rocksDbProvider.ConsumerDepositApprovalsDb, depositApprovalRlpDecoder);
                providerRepository = new ProviderRocksRepository(rocksDbProvider.DepositsDb,
                                                                 depositDetailsRlpDecoder);
                receiptRepository = new ReceiptRocksRepository(rocksDbProvider.ConsumerReceiptsDb,
                                                               receiptRlpDecoder);
                sessionRepository = new ConsumerSessionRocksRepository(rocksDbProvider.ConsumerSessionsDb,
                                                                       sessionRlpDecoder);
                break;
            }

            var requiredBlockConfirmations = ndmConfig.BlockConfirmations;
            var abiEncoder                = services.CreatedServices.AbiEncoder;
            var blockchainBridge          = services.CreatedServices.BlockchainBridge;
            var blockProcessor            = services.RequiredServices.BlockProcessor;
            var configManager             = services.RequiredServices.ConfigManager;
            var consumerAddress           = services.CreatedServices.ConsumerAddress;
            var cryptoRandom              = services.RequiredServices.CryptoRandom;
            var depositService            = services.CreatedServices.DepositService;
            var gasPriceService           = services.CreatedServices.GasPriceService;
            var ecdsa                     = services.RequiredServices.Ecdsa;
            var ethRequestService         = services.RequiredServices.EthRequestService;
            var jsonRpcNdmConsumerChannel = services.CreatedServices.JsonRpcNdmConsumerChannel;
            var ndmNotifier               = services.RequiredServices.Notifier;
            var nodePublicKey             = services.RequiredServices.Enode.PublicKey;
            var timestamper               = services.RequiredServices.Timestamper;
            var wallet                    = services.RequiredServices.Wallet;
            var httpClient                = services.RequiredServices.HttpClient;
            var jsonRpcClientProxy        = services.RequiredServices.JsonRpcClientProxy;
            var ethJsonRpcClientProxy     = services.RequiredServices.EthJsonRpcClientProxy;
            var transactionService        = services.CreatedServices.TransactionService;
            var monitoringService         = services.RequiredServices.MonitoringService;

            monitoringService?.RegisterMetrics(typeof(Metrics));

            var dataRequestFactory     = new DataRequestFactory(wallet, nodePublicKey);
            var transactionVerifier    = new TransactionVerifier(blockchainBridge, requiredBlockConfirmations);
            var depositUnitsCalculator = new DepositUnitsCalculator(sessionRepository, timestamper);
            var depositProvider        = new DepositProvider(depositRepository, depositUnitsCalculator, logManager);
            var kycVerifier            = new KycVerifier(depositApprovalRepository, logManager);
            var consumerNotifier       = new ConsumerNotifier(ndmNotifier);

            var dataAssetService   = new DataAssetService(providerRepository, consumerNotifier, logManager);
            var providerService    = new ProviderService(providerRepository, consumerNotifier, logManager);
            var dataRequestService = new DataRequestService(dataRequestFactory, depositProvider, kycVerifier, wallet,
                                                            providerService, timestamper, sessionRepository, consumerNotifier, logManager);

            var sessionService = new SessionService(providerService, depositProvider, dataAssetService,
                                                    sessionRepository, timestamper, consumerNotifier, logManager);
            var dataConsumerService = new DataConsumerService(depositProvider, sessionService,
                                                              consumerNotifier, timestamper, sessionRepository, logManager);
            var dataStreamService = new DataStreamService(dataAssetService, depositProvider,
                                                          providerService, sessionService, wallet, consumerNotifier, sessionRepository, logManager);
            var depositApprovalService = new DepositApprovalService(dataAssetService, providerService,
                                                                    depositApprovalRepository, timestamper, consumerNotifier, logManager);
            var depositConfirmationService = new DepositConfirmationService(blockchainBridge, consumerNotifier,
                                                                            depositRepository, depositService, logManager, requiredBlockConfirmations);

            IDepositManager depositManager = new DepositManager(depositService, depositUnitsCalculator,
                                                                dataAssetService, kycVerifier, providerService, abiEncoder, cryptoRandom, wallet, gasPriceService,
                                                                depositRepository, timestamper, logManager, requiredBlockConfirmations,
                                                                disableSendingDepositTransaction);

            if (instantDepositVerificationEnabled)
            {
                depositManager = new InstantDepositManager(depositManager, depositRepository, timestamper, logManager,
                                                           requiredBlockConfirmations);
            }

            var depositReportService = new DepositReportService(depositRepository, receiptRepository, sessionRepository,
                                                                timestamper);
            var receiptService = new ReceiptService(depositProvider, providerService, receiptRequestValidator,
                                                    sessionService, timestamper, receiptRepository, sessionRepository, abiEncoder, wallet, ecdsa,
                                                    nodePublicKey, logManager);
            var refundService = new RefundService(blockchainBridge, abiEncoder, wallet, depositRepository,
                                                  contractAddress, logManager);
            var refundClaimant = new RefundClaimant(refundService, blockchainBridge, depositRepository,
                                                    transactionVerifier, gasPriceService, timestamper, logManager);
            var accountService = new AccountService(configManager, dataStreamService, providerService,
                                                    sessionService, consumerNotifier, wallet, configId, consumerAddress, logManager);
            var proxyService    = new ProxyService(jsonRpcClientProxy, configManager, configId, logManager);
            var consumerService = new ConsumerService(accountService, dataAssetService, dataRequestService,
                                                      dataConsumerService, dataStreamService, depositManager, depositApprovalService, providerService,
                                                      receiptService, refundService, sessionService, proxyService);
            var ethPriceService             = new EthPriceService(httpClient, timestamper, logManager);
            var consumerTransactionsService = new ConsumerTransactionsService(transactionService, depositRepository,
                                                                              timestamper, logManager);
            var gasLimitService = new ConsumerGasLimitsService(depositService, refundService);

            IPersonalBridge personalBridge = services.RequiredServices.EnableUnsecuredDevWallet
                ? new PersonalBridge(ecdsa, wallet)
                : null;

            services.RequiredServices.RpcModuleProvider.Register(
                new SingletonModulePool <INdmRpcConsumerModule>(new NdmRpcConsumerModule(consumerService,
                                                                                         depositReportService, jsonRpcNdmConsumerChannel, ethRequestService, ethPriceService,
                                                                                         gasPriceService, consumerTransactionsService, gasLimitService, personalBridge, timestamper), true));

            if (!backgroundServicesDisabled)
            {
                var useDepositTimer = ndmConfig.ProxyEnabled;
                var consumerServicesBackgroundProcessor = new ConsumerServicesBackgroundProcessor(accountService,
                                                                                                  refundClaimant, depositConfirmationService, ethPriceService, gasPriceService, blockProcessor,
                                                                                                  depositRepository, consumerNotifier, logManager, useDepositTimer, ethJsonRpcClientProxy);
                consumerServicesBackgroundProcessor.Init();
            }

            return(new NdmConsumerServices(accountService, consumerService));
        }
        public static IWebDriver Create(BrowserConfiguration executionConfiguration)
        {
            ProcessCleanupService.KillAllDriversAndChildProcessesWindows();

            DisposeDriverService.TestRunStartTime = DateTime.Now;

            BrowserConfiguration = executionConfiguration;
            var wrappedWebDriver = default(IWebDriver);

            _proxyService = ServicesCollection.Current.Resolve <ProxyService>();
            var webDriverProxy = new OpenQA.Selenium.Proxy
            {
                HttpProxy = $"http://127.0.0.1:{_proxyService.Port}",
                SslProxy  = $"http://127.0.0.1:{_proxyService.Port}",
            };

            switch (executionConfiguration.ExecutionType)
            {
            case ExecutionType.Regular:
                wrappedWebDriver = InitializeDriverRegularMode(executionConfiguration, webDriverProxy);
                break;

            case ExecutionType.Grid:
                var gridUri = ConfigurationService.GetSection <WebSettings>().Remote.GridUri;
                if (gridUri == null || !Uri.IsWellFormedUriString(gridUri.ToString(), UriKind.Absolute))
                {
                    throw new ArgumentException("To execute your tests in WebDriver Grid mode you need to set the gridUri in the browserSettings file.");
                }

                Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
                wrappedWebDriver = new RemoteWebDriver(gridUri, executionConfiguration.DriverOptions);
                var gridPageLoadTimeout = ConfigurationService.GetSection <WebSettings>().Remote.PageLoadTimeout;
                wrappedWebDriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(gridPageLoadTimeout);
                var gridScriptTimeout = ConfigurationService.GetSection <WebSettings>().Remote.ScriptTimeout;
                wrappedWebDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(gridScriptTimeout);
                BrowserSettings = ConfigurationService.GetSection <WebSettings>().Remote;
                ChangeWindowSize(executionConfiguration.BrowserType, executionConfiguration.Size, wrappedWebDriver);
                break;

            case ExecutionType.BrowserStack:
                var browserStackUri = ConfigurationService.GetSection <WebSettings>().BrowserStack.GridUri;
                BrowserSettings = ConfigurationService.GetSection <WebSettings>().BrowserStack;
                if (browserStackUri == null || !Uri.IsWellFormedUriString(browserStackUri.ToString(), UriKind.Absolute))
                {
                    throw new ArgumentException("To execute your tests in BrowserStack you need to set the gridUri in the browserSettings file.");
                }

                wrappedWebDriver = new RemoteWebDriver(browserStackUri, executionConfiguration.DriverOptions);
                var browserStackPageLoadTimeout = ConfigurationService.GetSection <WebSettings>().BrowserStack.PageLoadTimeout;
                wrappedWebDriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(browserStackPageLoadTimeout);
                var browserStackScriptTimeout = ConfigurationService.GetSection <WebSettings>().BrowserStack.ScriptTimeout;
                wrappedWebDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(browserStackScriptTimeout);
                break;

            case ExecutionType.CrossBrowserTesting:
                var crossBrowserTestingUri = ConfigurationService.GetSection <WebSettings>().CrossBrowserTesting.GridUri;
                BrowserSettings = ConfigurationService.GetSection <WebSettings>().CrossBrowserTesting;
                if (crossBrowserTestingUri == null || !Uri.IsWellFormedUriString(crossBrowserTestingUri.ToString(), UriKind.Absolute))
                {
                    throw new ArgumentException("To execute your tests in CrossBrowserTesting you need to set the gridUri in the browserSettings file.");
                }

                wrappedWebDriver = new RemoteWebDriver(crossBrowserTestingUri, executionConfiguration.DriverOptions);
                var crossBrowserTestingPageLoadTimeout        = ConfigurationService.GetSection <WebSettings>().CrossBrowserTesting.PageLoadTimeout;
                wrappedWebDriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(crossBrowserTestingPageLoadTimeout);
                var crossBrowserTestingScriptTimeout          = ConfigurationService.GetSection <WebSettings>().CrossBrowserTesting.ScriptTimeout;
                wrappedWebDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(crossBrowserTestingScriptTimeout);
                break;

            case ExecutionType.SauceLabs:
                var sauceLabsSettings = ConfigurationService.GetSection <WebSettings>().SauceLabs;
                var sauceLabsUri      = sauceLabsSettings.GridUri;
                if (sauceLabsUri == null || !Uri.IsWellFormedUriString(sauceLabsUri.ToString(), UriKind.Absolute))
                {
                    throw new ArgumentException("To execute your tests in SauceLabs you need to set the gridUri in the browserSettings file.");
                }

                wrappedWebDriver = new RemoteWebDriver(sauceLabsUri, executionConfiguration.DriverOptions);
                var sauceLabsPageLoadTimeout = sauceLabsSettings.PageLoadTimeout;
                wrappedWebDriver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(sauceLabsPageLoadTimeout);
                var sauceLabsScriptTimeout = sauceLabsSettings.ScriptTimeout;
                wrappedWebDriver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(sauceLabsScriptTimeout);
                BrowserSettings = sauceLabsSettings;
                break;
            }

            if (executionConfiguration.BrowserType != BrowserType.Edge)
            {
                FixDriverCommandExecutionDelay((RemoteWebDriver)wrappedWebDriver);
            }

            ChangeWindowSize(executionConfiguration.BrowserType, executionConfiguration.Size, wrappedWebDriver);

            return(wrappedWebDriver);
        }
Example #21
0
 /// <summary>
 /// Returns all running Outlook.Application instances from the environment/system that passed a predicate filter
 /// </summary>
 /// <param name="predicate">filter predicate</param>
 /// <returns>Outlook.Application sequence</returns>
 public static IDisposableSequence <Application> GetActiveInstances(Func <Application, bool> predicate)
 {
     return(ProxyService.GetActiveInstances <Application>("Outlook", "Application", predicate));
 }
Example #22
0
 public ProxyController(ProxyDbContext context)
 {
     _services = new ProxyService(new ProxyRepository(context));
 }
        public void CrossDomainSampleTestWithSerializableClass2()
        {

            ProxyService service = new ProxyService();
            var wrapper = service.Create<TestWrapper1>();
            wrapper.Test();
        }
Example #24
0
 /// <summary>
 /// Returns all running Outlook.Application instances from the environment/system
 /// </summary>
 /// <returns>Outlook.Application sequence</returns>
 public static IDisposableSequence <Application> GetActiveInstances()
 {
     return(ProxyService.GetActiveInstances <Application>("Outlook", "Application"));
 }
        public void CrossDomainSampleTestWithMarshalByRefObject()
        {

            ProxyService service = new ProxyService();
            var wrapper = service.Create<TestWrapper2>();
            wrapper.Test();
        }
Example #26
0
 public FileSystem(ScheduledRenewal renewal, Target target, IISClient iisClient, ILogService log, IInputService input, ProxyService proxy, string identifier) :
     base(log, input, proxy, renewal, target, identifier)
 {
     _iisClient = iisClient;
 }
Example #27
0
 public IIS(ScheduledRenewal renewal, Target target, IISClient iisClient, ILogService log, IInputService input, ProxyService proxy, string identifier) :
     base(renewal, target, iisClient, log, input, proxy, identifier)
 {
     _iisClient.PrepareSite(target);
 }
Example #28
0
 public ProxyController(ProxyService proxyService)
 {
     this.proxyService = proxyService;
 }
Example #29
0
 /// <summary>
 /// Returns first running Outlook.Application instance from the environment/system that passed a predicate filter
 /// </summary>
 /// <param name="predicate">filter predicate</param>
 /// <param name="throwExceptionIfNotFound">throw exception if unable to find an instance</param>
 /// <returns>Outlook.Application instance or null(Nothing in Visual Basic)</returns>
 /// <exception cref="ArgumentOutOfRangeException">occurs if no instance match and throwExceptionIfNotFound is set</exception>
 public static Application GetActiveInstance(Func <Application, bool> predicate, bool throwExceptionIfNotFound = false)
 {
     return(ProxyService.GetActiveInstance <Application>("Outlook", "Application", predicate, throwExceptionIfNotFound));
 }
Example #30
0
 public ZeroSsl(ProxyService proxy, ILogService log)
 {
     _httpClient = proxy.GetHttpClient();
     _log        = log;
 }
Example #31
0
 public AcmeOptionsFactory(ILogService log, ISettingsService settings, ProxyService proxy) :
     base(log, Constants.Dns01ChallengeType)
 {
     _proxy    = proxy;
     _settings = settings;
 }
Example #32
0
 public WebDav(ScheduledRenewal renewal, Target target, ILogService log, IInputService input, IOptionsService options, ProxyService proxy, string identifier) :
     base(log, input, proxy, renewal, target, identifier)
 {
     _webdavClient = new WebDavClient(target.HttpWebDavOptions, log);
 }
Example #33
0
 /// <summary>
 /// Returns a running Publisher.Application instance from the environment/system
 /// </summary>
 /// <param name="throwExceptionIfNotFound">throw exception if unable to find an instance</param>
 /// <returns>Publisher.Application instance or null(Nothing in Visual Basic)</returns>
 public static Application GetActiveInstance(bool throwExceptionIfNotFound = false)
 {
     return(ProxyService.GetActiveInstance <Application>("Publisher", "Application", throwExceptionIfNotFound));
 }
Example #34
0
 public ProxyPoolV1Impl(ProxyService proxyService)
 {
     this.proxyService = proxyService ?? throw new ArgumentNullException(nameof(proxyService));
 }
Example #35
0
 public ProxiedMessage(EmbedService embeds,
                       DiscordApiClient rest, IMetrics metrics, ModelRepository repo, ProxyService proxy,
                       WebhookExecutorService webhookExecutor, LogChannelService logChannel, IDiscordCache cache)
 {
     _embeds          = embeds;
     _rest            = rest;
     _webhookExecutor = webhookExecutor;
     _repo            = repo;
     _logChannel      = logChannel;
     // _cache = cache;
     _metrics = metrics;
     _proxy   = proxy;
 }
Example #36
0
 public BaseService(ProxyService proxyService)
 {
     _client             = proxyService.GetHttpClient();
     _client.BaseAddress = new Uri("https://api.transip.nl/v6/");
 }
        public static IProxyService BuildAndGetBoostUser(IConfiguration configuration)
        {
            IProxyService proxyService = new ProxyService(configuration);

            return(proxyService);
        }
Example #38
0
 public Ftp(ScheduledRenewal renewal, Target target, ILogService log, IInputService input, ProxyService proxy, string identifier) :
     base(log, input, proxy, renewal, target, identifier)
 {
     _ftpClient = new FtpClient(target.HttpFtpOptions, log);
 }
Example #39
0
        public void RunServiceWithProxy2()
        {
            WebHttpBinding webBinding = new WebHttpBinding
            {
                ContentTypeMapper = new RawContentMapper(),
                MaxReceivedMessageSize = 4194304,
                MaxBufferSize = 4194304
            };

            string baseAddress = "http://" + Environment.MachineName + ":8000/Service/jargs";
            Uri uriBase = new Uri(baseAddress);

            ServiceHost host = new ServiceHost(typeof(LocalService), uriBase);
            host.AddServiceEndpoint(typeof(ILocalService), webBinding, uriBase)
                            .Behaviors.Add(new WebHttpJsonNetBehavior2());

            host.Open();
            Console.WriteLine("Host opened");

            //////////////////////////////////////////////
            WebHttpBinding webBinding2 = new WebHttpBinding
            {
                ContentTypeMapper = new RawContentMapper(),
                MaxReceivedMessageSize = 4194304,
                MaxBufferSize = 4194304,
                SendTimeout = TimeSpan.FromMinutes(4)
            };

            EndpointAddress endpoint = new EndpointAddress(baseAddress);

            ProxyService client = new ProxyService(webBinding2, endpoint);
            //client.Endpoint.Behaviors.Add(new WebHttpJsonNetBehavior());
            client.Endpoint.Behaviors.Add(new NewHttpJsonNetBehavior());

            //var res = client.saveDataGet3(new InputData { FirstName = "myname", LastName = "mylastname" }, "my str");
            //var res1 = client.saveDataGet3(new InputData { FirstName = "myname", LastName = "mylastname" }, null);

            var res1 = client.ReadInputData1(new InputData { FirstName = "myname2", LastName = "mylastname2" }, "ReadInputData1");

            // ok
            //var res2 = client.ReadInputData2(new InputData { FirstName = "myname4", LastName = "mylastname4" }, "ReadInputData2");

            Console.WriteLine("######### risultato ########");
            //Console.WriteLine(res);
            Console.WriteLine(res1);
            //Console.WriteLine(res2);
            Console.ReadLine();
        }