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 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 processOwnerNamespaceAppId( RouteParseInfo routeInfo, RouteSetting route ) { String[] arrPathRow = routeInfo.getRowPathArray(); int count = route.GetNamedItem().Count; if (count == 0) { routeInfo.setPathArray( arrPathRow ); return; } String[] arrTemp; // 首先前面剔除掉 owner if (routeInfo.getOwnerInfo() != null) { arrTemp = new String[arrPathRow.Length - 2]; for (int i = 2; i < arrPathRow.Length; i++) { arrTemp[i - 2] = arrPathRow[i]; } } else { arrTemp = arrPathRow; } if (arrTemp.Length <= count) { routeInfo.setPathArray( arrTemp ); return; } // 然后末尾剔除掉 controller/action/id String[] arrPath = new String[count]; int x = 0; for (int i = arrTemp.Length - count; i < arrTemp.Length; i++) { arrPath[x] = arrTemp[i]; x++; } // 得到 ns StringBuilder ns = new StringBuilder(); int end = arrTemp.Length - count; for (int i = 0; i < end; i++) { if (i > 0) ns.Append( "." ); if (i == 0 && isEndsWithInt( arrTemp[i] )) { routeInfo.setAppId( strUtil.GetEndNumber( arrTemp[i] ) ); ns.Append( strUtil.TrimEnd( arrTemp[i], routeInfo.getAppId().ToString() ) ); } else ns.Append( arrTemp[i] ); } routeInfo.setPathArray( arrPath ); routeInfo.setNamespace( ns ); }
private static void processOwnerNamespaceAppId(RouteParseInfo routeInfo, RouteSetting route) { String[] arrPathRow = routeInfo.getRowPathArray(); int count = route.GetNamedItem().Count; if (count == 0) { routeInfo.setPathArray(arrPathRow); return; } String[] arrTemp; // 首先前面剔除掉 owner if (routeInfo.getOwnerInfo() != null) { arrTemp = new String[arrPathRow.Length - 2]; for (int i = 2; i < arrPathRow.Length; i++) { arrTemp[i - 2] = arrPathRow[i]; } } else { arrTemp = arrPathRow; } if (arrTemp.Length <= count) { routeInfo.setPathArray(arrTemp); return; } // 然后末尾剔除掉 controller/action/id String[] arrPath = new String[count]; int x = 0; for (int i = arrTemp.Length - count; i < arrTemp.Length; i++) { arrPath[x] = arrTemp[i]; x++; } // 得到 ns StringBuilder ns = new StringBuilder(); int end = arrTemp.Length - count; for (int i = 0; i < end; i++) { if (i > 0) { ns.Append("."); } if (i == 0 && isEndsWithInt(arrTemp[i])) { routeInfo.setAppId(strUtil.GetEndNumber(arrTemp[i])); ns.Append(strUtil.TrimEnd(arrTemp[i], routeInfo.getAppId().ToString())); } else { ns.Append(arrTemp[i]); } } routeInfo.setPathArray(arrPath); routeInfo.setNamespace(ns); }