so if i have a custom routing defined by a xml file like this:

    <route matches="/artigos-para-meninos-de-todos-tamanhos"
controller="Articles" action="ListByCategory">
        <params>
            <param patternPart="key" value="para-meninos"/>
        </params>
    </route>

this should get me there? (i have not tried it yet, but it seems a bit
suspicious to me... the fact that i have no namedPatternparts)

prototype code:

        private static IRoutingRule makeRoute(XElement xElement)
        {
            var controllerAttr = xElement.Attribute("controller");
            var controllerType = controllerAttr != null ?
controllerAttr.Value : null;
            var actionAttr = xElement.Attribute("action");
            var action = actionAttr != null ? actionAttr.Value : null;
            var patternAttr = xElement.Attribute("pattern");
            var pattern = patternAttr != null ?
patternAttr.Value.Replace('{', '<').Replace('}', '>') : null;
            var route = new PatternRoute(pattern)
                .DefaultForAction().Is(action)
                .DefaultForController().Is(controllerType);
            var paramElements = xElement.Descendants().Where(e => e.NodeType
== XmlNodeType.Element && e.Name == "params").ToList();
            if (paramElements.IsNullOrEmpty())
                return route;
            foreach (var paramElement in paramElements)
            {
                var attrs = new[] { paramElement.Attribute("patternPart"),
paramElement.Attribute("value") };
                if (attrs.Any(e => e == null))
                    continue;
                route.DefaultFor(attrs[0].Value).Is(attrs[1].Value);
            }
            return route;
        }


2009/11/13 Ken Egozi <[email protected]>

> try Default.For(Whichever).Is(Whatever)
>
> On Fri, Nov 13, 2009 at 12:56 AM, Jan Limpens <[email protected]>wrote:
>
>> but how do I pass a parameter to the action, then?
>>
>> 2009/11/10 hammett <[email protected]>
>>
>>> Hmm.. IIRC if you dont specify a pattern to a PatternRoute, all route
>>> nodes will be required, so you'll achieve exactly what your boss wants.
>>>
>>> On Mon, Nov 9, 2009 at 2:50 PM, Jan Limpens <[email protected]>wrote:
>>>
>>>> Hello!
>>>>
>>>> for my FooController/BarAction(string val) I have this routing:
>>>>
>>>> "/foo/bard/<val>"
>>>>
>>>> Now my boss enters and tells me: "For the val 'xyz', I want this other
>>>> routing '/my-wonderful-routing-for-xyz' and for 'abc', I want
>>>> '/this-is-a-nice-abc', the rest is nice the way it is."
>>>>
>>>> And I have no good idea how to implement this easily. I miss a way in
>>>> PatternRoute to pass in a parameter and this makes sense - because it is a
>>>> PatternRoute it expects a pattern, not something concrete. Is there an easy
>>>> way to implement something like a ConcreteRule, or do I have to do this all
>>>> by myself?
>>>>
>>>> --
>>>> Jan
>>>>
>>>> --~--~---------~--~----~------------~-------~--~----~
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Castle Project Users" group.
>>>> To post to this group, send email to
>>>> [email protected]
>>>> To unsubscribe from this group, send email to
>>>> [email protected]<castle-project-users%[email protected]>
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/castle-project-users?hl=en
>>>> -~----------~----~----~----~------~----~------~--~---
>>>>
>>>>
>>>
>>>
>>> --
>>> Cheers,
>>> hammett
>>> http://hammett.castleproject.org/
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Castle Project Users" group.
>>> To post to this group, send email to
>>> [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<castle-project-users%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/castle-project-users?hl=.
>>>
>>
>>
>>
>> --
>> Jan
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Castle Project Users" group.
>> To post to this group, send email to
>> [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<castle-project-users%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/castle-project-users?hl=.
>>
>
>
>
> --
> Ken Egozi.
> http://www.kenegozi.com/blog
> http://www.delver.com
> http://www.musicglue.com
> http://www.castleproject.org
> http://www.idcc.co.il - הכנס הקהילתי הראשון למפתחי דוטנט - בואו בהמוניכם
>
> --
> You received this message because you are subscribed to the Google Groups
> "Castle Project Users" group.
> To post to this group, send email to [email protected]
> .
> To unsubscribe from this group, send email to
> [email protected]<castle-project-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/castle-project-users?hl=.
>



-- 
Jan

--

You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=.


Reply via email to