//---------------------------------------------------------------------------------------------------------------------- private static void setRouteInfo(Route result, RouteParseInfo routeInfo, String cleanUrl) { if (strUtil.IsNullOrEmpty(result.ns)) { result.setNs(routeInfo.getNamespace().ToString()); } if (result.ns.Equals("_")) { result.setNs(""); } if (routeInfo.getAppId() > 0) { result.setItem("appid", routeInfo.getAppId()); } if (routeInfo.getOwnerInfo() != null) { result.setItem("owner", routeInfo.getOwnerInfo().Owner); result.setItem("ownertype", routeInfo.getOwnerInfo().OwnerType); } result.setCleanUrl(cleanUrl); setStrongTypeValue(result); setDefaultAction(result); }
public Route getRouteWithDefaultValue() { Route route = new Route(); route.setOwnerType(_default.getOwnerType()); route.setOwner(_default.getOwner()); route.setNs(_default.getNs()); route.setController(_default.getController()); route.setAction(_default.getAction()); route.setQuery(_default.getQuery()); route.setId(_default.getId()); route.setAppId(_default.getAppId()); route.setPage(_default.getPage()); route.setItem("ownertype", route.ownerType); route.setItem("owner", route.owner); route.setItem("namespace", route.ns); route.setItem("controller", route.controller); route.setItem("action", route.action); route.setItem("query", route.query); route.setItem("id", route.id); route.setItem("appId", route.appId); route.setItem("page", route.page); return(route); }
private static void setStrongTypeValue(Route result) { if (result.getItem("controller") != null) { result.setController(result.getItem("controller")); } if (result.getItem("action") != null) { result.setAction(result.getItem("action")); } if (result.getItem("query") != null) { result.setQuery(result.getItem("query")); } if (result.getItem("owner") != null) { result.setOwner(result.getItem("owner")); } if (result.getItem("ownertype") != null) { result.setOwnerType(result.getItem("ownertype")); } if (result.getItem("id") != null) { result.setId(cvt.ToLong(result.getItem("id"))); } if (result.getItem("appid") != null) { result.setAppId(cvt.ToLong(result.getItem("appid"))); } int page = 1; if (result.getItem("page") != null) { int routePage = Requirements.getPageNumber(result.getItem("page")); if (routePage > 1) { page = routePage; } } result.setItem("page", page); result.setPage(page); CurrentRequest.setCurrentPage(page); }
private static Route getResult(RouteSetting setting, RouteParseInfo routeInfo) { Route result = setting.getRouteWithDefaultValue(); List <PathItem> items = setting.GetNamedItem(); for (int i = 0; i < items.Count; i++) { String[] arrValue = routeInfo.getPathArray(); if (i > arrValue.Length - 1) { break; } PathItem item = items[i]; if (item.isNamed() == false) { continue; } String val = arrValue[i]; if (strUtil.IsNullOrEmpty(val)) { continue; } // 如果条件不符合,跳过此条route if (setting.getRequirements().match(item.getName(), val) == false) { return(null); } result.setItem(item.getName(), val); } return(result); }
private static void setStrongTypeValue( Route result ) { if (result.getItem( "controller" ) != null) result.setController( result.getItem( "controller" ) ); if (result.getItem( "action" ) != null) result.setAction( result.getItem( "action" ) ); if (result.getItem( "query" ) != null) result.setQuery( result.getItem( "query" ) ); if (result.getItem( "owner" ) != null) result.setOwner( result.getItem( "owner" ) ); if (result.getItem( "ownertype" ) != null) result.setOwnerType( result.getItem( "ownertype" ) ); if (result.getItem( "id" ) != null) result.setId( cvt.ToLong( result.getItem( "id" ) ) ); if (result.getItem( "appid" ) != null) result.setAppId( cvt.ToLong( result.getItem( "appid" ) ) ); int page = 1; if (result.getItem( "page" ) != null) { int routePage = Requirements.getPageNumber( result.getItem( "page" ) ); if (routePage > 1) page = routePage; } result.setItem( "page", page ); result.setPage( page ); CurrentRequest.setCurrentPage( page ); }
//---------------------------------------------------------------------------------------------------------------------- private static void setRouteInfo( Route result, RouteParseInfo routeInfo, String cleanUrl ) { if (strUtil.IsNullOrEmpty( result.ns )) result.setNs( routeInfo.getNamespace().ToString() ); if (result.ns.Equals( "_" )) result.setNs( "" ); if (routeInfo.getAppId() > 0) { result.setItem( "appid", routeInfo.getAppId() ); } if (routeInfo.getOwnerInfo() != null) { result.setItem( "owner", routeInfo.getOwnerInfo().Owner ); result.setItem( "ownertype", routeInfo.getOwnerInfo().OwnerType ); } result.setCleanUrl( cleanUrl ); setStrongTypeValue( result ); setDefaultAction( result ); }
public Route getRouteWithDefaultValue() { Route route = new Route(); route.setOwnerType ( _default.getOwnerType()); route.setOwner ( _default.getOwner()); route.setNs( _default.getNs() ); route.setController ( _default.getController()); route.setAction ( _default.getAction()); route.setQuery ( _default.getQuery()); route.setId( _default.getId() ); route.setAppId( _default.getAppId() ); route.setPage( _default.getPage() ); route.setItem( "ownertype", route.ownerType ); route.setItem( "owner", route.owner ); route.setItem( "namespace", route.ns ); route.setItem( "controller", route.controller ); route.setItem( "action", route.action ); route.setItem( "query", route.query ); route.setItem( "id", route.id ); route.setItem( "appId", route.appId ); route.setItem( "page", route.page ); return route; }