public static void MapRoutes(RouteCollection routes, string prefix, string suffix)
        {
            var    factory       = new DataServiceHostFactory();
            string servicePrefix = prefix + "/{repository}/FeedService.mvc";

            RouteTable.Routes.Add(new DynamicServiceRoute(servicePrefix, null, new[] { typeof(ODataPackageService).Namespace }, factory, typeof(ODataPackageService)));
        }
Ejemplo n.º 2
0
        private static void RegisterRoutes()
        {
            DataServiceHostFactory factory = new DataServiceHostFactory();

            RouteTable.Routes.Add(
                new ServiceRoute(ODataValidator.ServiceName, factory, typeof(ODataValidator)));
        }
Ejemplo n.º 3
0
 private static void MapRoutes(RouteCollection routes) {
     // The default route is http://{root}/nuget/Packages
     var factory = new DataServiceHostFactory();
     var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages));
     serviceRoute.Defaults = new RouteValueDictionary { { "serviceType", "odata" } };
     serviceRoute.Constraints = new RouteValueDictionary { { "serviceType", "odata" } };
     routes.Add("nuget", serviceRoute);
 }
Ejemplo n.º 4
0
        private static void MapRoutes(RouteCollection routes)
        {
            // Route to create a new package
            routes.MapDelegate("CreatePackage-Root",
                               "",
                               new { httpMethod = new HttpMethodConstraint("PUT") },
                               context => CreatePackageService().CreatePackage(context.HttpContext));

            routes.MapDelegate("CreatePackage",
                               "api/v2/package",
                               new { httpMethod = new HttpMethodConstraint("PUT") },
                               context => CreatePackageService().CreatePackage(context.HttpContext));

            // Route to delete packages
            routes.MapDelegate("DeletePackage-Root",
                               "{packageId}/{version}",
                               new { httpMethod = new HttpMethodConstraint("DELETE") },
                               context => CreatePackageService().DeletePackage(context.HttpContext));

            routes.MapDelegate("DeletePackage",
                               "api/v2/package/{packageId}/{version}",
                               new { httpMethod = new HttpMethodConstraint("DELETE") },
                               context => CreatePackageService().DeletePackage(context.HttpContext));

            // Route to get packages
            routes.MapDelegate("DownloadPackage",
                               "api/v2/package/{packageId}/{version}",
                               new { httpMethod = new HttpMethodConstraint("GET") },
                               context => CreatePackageService().DownloadPackage(context.HttpContext));

            // Route to clear package cache
            routes.MapDelegate("ClearPackageCache",
                               "nugetserver/api/clear-cache",
                               new { httpMethod = new HttpMethodConstraint("GET") },
                               context => CreatePackageService().ClearCache(context.HttpContext));

#if DEBUG
            // Route to create a new package(http://{root}/nuget)
            routes.MapDelegate("CreatePackageNuGet",
                               "nuget",
                               new { httpMethod = new HttpMethodConstraint("PUT") },
                               context => CreatePackageService().CreatePackage(context.HttpContext));

            // The default route is http://{root}/nuget/Packages
            var factory      = new DataServiceHostFactory();
            var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages));
            serviceRoute.Defaults = new RouteValueDictionary {
                { "serviceType", "odata" }
            };
            serviceRoute.Constraints = new RouteValueDictionary {
                { "serviceType", "odata" }
            };
            routes.Add("nuget", serviceRoute);
#endif
        }
Ejemplo n.º 5
0
        private void RegisterRoutes()
        {
            DataServiceHostFactory factory = new DataServiceHostFactory();
            string serverName    = Utils.ExtractServerNameFromConnectionString(ConfigurationManager.ConnectionStrings["MongoDB"].ConnectionString);
            var    databaseNames = MongoContext.GetDatabaseNames(serverName);

            foreach (var databaseName in databaseNames)
            {
                RouteTable.Routes.Add(new ServiceRoute(databaseName, factory, typeof(MongOData)));
            }
        }
Ejemplo n.º 6
0
        private void RegisterRoutes()
        {
            DataServiceHostFactory factory = new DataServiceHostFactory();
            string serverName = Utils.ExtractServerNameFromConnectionString(ConfigurationManager.ConnectionStrings["DocumentDB"].ConnectionString);

            // TODO
            //var databaseNames = DocumentDbContext.GetDatabaseNames(serverName);
            //foreach (var databaseName in databaseNames)
            //{
            //    RouteTable.Routes.Add(new ServiceRoute(databaseName, factory, typeof(DocumentDbOData)));
            //}
            RouteTable.Routes.Add(new ServiceRoute("odatatests", factory, typeof(DocumentDbOData)));
        }
Ejemplo n.º 7
0
        public void CreatesDataServiceHostFromServiceName()
        {
            var windsorContainer = new WindsorContainer().Register(
                Component.For <IOperations>().ImplementedBy <Operations>().Named("operations"),
                Component.For <IServiceHostBuilder <DataServiceModel> >().ImplementedBy <DataServiceHostBuilder>());

            var factory = new DataServiceHostFactory(windsorContainer.Kernel);

            var serviceLocation = new Uri("http://localhost/Foo.svc");
            var serviceHost     = factory.CreateServiceHost("operations", new[] { serviceLocation });

            Assert.That(serviceHost, Is.Not.Null);
            Assert.That(serviceHost, Is.InstanceOf <DataServiceHost>());
            Assert.That(serviceHost.BaseAddresses, Has.Member(serviceLocation));
        }
Ejemplo n.º 8
0
        public static void Start()
        {
            // The default route is http://{root}/nuget/Packages

            var factory      = new DataServiceHostFactory();
            var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages));

            serviceRoute.Defaults = new RouteValueDictionary {
                { "serviceType", "odata" }
            };
            serviceRoute.Constraints = new RouteValueDictionary {
                { "serviceType", "odata" }
            };
            RouteTable.Routes.Add("nuget", serviceRoute);
        }
		public void CreatesDataServiceHostFromServiceName()
		{
			var windsorContainer = new WindsorContainer().Register(
				Component.For<IOperations>().ImplementedBy<Operations>().Named("operations"),
				Component.For<IServiceHostBuilder<DataServiceModel>>().ImplementedBy<DataServiceHostBuilder>());

			var factory = new DataServiceHostFactory(windsorContainer.Kernel);

			var serviceLocation = new Uri("http://localhost/Foo.svc");
			var serviceHost = factory.CreateServiceHost("operations", new[] { serviceLocation });

			Assert.That(serviceHost, Is.Not.Null);
			Assert.That(serviceHost, Is.InstanceOf<DataServiceHost>());
			Assert.That(serviceHost.BaseAddresses, Has.Member(serviceLocation));
		}
Ejemplo n.º 10
0
        private static void MapRoutes(RouteCollection routes)
        {
            // Route to create a new package(http://{root}/nuget)
            routes.MapDelegate("CreatePackageNuGet",
                               "nuget",
                               new { httpMethod = new HttpMethodConstraint("PUT") },
                               context => CreatePackageService().CreatePackage(context.HttpContext));

            // The default route is http://{root}/nuget/Packages
            var factory      = new DataServiceHostFactory();
            var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages));

            serviceRoute.Defaults = new RouteValueDictionary {
                { "serviceType", "odata" }
            };
            serviceRoute.Constraints = new RouteValueDictionary {
                { "serviceType", "odata" }
            };
            routes.Add("nuget", serviceRoute);
        }
        private static void MapRoutes(RouteCollection routes)
        {
            // The default route is http://{root}/nuget/Packages
            var factory      = new DataServiceHostFactory();
            var serviceRoute = new ServiceRoute("nuget", factory, typeof(Packages));

            serviceRoute.Defaults = new RouteValueDictionary {
                { "serviceType", "odata" }
            };
            serviceRoute.Constraints = new RouteValueDictionary {
                { "serviceType", "odata" }
            };
            routes.Add("nuget", serviceRoute);

            routes.MapRoute(
                "Default",                    // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
                );

            // For some godforsaken reason, the PublishPackage route (registered by NuGet.Server) causes the { controller, action } => url mapping to always return this route.
            routes.Remove(routes.OfType <Route>().Single(r => r.DataTokens != null && r.DataTokens.ContainsKey("__RouteName") && (string)r.DataTokens["__RouteName"] == "PublishPackage"));
        }