public void AddEndpoint_InvalidPath_BubblesOutException() { var services = CreateServices(); var factory = services.GetRequiredService <ProxyEndpointFactory>(); factory.SetProxyPipeline(context => Task.CompletedTask); var route = new RouteConfig { RouteId = "route1", Match = new RouteMatch { Path = "/{invalid", }, Order = 12, }; var cluster = new ClusterState("cluster1"); var routeState = new RouteState("route1"); Action action = () => CreateEndpoint(factory, routeState, route, cluster); Assert.Throws <RoutePatternException>(action); }
public void AddEndpoint_DefaultAuth_Works() { var services = CreateServices(); var factory = services.GetRequiredService <ProxyEndpointFactory>(); factory.SetProxyPipeline(context => Task.CompletedTask); var route = new RouteConfig { RouteId = "route1", AuthorizationPolicy = "defaulT", Order = 12, Match = new RouteMatch(), }; var cluster = new ClusterState("cluster1"); var routeState = new RouteState("route1"); var(routeEndpoint, _) = CreateEndpoint(factory, routeState, route, cluster); var attribute = Assert.IsType <AuthorizeAttribute>(routeEndpoint.Metadata.GetMetadata <IAuthorizeData>()); Assert.Null(attribute.Policy); }
public void AddEndpoint_CustomCors_Works() { var services = CreateServices(); var factory = services.GetRequiredService <ProxyEndpointFactory>(); factory.SetProxyPipeline(context => Task.CompletedTask); var route = new RouteConfig { RouteId = "route1", CorsPolicy = "custom", Order = 12, Match = new RouteMatch(), }; var cluster = new ClusterState("cluster1"); var routeState = new RouteState("route1"); var(routeEndpoint, _) = CreateEndpoint(factory, routeState, route, cluster); var attribute = Assert.IsType <EnableCorsAttribute>(routeEndpoint.Metadata.GetMetadata <IEnableCorsAttribute>()); Assert.Equal("custom", attribute.PolicyName); Assert.Null(routeEndpoint.Metadata.GetMetadata <IDisableCorsAttribute>()); }
private static void routeWorkerThread_completed(object sender, RunWorkerCompletedEventArgs e) { RoutefileState = RouteState.Processed; if (e.Error != null || Program.CurrentRoute == null) { Program.CurrentHost.RegisterTexture(Path.CombineFile(Program.FileSystem.DataFolder, "Menu\\route_error.png"), new TextureParameters(null, null), out routePictureBox.Texture); if (e.Error != null) { routeDescriptionBox.Text = e.Error.Message; RoutefileState = RouteState.Error; } routeWorkerThread.Dispose(); return; } try { // image if (!string.IsNullOrEmpty(Program.CurrentRoute.Image)) { try { if (File.Exists(Program.CurrentRoute.Image)) { Program.CurrentHost.RegisterTexture(Program.CurrentRoute.Image, new TextureParameters(null, null), out routePictureBox.Texture); } else { Program.CurrentHost.RegisterTexture(Path.CombineFile(Program.FileSystem.DataFolder, "Menu\\route_unknown.png"), new TextureParameters(null, null), out routePictureBox.Texture); } } catch { routePictureBox.Texture = null; } } else { string[] f = { ".png", ".bmp", ".gif", ".tiff", ".tif", ".jpeg", ".jpg" }; int i; for (i = 0; i < f.Length; i++) { string g = OpenBveApi.Path.CombineFile(System.IO.Path.GetDirectoryName(currentFile), System.IO.Path.GetFileNameWithoutExtension(currentFile) + f[i]); if (System.IO.File.Exists(g)) { try { using (var fs = new FileStream(g, FileMode.Open, FileAccess.Read)) { //pictureboxRouteImage.Image = new Bitmap(fs); } } catch { //pictureboxRouteImage.Image = null; } break; } } if (i == f.Length) { Program.CurrentHost.RegisterTexture(Path.CombineFile(Program.FileSystem.DataFolder, "Menu\\route_unknown.png"), new TextureParameters(null, null), out routePictureBox.Texture); } } // description string Description = Program.CurrentRoute.Comment.ConvertNewlinesToCrLf(); if (Description.Length != 0) { routeDescriptionBox.Text = Description; } else { routeDescriptionBox.Text = System.IO.Path.GetFileNameWithoutExtension(currentFile); } } catch (Exception ex) { Program.CurrentHost.RegisterTexture(Path.CombineFile(Program.FileSystem.DataFolder, "Menu\\route_error.png"), new TextureParameters(null, null), out routePictureBox.Texture); routeDescriptionBox.Text = ex.Message; currentFile = null; } }
private (RouteEndpoint routeEndpoint, RouteModel routeConfig) CreateEndpoint(ProxyEndpointFactory factory, RouteState routeState, RouteConfig routeConfig, ClusterState clusterState) { routeState.ClusterRevision = clusterState.Revision; var routeModel = new RouteModel(routeConfig, clusterState, HttpTransformer.Default); var endpoint = factory.CreateEndpoint(routeModel, Array.Empty <Action <EndpointBuilder> >()); var routeEndpoint = Assert.IsType <RouteEndpoint>(endpoint); return(routeEndpoint, routeModel); }
internal static RatedRouteDto GetDefaultRoute(Rbr_Db pDb, CarrierAcctDto pCarrierAcct, RouteState pValid) { var _defaultCarrierRouteRow = pDb.CarrierRouteCollection.GetByPrimaryKey(-pCarrierAcct.CarrierAcctId); //if (pCarrierAcctRow.IsRatingEnabled) { //NOTE: DefaultRatingInfo is always created no metter what //and it should be loaded as well no metter what //} var _baseRoute = RoutingManager.GetBaseRoute(pDb, _defaultCarrierRouteRow.Route_id); return(mapToRoute(_defaultCarrierRouteRow, pCarrierAcct, _baseRoute, pValid)); }
static RatedRouteDto mapToRoute(CarrierRouteRow pCarrierRouteRow, CarrierAcctDto pCarrierAcct, BaseRouteDto pBaseRoute, RouteState pCarrierRouteState) { if (pCarrierRouteRow == null) { return(null); } var _route = new RatedRouteDto(); _route.RatedRouteId = pCarrierRouteRow.Carrier_route_id; _route.Status = pCarrierRouteRow.RouteStatus; _route.ACDTarget = pCarrierRouteRow.Acd_target; _route.ACDTimeWindow = pCarrierRouteRow.Acd_time_window; _route.ASRTarget = pCarrierRouteRow.Asr_target; _route.ASRTimeWindow = pCarrierRouteRow.Asr_time_window; _route.NextEP = pCarrierRouteRow.Next_ep; _route.AccountId = pCarrierAcct.CarrierAcctId; _route.AccountName = pCarrierAcct.Name; _route.AccountStatus = pCarrierAcct.Status; _route.BaseRoute = pBaseRoute; _route.RouteState = pCarrierRouteState; _route.DefaultRatingInfo = pCarrierAcct.DefaultRatingInfo; return(_route); }
static RatedRouteDto mapToRoute(WholesaleRouteRow pWholesaleRouteRow, int pRoutingPlanId, RoutingAlgorithmType pRoutingAlgorithmType, ServiceDto pService, BaseRouteDto pBaseRoute, RouteState pRouteState) { if (pWholesaleRouteRow == null) { return(null); } var _route = new RatedRouteDto { RatedRouteId = pWholesaleRouteRow.Wholesale_route_id, AccountId = pService.ServiceId, AccountName = pService.Name, AccountStatus = pService.Status, RoutingPlanId = pRoutingPlanId, Algorithm = pRoutingAlgorithmType, Status = pWholesaleRouteRow.RouteStatus, BaseRoute = pBaseRoute, RouteState = pRouteState, DefaultRatingInfo = pService.DefaultRatingInfo }; return(_route); }
private void FixedUpdate() { switch (state) { case RouteState.onMove: if (transform.position != enemyRoute.routeList[curRouteIndex].destination) { transform.position = Vector3.MoveTowards( transform.position, enemyRoute.routeList[curRouteIndex].destination, enemyRoute.routeList[curRouteIndex].linearVelocity * Time.fixedDeltaTime); } else if (enemyWeapon != null && enemyRoute.routeList[curRouteIndex].isFireOnWait) { if (enemyRoute.routeList[curRouteIndex].isWeaponRefresh) { enemyWeapon.initializeWeapons(); } enemyWeapon.setWeaponDisabled(!enemyRoute.routeList[curRouteIndex].isFireOnWait); state = RouteState.onFire; } else if (enemyRoute.routeList[curRouteIndex].waitTime >= 0.02f) { setToWait(); } else { setToNext(); } break; case RouteState.onFire: if (enemyWeapon.getCurWeaponData().isOnEnd()) { enemyWeapon.setWeaponDisabled(true); setToWait(); } break; case RouteState.onWait: if (!enemyRoute.routeList[curRouteIndex].isWaitTimeOut()) { enemyRoute.routeList[curRouteIndex].countWaitTime(Time.fixedDeltaTime); } else { setToNext(); } break; case RouteState.onStart: curRouteIndex = 0; setToMove(); break; case RouteState.onEnd: if (isDestroyOnEnd) { Destroy(gameObject); } else if (isFireOnEnd) { if (enemyWeapon != null) { if (isWeaponRefreshOnEnd) { enemyWeapon.initializeWeapons(); } enemyWeapon.setWeaponDisabled(false); } } break; } }
private void setToWait() { enemyRoute.routeList[curRouteIndex].resetWaitTime(); state = RouteState.onWait; }
static BaseRouteDto mapToBaseRoute(RouteRow pRouteRow, CountryDto pCountry, CallingPlanDto pCallingPlan, RouteState pRouteState) { if (pRouteRow == null) { return(null); } var _baseRoute = new BaseRouteDto(); _baseRoute.BaseRouteId = pRouteRow.Route_id; _baseRoute.Name = pRouteRow.Name; _baseRoute.BaseStatus = pRouteRow.RouteStatus; _baseRoute.CallingPlan = pCallingPlan; _baseRoute.Country = pCountry; _baseRoute.RoutingNumber = pRouteRow.Routing_number; _baseRoute.Version = pRouteRow.Version; _baseRoute.RouteState = pRouteState; return(_baseRoute); }
static RoutingPlanDetailDto mapToRoutingPlanDetail(RoutingPlanDetailRow pRoutingPlanDetailRow, BaseRouteDto pBaseRoute, RoutingPlanDto pRoutingPlan, RouteState pRoutingPlanDetailRouteState) { if (pRoutingPlanDetailRow == null) { return(null); } var _routingPlanDetail = new RoutingPlanDetailDto(); _routingPlanDetail.RoutingPlan = pRoutingPlan; _routingPlanDetail.BaseRoute = pBaseRoute; _routingPlanDetail.Algorithm = pRoutingPlanDetailRow.Algorithm; _routingPlanDetail.RouteState = pRoutingPlanDetailRouteState; return(_routingPlanDetail); }