CSLA 3.8 question: getting this.Parent from a static business rule

CSLA 3.8 question: getting this.Parent from a static business rule

Old forum URL: forums.lhotka.net/forums/t/10155.aspx


Lord02 posted on Thursday, March 10, 2011

Normal 0 21 false false false IS X-NONE X-NONE

*** update ***
ahhhh, of course ... I forgot the target.Parent :-)
************************************************************

 

 

In CSLA 3.8:

Could you please tell me how I can reference this.Parent from a Business Rule ( as I understand it … all business rules must be static )

I can also NOT use this.Parent ( of course! ) inside the static rule itself … how would you implement this ?

 

private LogoutProcessManager GetParent()
        {
            IParent parent = this.Parent;
            return (LogoutProcessManager) parent;
        }

        private static bool RealmRule<T>(T target, RuleArgs e) where T : WebClientInformation
        {
            LogoutProcessManager parent = GetParent(); // this will not work, because because the GetParent uses this.XXXXX but the business rule is static

            LogoutProcessState logoutProcessState = parent.CurrentState;

            if (string.IsNullOrEmpty(target.Realm) && logoutProcessState != LogoutProcessState.Initialized)
            {
                e.Description = BusinessResources.RealmMissing;
                e.Severity = RuleSeverity.Error;

                return false;
            }

            return true;
        }

Thanx in advance,

ajj3085 replied on Thursday, March 10, 2011

Lord02
*** update ***
ahhhh, of course ... I forgot the target.Parent :-)

ajj3085 replied on Thursday, March 10, 2011

Quoted your text in the question to

1) Highlight that this is the answer, as I just about finished my post before I noticed you didn't need an answer

and

2) not leave the question unanswered

Copyright (c) Marimer LLC