Ejemplo n.º 1
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            var config = new WebApiConfiguration { EnableTestClient = true };

            config.ErrorHandlers = OnErrorHandlers;

            if (UseHttpContextForStoringUniqueRequestId)
            {
                config.MessageHandlerFactory = () => new List<DelegatingHandler> { new HttpContextRequestIdHandler() };
            }
            else
            {
                config.MessageHandlerFactory = () => new List<DelegatingHandler> { new OperationContextRequestIdHandler() };
            }

            routes.SetDefaultHttpConfiguration(config);

            routes.MapServiceRoute<StringService>("api/str");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }
        private static ServiceRoute MapServiceRoute(Type serviceType, string routePrefix, HttpConfiguration configuration = null, object constraints = null, bool useMethodPrefixForHttpMethod = true)
        {
            if (configuration == null)
                configuration = new WebApiConfiguration(useMethodPrefixForHttpMethod);

            var serviceHostFactory = new HttpServiceHostFactory { Configuration = configuration };
            var webApiRoute = new WebApiRoute(routePrefix, serviceHostFactory, serviceType) { Constraints = new RouteValueDictionary(constraints) };
            return webApiRoute;
        }
 void Application_Start(object sender, EventArgs e)
 {
     var config = new WebApiConfiguration();
     config.EnableTestClient = true;
     RouteTable.Routes.SetDefaultHttpConfiguration(config);
     RouteTable.Routes.MapServiceRoute<RealEstateApi>("PropertyTableAzures");
     Search.PopulatetheCache();
     Search.PopulatetheCacheEstate();
        // PopulateTheCache();
 }
Ejemplo n.º 4
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            var config = new WebApiConfiguration() {EnableTestClient = true, EnableHelpPage = true};

            routes.SetDefaultHttpConfiguration(config);

            routes.MapServiceRoute<ExpeditionApi>("api/expvar");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }
Ejemplo n.º 5
0
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            HttpConfiguration configuration = new WebApiConfiguration();// {EnableTestClient = true};
            configuration.Formatters.Add(new JpgFormatter());
            configuration.Formatters.Add(new RssFormatter());
            configuration.MessageHandlers.Add(typeof(UriFormatHandler));
            #if DEBUG
            configuration.EnableTestClient = true;
            #endif
            routes.MapServiceRoute<DonaldApi>("api/donald", configuration);
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
        }
Ejemplo n.º 6
0
        public static void Start()
        {

            // Set up StructureMap Container
            ObjectFactory.Initialize(c =>
                {
                    c.For<IPlayerRepository>().Singleton().Use<PlayerRepository>();
                });

            var iocContainer = ObjectFactory.Container;

            // Get Configuration for Web API
            var config = new WebApiConfiguration
            {
                EnableTestClient = true,
                EnableHelpPage = true,
                IncludeExceptionDetail = true,
            };

            //Set the delegate for creating the instance of the service
            config.CreateInstance = (serviceType, context, request) =>
            {
                if (serviceType == null)
                {
                    return null;
                }

                try
                {
                    return serviceType.IsAbstract || serviceType.IsInterface
                               ? iocContainer.TryGetInstance(serviceType)
                               : iocContainer.GetInstance(serviceType);
                }
                catch (System.Exception)
                {
                    return null;
                }
            };

            //Set the configuration for all the services
            RouteTable.Routes.SetDefaultHttpConfiguration(config);
            RouteTable.Routes.MapServiceRoute<PlayersApi>("Players");
        }
Ejemplo n.º 7
0
        protected void Application_Start()
        {
            CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
            {
                string configuration = RoleEnvironment.IsAvailable ?
                    RoleEnvironment.GetConfigurationSettingValue(configName) :
                    ConfigurationManager.AppSettings[configName];

                configSetter(configuration);
            });

            // Setup AutoFac
            var builder = new ContainerBuilder();
            DependancySetup(builder);
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            // Setup WCF Web API Config
            var config = new WebApiConfiguration();
            config.EnableTestClient = true;
            config.CreateInstance = ((t, i, h) => DependencyResolver.Current.GetService(t));
            //config.MessageHandlerFactory = () => DependencyResolver.Current.GetService<DelegatingHandler[]>();
            RouteTable.Routes.SetDefaultHttpConfiguration(config);

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            FederatedAuthentication.ServiceConfigurationCreated += this.OnServiceConfigurationCreated;
        }