Question of Day

2 views
Skip to first unread message

Nirav Patel

unread,
Mar 17, 2016, 11:36:36 AM3/17/16
to Elite Techie Group
Scenario:
 I have Application where I have private method.I want to give access to this private method to certain group of users.How do I achieve this?

Jignesh Gor

unread,
Mar 17, 2016, 11:43:46 AM3/17/16
to elite-tec...@googlegroups.com

Decorate with authorized user group...

On Mar 17, 2016 11:36 AM, "Nirav Patel" <pate...@gmail.com> wrote:
Scenario:
 I have Application where I have private method.I want to give access to this private method to certain group of users.How do I achieve this?

--
You received this message because you are subscribed to the Google Groups "Elite Techie Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elite-techie-gr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aalap Shah

unread,
Mar 17, 2016, 12:50:42 PM3/17/16
to elite-tec...@googlegroups.com
Right, you can create your own attribute to check authorized users or use PrincipalPermission (for windows users and roles) to check it.
You might need to convert private to public 

or may be you can use reflection to invoke it as private members are inherited even-though they are not accessible directly.
here is something i got from stakoverflow:
MethodInfo dynMethod = this.GetType().GetMethod("Draw_" + itemType, 
    BindingFlags.NonPublic | BindingFlags.Instance);
dynMethod.Invoke(this, new object[] { methodParams });

Thanks and Regards,
Aalap Shah

pate...@gmail.com

unread,
Mar 17, 2016, 3:08:06 PM3/17/16
to elite-tec...@googlegroups.com
I don't want to change my method from private to public 

Sent from my iPhone

Jignesh Gor

unread,
Mar 17, 2016, 4:03:41 PM3/17/16
to elite-tec...@googlegroups.com

No need....Attribute oriented programming allows private too

Reply all
Reply to author
Forward
0 new messages