CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Authorization rule with an additional boolean parameter

rated by 0 users
Answered (Verified) This post has 1 verified answer | 4 Replies | 1 Follower

Top 150 Contributor
50 Posts
Reservatrix posted on Thu, Jan 17 2013 6:24 PM

Is it possible to create an authorization rule having an additional boolean parameter and the rule result will also depend on the boolean parameter?

The value of the boolean parameter could change during the life cycle of the instance.

My question is because when the AddObjectAuthorizationRules() loads the authorization rules the boolean parameter will have a value and that value could change during the life cycle of the instance.

 

Thanks for your help.

 

Answered (Verified) Verified Answer

Top 10 Contributor
1,815 Posts
Verified by Reservatrix

The only way would be to create an AuthorizationRule that accepts a lambda expression with statements that use the bool parameter. 

You can also read a value from the actual object (when provided) or read values from f.ex ApplicationContext or your own context within the rules Execute method. 

Jonny Bekkum, Norway CslaContrib Coordinator

All Replies

Top 10 Contributor
1,815 Posts
Verified by Reservatrix

The only way would be to create an AuthorizationRule that accepts a lambda expression with statements that use the bool parameter. 

You can also read a value from the actual object (when provided) or read values from f.ex ApplicationContext or your own context within the rules Execute method. 

Jonny Bekkum, Norway CslaContrib Coordinator

Top 150 Contributor
50 Posts

Hi JonnyBee:

I was thinking in using the AuthorizationContext to access the property Target and then get the value from the property.

Like in the sample in the book:

protected override void Execute(Csla.Rules.AuthorizationContext context)

{

var target = context.Target as ProductEdit;

.....

Can I do that with an interface too?

Top 10 Contributor
1,815 Posts

Yes

Jonny Bekkum, Norway CslaContrib Coordinator

Top 150 Contributor
50 Posts

Thanks JonyBee.

Page 1 of 1 (5 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems