public void UrlParameters_Returns_ParametersDefinedOnTheAttribute() { var routeInfo = new RouteInfo(_testMethod); var urlParameters = routeInfo.QueryParameters; var parameters = string.Join(",", urlParameters.Select(a => a.Name)); Assert.Equal("p1,p2,p3,gender,date,list,numbers", parameters); }
public void RouteInfoComparisonTest() { // Create route infos and add them to a list out of order. RouteInfo r101Both = new RouteInfo { Name = "101", LrsTypes = LrsTypes.Both }; RouteInfo r005Both = new RouteInfo { Name = "005", LrsTypes = LrsTypes.Both }; RouteInfo r005Inc = new RouteInfo { Name = "005", LrsTypes = LrsTypes.Increase }; List<RouteInfo> routeInfo = new List<RouteInfo>(); routeInfo = new List<RouteInfo>(3); routeInfo.Add(r101Both); routeInfo.Add(r005Both); routeInfo.Add(r005Inc); // Sort the list and test for the expected order. routeInfo.Sort(); Assert.AreEqual(routeInfo[0], r005Inc); Assert.AreEqual(routeInfo[1], r005Both); Assert.AreEqual(routeInfo[2], r101Both); }
public ActionResult OEmbed(string url, int maxwidth = 570, int maxheight = 400, DataFormat format = DataFormat.Json) { if (string.IsNullOrEmpty(url)) return HttpStatusCodeResult(HttpStatusCode.BadRequest, "URL not specified"); var route = new RouteInfo(new Uri(url), AppConfig.HostAddress).RouteData; var controller = route.Values["controller"].ToString().ToLowerInvariant(); if (controller != "song" && controller != "s") { return HttpStatusCodeResult(HttpStatusCode.BadRequest, "Only song embeds are supported"); } int id; if (controller == "s") { var match = Regex.Match(route.Values["action"].ToString(), @"(\d+)"); id = int.Parse(match.Groups[1].Value); } else { id = int.Parse(route.Values["id"].ToString()); } var song = Services.Songs.GetSong(id); var html = string.Format("<iframe src=\"{0}\" width=\"{1}\" height=\"{2}\"></iframe>", VocaUriBuilder.CreateAbsolute(Url.Action("EmbedSong", new {songId = id})), maxwidth, maxheight); return Object(new SongOEmbedResponse(song, maxwidth, maxheight, html), format); }
public RouteDetail(RouteInfo routeInfo, Func<Type, ModelDescription> modelDescriptionCreator) { _routeInfo = routeInfo; _modelDescriptionCreator = modelDescriptionCreator; LoadUrlParameters(); LoadBodyParameter(); LoadReturnParameter(); }
public void ReturnParameter_Returns_ReturnParameter() { var routeInfo = new RouteInfo(_testMethod); var returnParameter = routeInfo.ReturnParameter; Assert.NotNull(returnParameter); Assert.Equal(typeof(TestResult), returnParameter.ParameterType); }
public void HandlesRoutesWithNoConstraints() { var constraints = new RouteValueDictionary(); var routeInfo = new RouteInfo { Constraints = new RouteValueDictionary() }; var processor = new ConstraintsProcessor(); processor.ProcessConstraints(constraints, routeInfo); Assert.AreEqual(0, routeInfo.Constraints.Count); }
public virtual void Begin(HttpRequest req, HttpResponse res, RouteInfo route, Application app) { this.Request = req; this.Response = res; this.RouteInfo = route; this.App = app; // Start the show this.PreHandle(); }
public void IncludesRegExpConstraints() { var constraints = new RouteValueDictionary {{"id", @"\d+"}}; var routeInfo = new RouteInfo { Constraints = new RouteValueDictionary() }; var processor = new ConstraintsProcessor(); processor.ProcessConstraints(constraints, routeInfo); Assert.AreEqual(1, routeInfo.Constraints.Count); Assert.AreEqual(@"\d+", routeInfo.Constraints["id"]); }
public static MvcHtmlString RouteLinkExists(this HtmlHelper helper, RouteInfo routeInfo) { bool isNotAuthType = true; if (routeInfo.AccessType == RouteAccessType.Auth) { foreach (string role in Roles.GetRolesForUser()) { var userType = (WFSUserTypeEnum)Enum.Parse(typeof(WFSUserTypeEnum), role); if (isNotAuthType) isNotAuthType = !((routeInfo.UserType == userType) && routeInfo.AccessType == RouteAccessType.Auth); } } else { isNotAuthType = false; } bool isNotAuth = HttpContext.Current.User.Identity.IsAuthenticated && routeInfo.AccessType == RouteAccessType.NonAuth; bool isAuth = HttpContext.Current.User.Identity.IsAuthenticated && routeInfo.AccessType == RouteAccessType.NonAuth; bool isActive = routeInfo.IsActive(); // auth type filter if (isNotAuth || isNotAuthType || !isActive) { return new MvcHtmlString(string.Empty); } if (helper.RouteCollection[routeInfo.RouteName] == null) { throw new Exception(string.Format(EXC_ROUTE_NOTFOUND, routeInfo.RouteName)); } string area = (((System.Web.Routing.Route)(helper.RouteCollection[routeInfo.RouteName])).DataTokens["area"] ?? "").ToString(); string currentArea = (helper.ViewContext.RouteData.DataTokens["area"] ?? "").ToString(); string url = String.Format("/{0}", ((System.Web.Routing.Route)(helper.RouteCollection[routeInfo.RouteName])).Url); if (routeInfo.IsDisabled()) { return new MvcHtmlString(string.Format(TMP_URL, "disabledMenuItem", "", helper.RouteLink(routeInfo.LinkText, routeInfo.RouteName, routeInfo.RouteValues, routeInfo.HtmlAttributes).ToHtmlString())); } else if (url == HttpContext.Current.Request.Url.AbsolutePath) { return new MvcHtmlString(string.Format(TMP_URL, "active", routeInfo.RouteMatchClass, helper.RouteLink(routeInfo.LinkText, routeInfo.RouteName, routeInfo.RouteValues, routeInfo.HtmlAttributes).ToHtmlString())); } else if (area == currentArea && !routeInfo.ExactMatch) { return new MvcHtmlString(string.Format(TMP_URL, "", "", helper.RouteLink(routeInfo.LinkText, routeInfo.RouteName, routeInfo.RouteValues, routeInfo.HtmlAttributes).ToHtmlString())); } return new MvcHtmlString(string.Format(TMP_URL, "", "", helper.RouteLink(routeInfo.LinkText, routeInfo.RouteName, routeInfo.RouteValues, routeInfo.HtmlAttributes).ToHtmlString())); }
private RouteInfo Parse(string template) { var parser = new RouteTemplateParser(); var parsedTemplate = TemplateParser.Parse(template); var info = new RouteInfo { Defaults = new Dictionary<string, object>(), Optional = new List<string>(), }; parser.Parse(parsedTemplate, info); return info; }
public static MvcHtmlString RouteLinkExists(this HtmlHelper helper, string linkText, string routeName, object routeValues, object htmlAttributes, string routeMatchesClass, bool exactMatch) { RouteInfo routeInfo = new RouteInfo(); routeInfo.AccessType = RouteAccessType.All; routeInfo.ExactMatch = exactMatch; routeInfo.HtmlAttributes = htmlAttributes; routeInfo.LinkText = linkText; routeInfo.RouteMatchClass = routeMatchesClass; routeInfo.RouteName = routeName; routeInfo.RouteValues = routeValues; return helper.RouteLinkExists(routeInfo); }
public void ExcludesCustomConstraints() { var customConstraint = new Mock<IRouteConstraint>(); var constraints = new RouteValueDictionary { { "id", @"\d+" }, { "awesome", customConstraint }, }; var routeInfo = new RouteInfo { Constraints = new RouteValueDictionary() }; var processor = new ConstraintsProcessor(); processor.ProcessConstraints(constraints, routeInfo); Assert.AreEqual(1, routeInfo.Constraints.Count); }
public void BuildEndpoints_Header_Works() { var services = CreateServices(); var factory = services.GetRequiredService <ProxyEndpointFactory>(); factory.SetProxyPipeline(context => Task.CompletedTask); var route = new ProxyRoute { RouteId = "route1", Match = new ProxyMatch { Path = "/", Headers = new[] { new RouteHeader() { Name = "header1", Values = new[] { "value1" }, Mode = HeaderMatchMode.HeaderPrefix, IsCaseSensitive = true, } } }, }; var cluster = new ClusterInfo("cluster1"); var routeInfo = new RouteInfo("route1"); var(routeEndpoint, routeConfig) = CreateEndpoint(factory, routeInfo, route, cluster); Assert.Same(cluster, routeConfig.Cluster); Assert.Equal("route1", routeEndpoint.DisplayName); var headerMetadata = routeEndpoint.Metadata.GetMetadata <IHeaderMetadata>(); Assert.NotNull(headerMetadata); var matchers = headerMetadata.Matchers; Assert.Single(matchers); var matcher = matchers.Single(); Assert.Equal("header1", matcher.Name); Assert.Equal(new[] { "value1" }, matcher.Values); Assert.Equal(HeaderMatchMode.HeaderPrefix, matcher.Mode); Assert.True(matcher.IsCaseSensitive); Assert.False(routeConfig.HasConfigChanged(route, cluster, routeInfo.ClusterRevision)); }
private void SpawnMonsters() { var topLeftLocation = new Point(CurrentLocation.X - Info.EventSize, CurrentLocation.Y - Info.EventSize); foreach (var eventRespawn in Info.Respawns) { var respawnInfo = new RespawnInfo(); var monster = Envir.GetMonsterInfo(eventRespawn.MonsterName); if (monster == null) { SMain.EnqueueDebugging(string.Format("{0} Activating Event:{1} FAILED COULDN'T FIND MONSTER {2}", Map.Info.FileName, Info.EventName, eventRespawn.MonsterName)); return; } respawnInfo.Spread = eventRespawn.MonsterCount; respawnInfo.Count = eventRespawn.MonsterCount; respawnInfo.MonsterIndex = monster.Index; respawnInfo.Delay = 10000; respawnInfo.SaveRespawnTime = false; respawnInfo.RespawnIndex = 0; respawnInfo.RespawnTicks = 0; if (eventRespawn.SpreadY == 0 && eventRespawn.SpreadX == 0 && eventRespawn.MonsterCount == 1) { respawnInfo.Location = CurrentLocation; } else { respawnInfo.Location = new Point(topLeftLocation.X + eventRespawn.SpreadX * 2, topLeftLocation.Y + eventRespawn.SpreadY * 2); } MapRespawn mapRespawn = new MapRespawn(respawnInfo); RouteInfo route = new RouteInfo(); route.Location = respawnInfo.Location; route.Delay = 1000; mapRespawn.Route.Add(route); mapRespawn.Map = Map; mapRespawn.IsEventObjective = eventRespawn.IsObjective; mapRespawn.Event = this; MapRespawns.Add(mapRespawn); } Map.Respawns.AddRange(MapRespawns); }
private void SpawnMonstersForInvasion(List <EventRespawn> respawns) { var topLeftLocation = new Point(CurrentLocation.X - Info.EventSize, CurrentLocation.Y - Info.EventSize); foreach (var eventRespawn in respawns) { var monster = Envir.GetMonsterInfo(eventRespawn.MonsterName); if (monster == null) { SMain.EnqueueDebugging(string.Format("{0} Event:{1} FAILED COULDN'T FIND MONSTER {2}", Map.Info.FileName, Info.EventName, eventRespawn.MonsterName)); continue; } var respawnInfo = new RespawnInfo() { Spread = eventRespawn.MonsterCount, Count = eventRespawn.MonsterCount, MonsterIndex = monster.Index, Delay = ushort.MaxValue }; if (eventRespawn.SpreadY == 0 && eventRespawn.SpreadX == 0) { respawnInfo.Location = CurrentLocation; } else { respawnInfo.Location = new Point(topLeftLocation.X + eventRespawn.SpreadX * 2, topLeftLocation.Y + eventRespawn.SpreadY * 2); } MapRespawn mapRespawn = new MapRespawn(respawnInfo); RouteInfo route = new RouteInfo() { Location = respawnInfo.Location, Delay = 1000, }; mapRespawn.Route.Add(route); mapRespawn.Map = Map; mapRespawn.IsEventObjective = eventRespawn.IsObjective; mapRespawn.Event = this; MapRespawns.Add(mapRespawn); } Map.Respawns.AddRange(MapRespawns); }
public void Get_WithId_ReturnOne() { //arrange var controller = new AutoAPI.RESTAPIController(SetupHelper.BuildTestContext(), null, null); var routeInfo = new RouteInfo() { Entity = entityList.Where(x => x.Route == "/api/authors").First(), Id = "1" }; //act var result = (OkObjectResult)controller.Get(routeInfo); //assert Assert.Equal(200, result.StatusCode.Value); Assert.Equal(1, ((Author)result.Value).Id); Assert.Equal("Ernest Hemingway", ((Author)result.Value).Name); }
public static async Task <T> Patch_ModelAsync <T>(Api.Models.PointModel point) { var routeInfo = new RouteInfo { HttpMethods = "PATCH", Path = Patch_Model, Parameters = new List <ParameterInfo> { new ParameterInfo() { Name = "point", Type = "Api.Models.PointModel" }, } }; return(await HttpClientAsync.Async <T>(routeInfo, point)); }
void SetRouteInfo(string Code, string Segment, EndPoint point) { if (RouteList.ContainsKey(Code)) { RouteList[Code].RemotePoint = point; RouteList[Code].IsOnline = true; RouteList[Code].Segment = Segment; } else { RouteInfo info = new RouteInfo(); info.RemotePoint = point; info.Segment = Segment; info.IsOnline = true; RouteList.Add(Code, info); } }
public void HandlesOptionalParameters() { var routes = new RouteCollection(); routes.MapRoute( name: "Hello", url: "hello/world/{id}", defaults: new { controller = "Hello", action = "HelloWorld", id = UrlParameter.Optional } ); var routeInfo = new RouteInfo(); var defaultsProcessor = new DefaultsProcessor(); defaultsProcessor.ProcessDefaults((Route)routes["Hello"], routeInfo); Assert.IsTrue(routeInfo.Optional.Contains("id")); }
public static async Task <T> Patch_1_FromBodyAsync <T>(string key) { var routeInfo = new RouteInfo { HttpMethods = "PATCH", Path = Patch_1_FromBody, Parameters = new List <ParameterInfo> { new ParameterInfo() { Name = "key", Type = "string" }, } }; return(await HttpClientAsync.Async <T>(routeInfo, key)); }
private static IEnumerable<RouteInfo> GetRouteInfo() { var items = new List<RouteInfo>(); foreach (var route in RouteTable.Routes.Cast<Route>()) { var item = new RouteInfo { Url = route.Url }; if (route.Defaults != null) { foreach (var @default in route.Defaults) item.Defaults.Add(@default.Key, @default.Value.ToString()); } if (route.Constraints != null) { foreach (var constraint in route.Constraints) { if (constraint.Value == null) continue; if (constraint.Value.GetType() == typeof(RestfulHttpMethodConstraint)) item.HttpMethod = String.Join(", ", ((RestfulHttpMethodConstraint)constraint.Value).AllowedMethods); else if (constraint.Value.GetType() == typeof(RegexRouteConstraint)) item.Constraints.Add(constraint.Key, ((RegexRouteConstraint)constraint.Value).Pattern); else item.Constraints.Add(constraint.Key, constraint.Value.ToString()); } } if (route.DataTokens != null) { foreach (var token in route.DataTokens) { if (token.Key.ValueEquals("namespaces")) item.DataTokens.Add(token.Key, ((string[])token.Value).Aggregate((n1, n2) => n1 + ", " + n2)); else item.DataTokens.Add(token.Key, token.Value.ToString()); } } items.Add(item); } return items; }
private void BindRouteName() { RouteController routeController = new RouteController(); RouteCollections routeCollection = routeController.SelectList(); RouteInfo info = new RouteInfo(); info.RouteName = " - Select One - "; info.RouteID = null; routeCollection.Insert(0, info); cboRoute.DisplayMember = "RouteName"; cboRoute.ValueMember = "RouteID"; cboRoute.DataSource = routeCollection; cboRoute.SelectedIndex = 0; }
public void Delete_WithIdID_Deletes() { //arrange var testContext = SetupHelper.BuildTestContext(); var controller = new AutoAPI.RESTAPIController(testContext, null, null); var routeInfo = new RouteInfo() { Entity = entityList.Where(x => x.Route == "/api/authors").First(), Id = "1" }; //act var result = (OkObjectResult)controller.Delete(routeInfo); //assert Assert.Equal(200, result.StatusCode); Assert.Null(testContext.Authors.Find(1)); }
public static async Task <T> GetByIdAsync <T>(int id) { var routeInfo = new RouteInfo { HttpMethods = "GET", Path = GetById, Parameters = new List <ParameterInfo> { new ParameterInfo() { Name = "id", Type = "int" }, } }; return(await HttpClientAsync.Async <T>(routeInfo, id)); }
public ModelEndpointDataSourceReport(EndpointDataSource endpointDataSource) : base(endpointDataSource) { foreach (var endpoint in endpointDataSource.Endpoints.OrderBy(ep => (ep as RouteEndpoint)?.Order ?? -1)) { var meta = ExtractMetadata(endpoint.Metadata); var routeInfo = new RouteInfo() { DisplayName = endpoint.DisplayName, Meta = meta, RoutePattern = (endpoint as RouteEndpoint)?.RoutePattern.RawText.ToString(), HttpMethods = string.Join(",", endpoint.Metadata.OfType <HttpMethodMetadata>().SelectMany(h => h.HttpMethods).Distinct()) }; var values = typeof(RouteInfo).GetProperties().Select(p => p.GetValue(routeInfo)?.ToString() ?? string.Empty).ToArray(); _rows.Add(values); } }
public async Task <Result <RouteInfo> > GetRouteInfoAsync(string carTagId) { FormUrlEncodedContent content = new FormUrlEncodedContentBuilder() .Add("CarTagId", carTagId) .Build(); HttpClient client = NetUtils.Instance(); HttpResponseMessage respone = await client.PostAsync(NetURL.URL_ROUTE_INFO, content); RouteInfo routeInfo = null; ResponseResult result = NetUtils.ExplainHttpResponce(respone); if (result.StateCode == 200) { routeInfo = RouteInfo.InstanceFormJson(result.Data); } return(Result <RouteInfo> .FromResponseResult(result, routeInfo)); }
public static async Task <T> Get_1_Nullable_ConstraintAsync <T>(int?id) { var routeInfo = new RouteInfo { HttpMethods = "GET", Path = Get_1_Nullable_Constraint, Parameters = new List <ParameterInfo> { new ParameterInfo() { Name = "id", Type = "int?" }, } }; return(await HttpClientAsync.Async <T>(routeInfo, id)); }
public void Get_WithCount_ReturnCount() { //arrange var controller = new AutoAPI.RESTAPIController(SetupHelper.BuildTestContext(), null, null); var routeInfo = new RouteInfo() { Entity = entityList.Where(x => x.Route == "/api/authors").First(), IsCount = true }; //act var result = (OkObjectResult)controller.Get(routeInfo); //assert Assert.Equal(200, result.StatusCode.Value); Assert.Equal(2, (int)result.Value); }
public static async Task <T> EditAsync <T>(Api.Models.PointModel model) { var routeInfo = new RouteInfo { HttpMethods = "POST", Path = Edit, Parameters = new List <ParameterInfo> { new ParameterInfo() { Name = "model", Type = "Api.Models.PointModel" }, } }; return(await HttpClientAsync.Async <T>(routeInfo, model)); }
public static async Task <T> Delete_1_Nullable_ParameterAsync <T>(int?id) { var routeInfo = new RouteInfo { HttpMethods = "DELETE", Path = Delete_1_Nullable_Parameter, Parameters = new List <ParameterInfo> { new ParameterInfo() { Name = "id", Type = "int?" }, } }; return(await HttpClientAsync.Async <T>(routeInfo, id)); }
private RouteInfo Create() { var route = new RouteInfo() { Name = Guid.NewGuid().ToString("N"), Hosts = new string[] { "www.konghq.com" }, Methods = new string[] { "GET" }, Protocols = new string[] { "http" }, Https_redirect_status_code = 301, Service = new RouteInfo.ServiceId() { Id = TestCases.SERVICE_ID } }; return(route); }
public static async Task <T> DeleteAsync <T>(string id) { var routeInfo = new RouteInfo { HttpMethods = "DELETE", Path = Delete, Parameters = new List <ParameterInfo> { new ParameterInfo() { Name = "id", Type = "string" }, } }; return(await HttpClientAsync.Async <T>(routeInfo, id)); }
public static async Task <T> GetPostByEmailAsync <T>(string email) { var routeInfo = new RouteInfo { HttpMethods = "GET", Path = GetPostByEmail, Parameters = new List <ParameterInfo> { new ParameterInfo() { Name = "email", Type = "string" }, } }; return(await HttpClientAsync.Async <T>(routeInfo, email)); }
/// <summary> /// Builds a tool tip text containing the overall information generated out of all routes. /// </summary> /// <returns>Tool tip text. Returns an empty string if there is any route with an error.</returns> public string GetToolTip() { if (routes.Count(r => r.HasRoutePolyline) != routes.Count) { return(""); } var info = new RouteInfo(); foreach (var r in routes) { info.time += r.RouteInfo.time; info.distance += r.RouteInfo.distance; } return(Route.FormatRouteToolTip(First.Label, Last.Label, info)); }
/// <summary> /// 時間、金額、乗り換え回数取得 /// </summary> /// <param name="Info"></param> private RouteInfo GetElement(IEnumerable <XElement> Info) { int i = 0; var rI = new RouteInfo(); foreach (XElement el in Info) { switch (i) { case 0: rI.Time = el.Value; //Debug.Log(rI.Time); rI.LeftTime = rI.Time.Remove(5); rI.ArriveTime = rI.Time.Remove(13).Remove(0, 8); if (IsDebug) { Debug.Log("出発: " + rI.LeftTime); Debug.Log("到着: " + rI.ArriveTime); } break; case 1: rI.TCount = int.Parse(el.Value.Remove(el.Value.Length - 1).Remove(0, 3)); if (IsDebug) { Debug.Log("乗り換え回数: " + (rI.TCount + 1)); } Array.Resize(ref rI.TransTime, 2 + 2 * rI.TCount); break; case 2: rI.Money = int.Parse(el.Value.Remove(el.Value.Length - 1).Remove(0, 3)); if (IsDebug) { Debug.Log("料金: " + rI.Money); } break; default: break; } i++; } return(rI); }
/// <summary> /// Function to Update values in Route Table /// </summary> /// <param name="routeinfo"></param> /// <returns></returns> public bool RouteEditing(RouteInfo routeinfo) { bool isEdit = false; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("RouteEditing", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@routeId", SqlDbType.Decimal); sprmparam.Value = routeinfo.RouteId; sprmparam = sccmd.Parameters.Add("@routeName", SqlDbType.VarChar); sprmparam.Value = routeinfo.RouteName; sprmparam = sccmd.Parameters.Add("@areaId", SqlDbType.Decimal); sprmparam.Value = routeinfo.AreaId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = routeinfo.Narration; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = routeinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = routeinfo.Extra2; int ina = sccmd.ExecuteNonQuery(); if (ina > 0) { isEdit = true; } else { isEdit = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(isEdit); }
public void HandlesMvcControllerAndAction() { var routes = new RouteCollection(); routes.MapRoute( name: "Hello", url: "hello/world", defaults: new { controller = "Hello", action = "HelloWorld" } ); var routeInfo = new RouteInfo(); var defaultsProcessor = new DefaultsProcessor(); defaultsProcessor.ProcessDefaults((Route)routes["Hello"], routeInfo); Assert.AreEqual("Hello", routeInfo.Defaults["controller"]); Assert.AreEqual("HelloWorld", routeInfo.Defaults["action"]); }
bool ContainsEqualRouteInfo(ICollection <RouteInfo> routeInfoCollection, RouteInfo routeInfo, bool ignoreSelf) { foreach (var item in routeInfoCollection) { bool valuesEqual = item.Name == routeInfo.Name && item.Order == routeInfo.Order && item.Template == routeInfo.Template; bool updateTypesEqual = UpdateTypeCollectionsEqual(item.UpdateTypes, routeInfo.UpdateTypes); bool isEqual = valuesEqual && updateTypesEqual; if (isEqual) { bool isSelf = item == routeInfo; if (!(ignoreSelf && isSelf)) { return(true); } } } return(false); }
public void HandlesAreas() { var routes = new RouteCollection(); var areaReg = new AreaRegistrationContext("Foobar", routes); areaReg.MapRoute( name: "Hello", url: "hello/world", defaults: new { controller = "Hello", action = "HelloWorld" } ); var routeInfo = new RouteInfo(); var defaultsProcessor = new DefaultsProcessor(); defaultsProcessor.ProcessDefaults((Route)routes["Hello"], routeInfo); Assert.AreEqual("Foobar", routeInfo.Defaults["area"]); }
public ActionResult EntryToolTip(string url, string callback) { var route = new RouteInfo(new Uri(url), AppConfig.HostAddress).RouteData; var controller = route.Values["controller"].ToString(); var id = int.Parse(route.Values["id"].ToString()); string data = string.Empty; switch (controller) { case "Album": data = RenderPartialViewToString("AlbumWithCoverPopupContent", Services.Albums.GetAlbum(id)); break; case "Artist": data = RenderPartialViewToString("ArtistPopupContent", Services.Artists.GetArtist(id)); break; } return Json(data, callback); }
public static string ExtractEndpoint(ResolvedServicePartition resolved, RouteInfo validRoute) { var resolvedEndpoints = resolved.Endpoints.First().Address; var rawAddress = JsonObject.Parse(resolvedEndpoints); var endpoints = rawAddress["Endpoints"] as JsonObject; if (endpoints == null) { return(string.Empty); } var endpoint = endpoints.Count == 1 ? endpoints.First().Value.ToString() : endpoints[validRoute.ListenerName] as string ?? ""; return(endpoint); }
/// <summary> /// 乗り換え番線を取得したい人生だった /// 現状2回以上の乗り換えに対応してません。 /// </summary> /// <param name="Info"></param> /// <param name="rI"></param> /// <returns></returns> private void GetTLine(IEnumerable <XElement> Info, RouteInfo rI) { int i = 0; foreach (XElement el in Info) { if (i < 2) { //Debug.Log(el.Value.Replace(" ", "").Replace(" ", "").Replace("\n", "")); rI.TLine[i] = el.Value.Replace(" ", "").Replace(" ", "").Replace("\n", ""); i++; } else { break; } } }
private TreeNodeViewModel CreateRouteNode(TreeNodeViewModel parentNode, RouteInfo route) { TreeNodeViewModel node = new TreeNodeViewModel() { Parent = parentNode, IsExpanded = false, NodeIcon = ROUTE_ICON, NodeText = route.Name, NodeToolTip = route.ToString(), NodePayload = route }; node.ContextMenuItems.Add(new MenuItemViewModel() { MenuItemHeader = "Edit route settings", MenuItemIcon = EDIT_QUEUE_ICON, MenuItemCommand = new RelayCommand(EditRouteCommand), MenuItemPayload = node }); node.ContextMenuItems.Add(new MenuItemViewModel() { IsSeparator = true }); node.ContextMenuItems.Add(new MenuItemViewModel() { MenuItemHeader = "Send test message to remote queue", MenuItemIcon = SEND_MESSAGE_ICON, MenuItemCommand = new RelayCommand(SendTestMessageCommand), MenuItemPayload = node }); node.ContextMenuItems.Add(new MenuItemViewModel() { IsSeparator = true }); node.ContextMenuItems.Add(new MenuItemViewModel() { MenuItemHeader = "Delete route", MenuItemIcon = ROUTE_ERROR_ICON, MenuItemCommand = new RelayCommand(DeleteRouteCommand), MenuItemPayload = node }); return(node); }
public void BuildEndpoints_InvalidPath_BubblesOutException() { // Arrange var builder = Create <RuntimeRouteBuilder>(); var parsedRoute = new ParsedRoute { RouteId = "route1", Path = "/{invalid", Priority = 12, }; var cluster = new ClusterInfo("cluster1", new DestinationManager(), new Mock <IProxyHttpClientFactory>().Object); var routeInfo = new RouteInfo("route1"); // Act Action action = () => builder.Build(parsedRoute, cluster, routeInfo); // Assert Assert.Throws <AspNetCore.Routing.Patterns.RoutePatternException>(action); }
protected void OnTableListingRequest(TableListingRequest listingRequest, RouteInfo routeInfo) { TableListingResponse listingResponse = new TableListingResponse(); listingResponse.ResponseId = listingRequest.RequestId; listingResponse.TableSummaries = Manager.Tables.GetTableSummaries(); ClientBoundSeverEnvelopeObject envelope = new ClientBoundSeverEnvelopeObject(); envelope.InnerData = Manager.Serializer.GetBytes(listingResponse); envelope.InnerOperationCode = (int)GameMessageType.Client_ReceiveTableListingResponse; envelope.SenderServerId = Manager.ServerInfo.ServerId; envelope.PlayerNames = listingRequest.PlayerName.ToList(); OutgoingMessage outgoingMessage = ServerMessageFormatter.CreateOutgoingMessage( (int)ServerMessageType.ReceiveForwardMessageToClientRequest, Manager.Serializer.GetBytes(envelope), Manager.ResolveServers(routeInfo.GatewayServerId.ToList())); Manager.InternalOutgoingMessageQueue.Add(outgoingMessage); }
public GisDataPump() { Task.Factory.StartNew(() => { ril = new List<RouteInfo>(); //read all route-files into RouteInfoObjects. foreach (var routeFile in Directory.GetFiles(routeDictionary, "*.json")) { var file = new FileInfo(routeFile); //Send data to client when movement is detected (or faked in this case) var ri = new RouteInfo(file, (id, geodata) => { this.InvokeToAll<GeoCars>(new { id, geodata },"pos"); }); ril.Add(ri); var r = new Random(42); ri.Start(r.Next(1000,5000)); } }); }
public ActionResult EntryToolTip(string url, string callback) { if (string.IsNullOrWhiteSpace(url)) return HttpStatusCodeResult(HttpStatusCode.BadRequest, "URL must be specified"); var route = new RouteInfo(new Uri(url), AppConfig.HostAddress, HttpContext).RouteData; var controller = route.Values["controller"].ToString(); var id = int.Parse(route.Values["id"].ToString()); string data = string.Empty; switch (controller) { case "Album": data = RenderPartialViewToString("AlbumWithCoverPopupContent", Services.Albums.GetAlbum(id)); break; case "Artist": data = RenderPartialViewToString("ArtistPopupContent", Services.Artists.GetArtist(id)); break; case "Song": data = RenderPartialViewToString("SongPopupContent", Services.Songs.GetSongWithPVAndVote(id)); break; } return Json(data, callback); }
public virtual void SendEnvelopeObjectToServer(GameMessageType messageType, byte[] innerData, List<IPEndPoint> receivers, RouteInfo routeInfo) { ServerEnvelopeObject envelope = new ServerEnvelopeObject(); envelope.InnerOperationCode = (int)messageType; envelope.InnerData = innerData; envelope.SenderServerId = ServerId; envelope.RouteInfo = routeInfo; OutgoingMessage com = ServerMessageFormatter.CreateOutgoingMessage( (int)ServerMessageType.ReceiveForwardedMessageFromClient, Serializer.GetBytes(envelope), receivers); InternalOutgoingMessageQueue.Add(com); }
/// <summary> /// creating a default route under the creating area /// </summary> public void RouteNACreateUnderTheArea() { try { RouteBll BllRoute = new RouteBll(); RouteInfo infoRoute = new RouteInfo(); infoRoute.RouteName = "NA"; infoRoute.AreaId = decAreaId; infoRoute.Narration = txtNarration.Text.Trim(); infoRoute.Extra1 = string.Empty; infoRoute.Extra2 = string.Empty; infoRoute.ExtraDate = DateTime.Today; BllRoute.RouteAdd(infoRoute); } catch (Exception ex) { MessageBox.Show("AR2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void RouteInfoEqualityTest() { RouteInfo r1, r2; // Test two values that should be equal. r1 = new RouteInfo { Name = "005", LrsTypes = LrsTypes.Both }; r2 = new RouteInfo { Name = "005", LrsTypes = LrsTypes.Both }; Assert.AreEqual<RouteInfo>(r1, r2, "{0} should equal {1}.", r1, r2); r2.LrsTypes = LrsTypes.Decrease; Assert.AreNotEqual<RouteInfo>(r1, r2, "{0} should not equal {1}", r1, r2); }
/// <summary> /// Function to save the new route /// </summary> public void SaveFunction() { try { RouteBll BllRoute = new RouteBll(); RouteInfo infoRoute = new RouteInfo(); infoRoute.RouteName = txtRouteName.Text.Trim(); infoRoute.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); infoRoute.Narration = txtNarration.Text.Trim(); infoRoute.Extra1 = String.Empty; infoRoute.Extra2 = String.Empty; if (BllRoute.RouteCheckExistence(txtRouteName.Text.Trim(), 0, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false) { decRoute = BllRoute.RouteAddParticularFields(infoRoute); { Messages.SavedMessage(); Clear(); GridFill(); if (frmCustomerobj != null) { this.Close(); } } } else { Messages.InformationMessage(" Route name already exist"); txtRouteName.Focus(); } } catch (Exception ex) { MessageBox.Show("RT4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public RouteSummary(RouteInfo routeInfo, string helpModulePath) { _helpModulePath = RouteInfo.CleanPath(helpModulePath); Name = RouteInfo.CleanPath(routeInfo.Name); HttpMethod = routeInfo.HttpMethod; }
private static RouteInfo GetRouteInfo( IInlineConstraintResolver constraintResolver, Dictionary<string, RouteTemplate> templateCache, ActionDescriptor action) { var constraint = action.RouteConstraints .Where(c => c.RouteKey == AttributeRouting.RouteGroupKey) .FirstOrDefault(); if (constraint == null || constraint.KeyHandling != RouteKeyHandling.RequireKey || constraint.RouteValue == null) { // This can happen if an ActionDescriptor has a route template, but doesn't have one of our // special route group constraints. This is a good indication that the user is using a 3rd party // routing system, or has customized their ADs in a way that we can no longer understand them. // // We just treat this case as an 'opt-out' of our attribute routing system. return null; } var routeInfo = new RouteInfo() { ActionDescriptor = action, RouteGroup = constraint.RouteValue, RouteTemplate = action.AttributeRouteInfo.Template, }; try { RouteTemplate parsedTemplate; if (!templateCache.TryGetValue(action.AttributeRouteInfo.Template, out parsedTemplate)) { // Parsing with throw if the template is invalid. parsedTemplate = TemplateParser.Parse(action.AttributeRouteInfo.Template); templateCache.Add(action.AttributeRouteInfo.Template, parsedTemplate); } routeInfo.ParsedTemplate = parsedTemplate; } catch (Exception ex) { routeInfo.ErrorMessage = ex.Message; return routeInfo; } foreach (var kvp in action.RouteValueDefaults) { foreach (var parameter in routeInfo.ParsedTemplate.Parameters) { if (string.Equals(kvp.Key, parameter.Name, StringComparison.OrdinalIgnoreCase)) { routeInfo.ErrorMessage = Resources.FormatAttributeRoute_CannotContainParameter( routeInfo.RouteTemplate, kvp.Key, kvp.Value); return routeInfo; } } } routeInfo.Order = action.AttributeRouteInfo.Order; routeInfo.Precedence = AttributeRoutePrecedence.Compute(routeInfo.ParsedTemplate); routeInfo.Name = action.AttributeRouteInfo.Name; var constraintBuilder = new RouteConstraintBuilder(constraintResolver, routeInfo.RouteTemplate); foreach (var parameter in routeInfo.ParsedTemplate.Parameters) { if (parameter.InlineConstraints != null) { if (parameter.IsOptional) { constraintBuilder.SetOptional(parameter.Name); } foreach (var inlineConstraint in parameter.InlineConstraints) { constraintBuilder.AddResolvedConstraint(parameter.Name, inlineConstraint.Constraint); } } } routeInfo.Constraints = constraintBuilder.Build(); routeInfo.Defaults = routeInfo.ParsedTemplate.Parameters .Where(p => p.DefaultValue != null) .ToDictionary(p => p.Name, p => p.DefaultValue, StringComparer.OrdinalIgnoreCase); return routeInfo; }
public static RouteInfo ToRouteInfo(this ConnectionRecord record, string gatewayServerId) { RouteInfo routeInfo = new RouteInfo(); routeInfo.GatewayServerId = gatewayServerId; routeInfo.GameServerId = record.GameServerId; routeInfo.TableId = record.TableId; return routeInfo; }
protected void OnJoinTableRequestReceived(JoinTableRequest jtr, RouteInfo routeInfo) { var myEvent = JoinTableRequestReceived; if (myEvent != null) { myEvent(this, new JoinTableEventArgs(jtr, routeInfo)); } }
/// <summary> /// On double clicking on the datagridview, It displays the details of the rack to edit or delete /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvRoute_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex != -1) { if (dgvRoute.Rows[e.RowIndex].Cells["dgvtxtRouteName"].Value.ToString() != "NA") { RouteBll BllRoute = new RouteBll(); RouteInfo infoRoute = new RouteInfo(); infoRoute = BllRoute.RouteView(Convert.ToDecimal(dgvRoute.CurrentRow.Cells["dgvtxtRouteId"].Value.ToString())); decRouteId = Convert.ToDecimal(dgvRoute.CurrentRow.Cells["dgvtxtRouteId"].Value.ToString()); txtRouteName.Text = infoRoute.RouteName; cmbArea.SelectedValue = infoRoute.AreaId.ToString(); txtNarration.Text = infoRoute.Narration; btnSave.Text = "Update"; btnDelete.Enabled = true; txtRouteName.Focus(); } else { Messages.InformationMessage("Default Route cannot update or delete"); Clear(); } } } catch (Exception ex) { MessageBox.Show("RT19" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void Map(this RouteCollection collection, RouteInfo rootRoute) { foreach (RouteInfo ri in rootRoute.TreeStructureToList()) collection.MapPageRoute(ri.GetRouteName(), ri.GetRouteUrl(), string.Empty); }
public JoinTableEventArgs(JoinTableRequest request, RouteInfo routeInfo) { Request = request; RouteInfo = routeInfo; }
private RouteCost RequestRouteCost(RouteType routeType) { _routeDetails = new RouteDetails(); _routeDetails.descriptionType = Config.DesciptionType; _routeDetails.optimizeRoute = true; _routeDetails.routeType = Convert.ToInt32(routeType); _routeOptions.routeDetails = _routeDetails; using (var routeSoapClient = new RouteSoapClient()) { _routeInfo = routeSoapClient.getRoute(GenerateRouteStop(), _routeOptions, _token); } return new RouteCost { TotalDistance = _routeInfo.routeTotals.totalDistance, TotalFuelCost = _routeInfo.routeTotals.totalfuelCost, TotalCostWithToll = _routeInfo.routeTotals.totalCost, TotalTimeRote = _routeInfo.routeTotals.totalTime }; }
/// <summary> /// Function to edit already existing route /// </summary> public void EditFunction() { try { RouteBll BllRoute = new RouteBll(); RouteInfo infoRoute = new RouteInfo(); infoRoute.RouteName = txtRouteName.Text.Trim(); infoRoute.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString()); infoRoute.Narration = txtNarration.Text.Trim(); infoRoute.Extra1 = String.Empty; infoRoute.Extra2 = String.Empty; infoRoute.RouteId = decRouteId; if (BllRoute.RouteCheckExistence(txtRouteName.Text.Trim(), decRouteId, Convert.ToDecimal(cmbArea.SelectedValue.ToString())) == false) { if (BllRoute.RouteEditing(infoRoute)) { Messages.UpdatedMessage(); GridFill(); Clear(); } else if (infoRoute.RouteId == 1) { Messages.InformationMessage("Cannot update"); Clear(); txtRouteName.Focus(); } } else { Messages.InformationMessage(" Route name already exist"); txtRouteName.Focus(); } } catch (Exception ex) { MessageBox.Show("RT5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }