Пример #1
0
        //----------------------------------------------------------------------------------------------------------------------

        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);
        }
Пример #2
0
        //----------------------------------------------------------------------------------------------------------------------

        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 );
        }
Пример #3
0
        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 );

        }
Пример #4
0
        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);
        }