コード例 #1
0
        public void Execute()
        {
			var config = GlobalConfiguration.Configuration;

			var configBroadcaster = new WebApiConfigurationBroadcaster()
			{
				ModelBuilder = new ODataConventionModelBuilder(),
				RoutingConventions = ODataRoutingConventions.CreateDefault(),
				Routes = config.Routes
			};

			config.DependencyResolver = new AutofacWebApiDependencyResolver();

			config.Formatters.JsonFormatter.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented;
			config.Formatters.JsonFormatter.MediaTypeMappings.Add(new QueryStringMapping("format", "json", "application/json"));
			config.Formatters.XmlFormatter.MediaTypeMappings.Add(new QueryStringMapping("format", "xml", "application/xml"));

			var queryAttribute = new WebApiQueryableAttribute()
			{
				MaxTop = WebApiGlobal.MaxTop
			};
			config.EnableQuerySupport(queryAttribute);

			var corsAttribute = new EnableCorsAttribute("*", "*", "*", WebApiGlobal.Header.CorsExposed);
			config.EnableCors(corsAttribute);

			config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;

			//var configPublisher = EngineContext.Current.Resolve<IWebApiConfigurationPublisher>();
			var configPublisher = (IWebApiConfigurationPublisher)config.DependencyResolver.GetService(typeof(IWebApiConfigurationPublisher));
			configPublisher.Configure(configBroadcaster);

			//config.Services.Insert(typeof(ModelBinderProvider), 0,
			//	new SimpleModelBinderProvider(typeof(Address), new AddressModelBinder()));

			try
			{
				if (!config.Routes.ContainsKey(WebApiGlobal.RouteNameDefaultApi))
				{
					config.Routes.MapHttpRoute(WebApiGlobal.RouteNameDefaultApi, "api/{version}/{controller}/{id}",
						new { version = "v1", controller = "Home", id = RouteParameter.Optional });
				}
			}
			catch (Exception) { }

			try
			{
				if (!config.Routes.ContainsKey(WebApiGlobal.RouteNameDefaultOdata))
				{
					config.Routes.MapODataRoute(WebApiGlobal.RouteNameDefaultOdata, WebApiGlobal.MostRecentOdataPath,
						configBroadcaster.ModelBuilder.GetEdmModel(), new DefaultODataPathHandler(), configBroadcaster.RoutingConventions);
				}
			}
			catch (Exception) { }
        }
コード例 #2
0
        public void Configure(WebApiConfigurationBroadcaster configData)
        {
            var m = configData.ModelBuilder;

            m.EntitySet<Address>(WebApiOdataEntitySet.Addresses);
            m.EntitySet<Category>(WebApiOdataEntitySet.Categories);
            m.EntitySet<Country>(WebApiOdataEntitySet.Countries);
            m.EntitySet<Currency>(WebApiOdataEntitySet.Currencies);
            m.EntitySet<Customer>(WebApiOdataEntitySet.Customers);
            m.EntitySet<DeliveryTime>(WebApiOdataEntitySet.DeliveryTimes);
            m.EntitySet<Discount>(WebApiOdataEntitySet.Discounts);
            m.EntitySet<Download>(WebApiOdataEntitySet.Downloads);
            m.EntitySet<GenericAttribute>(WebApiOdataEntitySet.GenericAttributes);
            m.EntitySet<Language>(WebApiOdataEntitySet.Languages);
            m.EntitySet<LocalizedProperty>(WebApiOdataEntitySet.LocalizedPropertys);
            m.EntitySet<Manufacturer>(WebApiOdataEntitySet.Manufacturers);
            m.EntitySet<OrderNote>(WebApiOdataEntitySet.OrderNotes);
            m.EntitySet<Order>(WebApiOdataEntitySet.Orders);
            m.EntitySet<OrderItem>(WebApiOdataEntitySet.OrderItems);
            m.EntitySet<PaymentMethod>(WebApiOdataEntitySet.PaymentMethods);
            m.EntitySet<Picture>(WebApiOdataEntitySet.Pictures);
            m.EntitySet<ProductAttribute>(WebApiOdataEntitySet.ProductAttributes);
            m.EntitySet<ProductBundleItem>(WebApiOdataEntitySet.ProductBundleItems);
            m.EntitySet<ProductCategory>(WebApiOdataEntitySet.ProductCategories);
            m.EntitySet<ProductManufacturer>(WebApiOdataEntitySet.ProductManufacturers);
            m.EntitySet<ProductPicture>(WebApiOdataEntitySet.ProductPictures);
            m.EntitySet<Product>(WebApiOdataEntitySet.Products);
            m.EntitySet<ProductSpecificationAttribute>(WebApiOdataEntitySet.ProductSpecificationAttributes);
            m.EntitySet<ProductTag>(WebApiOdataEntitySet.ProductTags);
            m.EntitySet<ProductVariantAttribute>(WebApiOdataEntitySet.ProductVariantAttributes);
            m.EntitySet<ProductVariantAttributeValue>(WebApiOdataEntitySet.ProductVariantAttributeValues);
            m.EntitySet<ProductVariantAttributeCombination>(WebApiOdataEntitySet.ProductVariantAttributeCombinations);
            m.EntitySet<QuantityUnit>(WebApiOdataEntitySet.QuantityUnits);
            m.EntitySet<RelatedProduct>(WebApiOdataEntitySet.RelatedProducts);
            m.EntitySet<ReturnRequest>(WebApiOdataEntitySet.ReturnRequests);
            m.EntitySet<Setting>(WebApiOdataEntitySet.Settings);
            m.EntitySet<Shipment>(WebApiOdataEntitySet.Shipments);
            m.EntitySet<ShipmentItem>(WebApiOdataEntitySet.ShipmentItems);
            m.EntitySet<ShippingMethod>(WebApiOdataEntitySet.ShippingMethods);
            m.EntitySet<SpecificationAttributeOption>(WebApiOdataEntitySet.SpecificationAttributeOptions);
            m.EntitySet<SpecificationAttribute>(WebApiOdataEntitySet.SpecificationAttributes);
            m.EntitySet<StateProvince>(WebApiOdataEntitySet.StateProvinces);
            m.EntitySet<Store>(WebApiOdataEntitySet.Stores);
            m.EntitySet<StoreMapping>(WebApiOdataEntitySet.StoreMappings);
            m.EntitySet<TierPrice>(WebApiOdataEntitySet.TierPrices);
            m.EntitySet<UrlRecord>(WebApiOdataEntitySet.UrlRecords);
            m.EntitySet<SyncMapping>(WebApiOdataEntitySet.SyncMappings);

            AddActionsToOrder(m.Entity<Order>());
            AddActionsToProduct(m.Entity<Product>());
        }
コード例 #3
0
        public void Configure(WebApiConfigurationBroadcaster configData)
        {
            var providerTypes = _typeFinder.FindClassesOfType <IWebApiConfigurationProvider>(ignoreInactivePlugins: true);
            var providers     = new List <IWebApiConfigurationProvider>();

            foreach (var providerType in providerTypes)
            {
                var provider = Activator.CreateInstance(providerType) as IWebApiConfigurationProvider;
                providers.Add(provider);
            }

            providers = providers.OrderByDescending(x => x.Priority).ToList();
            providers.Each(x => x.Configure(configData));
        }
		public void Configure(WebApiConfigurationBroadcaster configData)
		{
			var providerTypes = _typeFinder.FindClassesOfType<IWebApiConfigurationProvider>(ignoreInactivePlugins: true);
			var providers = new List<IWebApiConfigurationProvider>();

			foreach (var providerType in providerTypes)
			{
				var provider = Activator.CreateInstance(providerType) as IWebApiConfigurationProvider;
				providers.Add(provider);
			}

			providers = providers.OrderByDescending(x => x.Priority).ToList();
			providers.Each(x => x.Configure(configData));
		}
コード例 #5
0
        public void Configure(WebApiConfigurationBroadcaster configData)
        {
            var providerTypes = _typeFinder.FindClassesOfType<IWebApiConfigurationProvider>();
            var providers = new List<IWebApiConfigurationProvider>();

            foreach (var providerType in providerTypes)
            {
                if (!PluginManager.IsActivePluginAssembly(providerType.Assembly))
                {
                    continue;
                }

                var provider = Activator.CreateInstance(providerType) as IWebApiConfigurationProvider;
                providers.Add(provider);
            }

            providers = providers.OrderByDescending(x => x.Priority).ToList();
            providers.Each(x => x.Configure(configData));
        }
コード例 #6
0
        public void Configure(WebApiConfigurationBroadcaster configData)
        {
            var providerTypes = _typeFinder.FindClassesOfType <IWebApiConfigurationProvider>();
            var providers     = new List <IWebApiConfigurationProvider>();

            foreach (var providerType in providerTypes)
            {
                if (!PluginManager.IsActivePluginAssembly(providerType.Assembly))
                {
                    continue;
                }

                var provider = Activator.CreateInstance(providerType) as IWebApiConfigurationProvider;
                providers.Add(provider);
            }

            providers = providers.OrderByDescending(x => x.Priority).ToList();
            providers.Each(x => x.Configure(configData));
        }