コード例 #1
0
ファイル: ProxyBase.cs プロジェクト: Toloymak/BehaviorService
        protected ProxyBase(IRestClient restClient, ProxySettingCollection settingCollection, string appName)
        {
            proxySettings = settingCollection.GetByName(appName);

            this.restClient         = restClient;
            this.restClient.BaseUrl = new Uri(proxySettings.Url);
        }
コード例 #2
0
        private void CreateSantaProxy()
        {
            mockRestClient
            .Setup(c => c.Execute(It.IsAny <IRestRequest>()))
            .Returns(new RestResponse()
            {
                Content = errorMessage == null
                        ? JsonSerializer.Serialize(verdictDto)
                        : errorMessage,
                StatusCode     = statusCode,
                ErrorException = exception
            });

            var settingCollection = new ProxySettingCollection()
            {
                Proxies = new ProxySettings[]
                {
                    new ProxySettings()
                    {
                        Name = appName,
                        Url  = Url
                    }
                }
            };

            santaAppProxy = CreateProxy(mockRestClient.Object, settingCollection);
        }
コード例 #3
0
        public static ProxySettings GetByName(this ProxySettingCollection collection, string appName)
        {
            if (collection == null || collection.Proxies.Length == 0)
            {
                throw new ArgumentException($"Настройки для приложений не найдены");
            }

            var proxySettings = collection.Proxies
                                .FirstOrDefault(p => string.Equals(
                                                    p.Name,
                                                    appName,
                                                    StringComparison.CurrentCultureIgnoreCase));

            if (proxySettings == null)
            {
                throw new ArgumentException($"Настройки для приложения {appName} не обнаруженны");
            }

            return(proxySettings);
        }
コード例 #4
0
 public SantaAppProxy(IRestClient restClient, ProxySettingCollection settingCollection)
     : base(restClient, settingCollection, AppName)
 {
 }
コード例 #5
0
 protected override IBehaviorProxy CreateProxy(IRestClient restClient,
                                               ProxySettingCollection settingCollection) =>
 new SantaAppProxy(restClient, settingCollection);
コード例 #6
0
 protected abstract IBehaviorProxy CreateProxy(IRestClient restClient, ProxySettingCollection settingCollection);