public async Task <IActionResult> Post([FromBody] RouteRule routeRule) { try { var repo = await _repo.Get(); var fileConfiguration = repo.Data; var reRoute = fileConfiguration.ReRoutes.Where(r => r.Key == routeRule.ApiGwSuffix).FirstOrDefault(); if (reRoute == null) { var fileReRoute = ObjectConverter.ConvertToFileReRoute(routeRule); fileConfiguration.ReRoutes.Add(fileReRoute); var response = await _setter.Set(fileConfiguration); if (response.IsError) { return(new BadRequestObjectResult(response.Errors)); } } else { return(new BadRequestObjectResult("Add FileReRoute Failed, Key is duplicate.")); } return(new OkObjectResult("OK")); } catch (Exception e) { _logger.Log(LogLevel.Error, "Post Method Happen Error For RerouteController."); return(new BadRequestObjectResult($"{e.Message}:{e.StackTrace}")); } }
static RouteHandler() { var totalActions = new[] { RouteConstants.DefaultDefault, RouteConstants.Default, RouteConstants.Article, RouteConstants.TagSearchDefault, RouteConstants.TagSearch, RouteConstants.KeywordSearchDefault, RouteConstants.KeywordSearch, RouteConstants.ListDefault, RouteConstants.List, RouteConstants.Create, RouteConstants.Edit, RouteConstants.Login, RouteConstants.Logout, RouteConstants.Error, RouteConstants.About }; foreach (var action in totalActions) { var routeRule = new RouteRule(); routeRule.RouteName = action; routeRule.RouteUrl = RouteConstants.UrlMapping[action]; routeRule.PhysicalFile = RouteConstants.PhysicalFileMapping[action]; _routeRules.Add(routeRule); } }
void ApplyRouteRule(StaticFile staticFile, Site site, string outputDirectory) { RouteRule routeRule = site.GetRoutingRuleFor(staticFile.Item); string route = routeRule.ApplyTo(staticFile, site); staticFile.Path = outputDirectory + route; }
protected void RegisterRoutes(IEnumerable <object> processors) { foreach (var presenter in processors) { var rule = RouteRule.UseInterfaceMessageHandler(presenter); RegisterRoute(rule); } }
public static bool IsCanaryRouteRule(RouteRule routeRule) { Preconditions.CheckArgument(routeRule != null, "route rule should not null"); if (routeRule.RouteId == null) { return(false); } return(string.Equals(CANARY_ROUTE_RULE, routeRule.RouteId.Trim().ToLower())); }
public void SetUp() { expected = "Trust No One"; staticFile = new StaticFile(CreateFakeItem()); site = CreateFakeSite(); routeRule = new RouteRule("*", (ruleContext) => { return(expected); }); }
public void SetUp() { expected = "Trust No One"; staticFile = new StaticFile(CreateFakeItem()); site = CreateFakeSite(); routeRule = new RouteRule("*", (ruleContext) => { return expected; }); }
internal static RoutingProvider GetInterfaceBasedRoutingProvider(params object[] processors) { var router = new RoutingProvider(); foreach (var processor in processors) { router.RegisterRoute(RouteRule.UseInterfaceMessageHandler(processor)); } return(router); }
internal static void PrintRendererInfo(ChaControl chaCtrl, GameObject go, bool chara = false) { if (go == null) { return; } MaterialRouterController pluginCtrl = GetController(chaCtrl); Renderer[] rends = go.GetComponentsInChildren <Renderer>(true); List <RouteRule> rules = new List <RouteRule>(); int skipped = 0; foreach (Renderer rend in rends) { foreach (Material mat in rend.materials) { string ObjPath = GetGameObjectPath(rend.transform).Replace(chaCtrl.gameObject.name + "/", ""); string MatName = mat.NameFormatted(); RouteRule rule = new RouteRule { GameObjectPath = ObjPath, Action = Action.Clone, OldName = MatName, NewName = MatName + "_cloned" }; RouteRule exist = null; if (chara) { exist = pluginCtrl.BodyTrigger.Where(x => x.GameObjectPath == ObjPath && x.NewName == MatName).FirstOrDefault(); } else { exist = pluginCtrl.CurOutfitTrigger.Where(x => x.GameObjectPath == ObjPath && x.NewName == MatName).FirstOrDefault(); } if (exist != null) { if (CfgSkipCloned.Value) { skipped++; continue; } else { rule.Action = exist.Action; } } rules.Add(rule); } } Logger.LogWarning($"cloned/renamed skipped: {skipped}\n" + JSONSerializer.Serialize(rules.GetType(), rules, true)); }
internal static RoutingProvider GetStaticRoutingWithInterfaceRoutingProvider(params object[] processors) { var router = new RoutingProvider(); foreach (var processor in processors) { router.RegisterRoute(new RouteRule(processor, RouteOptions.UseStaticDefaultTemplate())); router.RegisterRoute(RouteRule.UseInterfaceMessageHandler(processor)); } return(router); }
public async Task <IActionResult> Get(string id) { var repo = await _repo.Get(); var fileRoute = repo.Data.ReRoutes.Where(r => r.Key == id).FirstOrDefault(); if (fileRoute == null) { return(new BadRequestObjectResult(new { Code = 1, Message = "the rule is not exist." })); } RouteRule rule = ObjectConverter.ConvertToRouteRule(fileRoute); return(new OkObjectResult(rule)); }
/** * Configure the default RouteTable of the specified InternetGateway to ensure it * contains a single outbound route for all traffic. * * NB: You should restrict these routes further if you keep this piece of * OCI infrastructure. * * @param vcnClient the service client to use to query a RouteTable. * @param routeTableId of the default route table associated with the VCN. * @param igId of the RouteTable's associated InternetGateway. */ private static async Task AddInternetGatewayToDefaultRouteTable(VirtualNetworkClient vcnClient, string routeTableId, string igId) { GetRouteTableRequest getRouteTableRequest = new GetRouteTableRequest { RtId = routeTableId }; GetRouteTableResponse getRouteTableResponse = await vcnClient.GetRouteTable(getRouteTableRequest); var routeRules = getRouteTableResponse.RouteTable.RouteRules; logger.Info("Current Route Rules in Default Route Table"); logger.Info("=========================================="); routeRules.ForEach(delegate(RouteRule rule) { logger.Info($"rule: {rule.NetworkEntityId}"); }); RouteRule internetAccessRoute = new RouteRule { Destination = "0.0.0.0/0", DestinationType = RouteRule.DestinationTypeEnum.CidrBlock, NetworkEntityId = igId }; routeRules.Add(internetAccessRoute); UpdateRouteTableDetails updateRouteTableDetails = new UpdateRouteTableDetails { RouteRules = routeRules, DisplayName = RouteTableName }; UpdateRouteTableRequest updateRouteTableRequest = new UpdateRouteTableRequest { UpdateRouteTableDetails = updateRouteTableDetails, RtId = routeTableId }; UpdateRouteTableResponse updateRouteTableResponse = await vcnClient.UpdateRouteTable(updateRouteTableRequest); getRouteTableResponse = vcnClient.Waiters.ForRouteTable(getRouteTableRequest, RouteTable.LifecycleStateEnum.Available).Execute(); routeRules = getRouteTableResponse.RouteTable.RouteRules; logger.Info("Updated Route Rules in Default Route Table"); logger.Info("=========================================="); routeRules.ForEach(delegate(RouteRule rule) { logger.Info($"rule: {rule.NetworkEntityId}\n"); }); }
public void Foo() { var m = new MessageDerived(); var rp = new RoutingProvider(); rp.RegisterRoute(RouteRule.UseInterfaceMessageHandler(new Handler())); //rp.RouteCall<ISessionStarted>(x => x.SessionStarted()); rp.RouteObject(m); rp.RouteObject(11); rp.RouteObject(11L); //var t = new List<string>(); //List<object> l= (List<object>)t; //rp.RouteObject(new Context(), m); }
internal void ImportFromRendererInfo(int SlotIndex) { GameObject go = ChaControl.GetAccessoryObject(SlotIndex); if (go == null) { return; } Renderer[] rends = go.GetComponentsInChildren <Renderer>(true); List <RouteRule> rules = new List <RouteRule>(); int skipped = 0; int added = 0; foreach (Renderer rend in rends) { foreach (Material mat in rend.materials) { string ObjPath = GetGameObjectPath(rend.transform).Replace(ChaControl.gameObject.name + "/", ""); string MatName = mat.NameFormatted(); RouteRule rule = new RouteRule { GameObjectPath = ObjPath, Action = Action.Clone, OldName = MatName, NewName = MatName + "_cloned" }; RouteRule exist = CurOutfitTrigger.Where(x => x.GameObjectPath == ObjPath && x.NewName == MatName).FirstOrDefault(); if (exist != null) { skipped++; continue; } CurOutfitTrigger.Add(rule); added++; } } Logger.LogMessage($"skipped: {skipped}, added: {added}"); }
public async Task <IActionResult> Put(string id, [FromBody] RouteRule routeRule) { var repo = await _repo.Get(); var fileConfiguration = repo.Data; var reRoute = fileConfiguration.ReRoutes.Where(r => r.Key == routeRule.ApiGwSuffix).FirstOrDefault(); if (reRoute == null) { return(new BadRequestObjectResult("The route rule is not exist.")); } var newRoute = ObjectConverter.ConvertToFileReRoute(routeRule); reRoute.UpstreamPathTemplate = newRoute.UpstreamPathTemplate; reRoute.DownstreamScheme = newRoute.DownstreamScheme; reRoute.DownstreamHostAndPorts = newRoute.DownstreamHostAndPorts; reRoute.DownstreamPathTemplate = newRoute.DownstreamPathTemplate; reRoute.AuthenticationOptions = newRoute.AuthenticationOptions; return(new OkObjectResult("OK")); }