Пример #1
0
        public async Task <IActionResult> TestProviderAsync(string name, [FromBody] IDictionary <string, string> config)
        {
            var providerType = ProviderService.GetProvider(name);

            if (providerType == null)
            {
                return(NotFound());
            }

            var provider = (IMetricValueProvider)Activator.CreateInstance(providerType);

            var providerProperties = providerType.GetProperties();

            foreach (var prop in providerProperties)
            {
                if (config.TryGetValue(prop.Name, out var value))
                {
                    prop.SetValue(provider, value);
                }
            }

            var val = await provider.GetValueAsync();

            return(Ok(val));
        }
        public PaymentsController()
            :base()
        {
            this.paymentProvider = ProviderService.GetProvider();
            this.antiForgeryService = new AntiForgeryService();
            this.engineService = new EngineService();

            System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
        }
        public async Task <IActionResult> Insert()
        {
            ViewBag.Brands = await _brandService.GetBrands();

            ViewBag.Provider = await providerSvc.GetProvider();

            ViewBag.Category = await this._categoryService.GetCategory();

            return(View());
        }
Пример #4
0
        public IActionResult GetProvider(string name)
        {
            var provider = ProviderService.GetProvider(name);

            if (provider == null)
            {
                return(NotFound());
            }

            var descriptor = MetadataService.GetMetadata(provider);

            return(Ok(descriptor));
        }
Пример #5
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //Register and Run Background Service if Provider Uses One
            var provider          = ProviderService.GetProvider();
            var backgroundService = provider.GetHostedService();

            if (backgroundService != null)
            {
                HostingEnvironment.RegisterObject(backgroundService);
            }
        }
Пример #6
0
        public void REQ_11_AddNewProvider()
        {
            _authentificationService.ConnectStorekeeper("MatMatStock", "brico2000clavy");
            var newProvider = _providerService.AddProvider(
                "Courage",
                "0606060606",
                "*****@*****.**",
                "Middle of",
                "666",
                "Nowhere"
                ,
                new Catalog()
                );

            var providerFound = _providerService.GetProvider(newProvider.Name);

            Assert.IsNotNull(providerFound);
        }
Пример #7
0
        private StockOrder MakeStockOrder(Storekeeper storekeeper)
        {
            var provider = _providerService.GetProvider("BricoWorld");

            var articles = new List <Article>();

            articles.Add(ArticleConsts.Screwdriver);
            articles.Add(ArticleConsts.Probe);
            articles.Add(ArticleConsts.WoodenGardenChair);
            articles.Add(ArticleConsts.RJ45Cable3Meters);

            var stockOrder = _stockOrderService.AddStockOrder(
                provider,
                storekeeper,
                articles
                );

            return(stockOrder);
        }
Пример #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            var provider = ProviderService.GetProvider("provider");

            services.AddHttpClient("items", c => { c.BaseAddress = provider.Uri; })
            .AddTypedClient(c => Refit.RestService.For <IItemsClient>(c));

            services.AddMvc()
            .AddApplicationPart(typeof(Controllers.ItemsController).Assembly);
            //.SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            services.AddCors();

            //services.AddCors(options =>
            //{
            //    options.AddPolicy(
            //        "AllowAnyOrigin",
            //        builder => builder
            //            .AllowAnyOrigin()
            //            .AllowAnyMethod()
            //            .AllowAnyHeader());
            //});
        }
Пример #9
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var     metric     = new Metric();
            JObject jsonObject = JObject.Load(reader);

            var typeProperty = jsonObject.Properties()
                               .FirstOrDefault(p => p.Name.Equals(nameof(Metric.ProviderType), StringComparison.OrdinalIgnoreCase));

            if (typeProperty == null)
            {
                throw new InvalidOperationException($"Property {nameof(Metric.ProviderType)} is required");
            }

            var typePropertyValue = typeProperty.First.Value <string>();
            var providerType      = ProviderService.GetProvider(typePropertyValue);

            if (providerType == null)
            {
                throw new InvalidOperationException($"Type {typePropertyValue} could not be resolved");
            }

            JToken provider;

            if (jsonObject.TryGetValue(nameof(Metric.Provider), StringComparison.OrdinalIgnoreCase, out provider))
            {
                ((JProperty)provider.Parent).Remove();
                using (var subReader = jsonObject.CreateReader())
                {
                    serializer.Populate(subReader, metric);
                }

                metric.Provider = (IMetricValueProvider)provider.ToObject(providerType);
            }

            return(metric);
        }