mccalltd / AttributeRouting

Define your routes using attributes on actions in ASP.NET MVC and Web API.
http://mccalltd.github.io/AttributeRouting/
MIT License
416 stars 89 forks source link

GetDefaultRouteArea 3.5.6.0 #221

Open smolesen opened 11 years ago

smolesen commented 11 years ago

Just upgraded to AR 3.5.6.0, and now the following code starts to fail:

var convention = type.GetCustomAttribute(true); var routeAreaAttribute = type.GetCustomAttribute(true) ?? convention.SafeGet(x => x.GetDefaultRouteArea(type));

(can't remember where I got it from)

is there another way to do this now?

TIA

/Søren

mccalltd commented 11 years ago

Need more details on the context

On Mar 14, 2013, at 4:18 AM, smolesen notifications@github.com wrote:

Just upgraded to AR 3.5.6.0, and now the following code starts to fail:

var convention = type.GetCustomAttribute(true); var routeAreaAttribute = type.GetCustomAttribute(true) ?? convention.SafeGet(x => x.GetDefaultRouteArea(type));

(can't remember where I got it from)

is there another way to do this now?

TIA

/Søren

— Reply to this email directly or view it on GitHubhttps://github.com/mccalltd/AttributeRouting/issues/221 .

smolesen commented 11 years ago

Think some of the code got lost when pasting... I've changed it to var convention = type.GetCustomAttribute<RouteConventionAttributeBase>(true); var routeAreaAttribute = type.GetCustomAttribute<RouteAreaAttribute>(true); if (routeAreaAttribute == null && convention != null) routeAreaAttribute = convention.SafeGet(x => x.GetDefaultRouteArea(type));

and now it's working... seems like convention.SafeGet(x => x.GetDefaultRouteArea(type)) would return null in previous version, whereas it now throws an exception....