TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jonathas Sucupira
NA
166
16.3k
Help on how to use Attribute with custom classes
Jul 27 2011 12:18 PM
Hello,
I was wanting to use an attribute in some of my class methods that would make sure that the user is an authorized before using the method that they called.
I was wanting to do something like
[
Authorized
()]
public
void
updateSomething
()
{
//TODO:
}
Here is my attribute class
[
class
AuthorizedAttribute
:
Attribute
{
public
bool
IsAuthorized {
get
;
set
; }
public
string
UserName {
get
;
set
; }
public
string
Password {
get
;
set
; }
public
string
UserEmail {
get
;
set
; }
public
AuthorizedAttribute
()
{
//This is not the actual implementation
this
.
IsAuthorized
=
false
;
}
public
AuthorizedAttribute
(
string
userEmail
,
string
userPassword
)
{
this
.
UserEmail
=
userEmail
;
this
.
Password
=
userPassword
;
this
.
UserName
=
string
.
Empty
;
BusinessLogic
bc
=
new
BusinessLogic
();
if
(
bc
.
VerifyCredentials
(
userEmail
,
userPassword
))
{
this
.
IsAuthorized
=
true
;
}
else
{
this
.
IsAuthorized
=
false
;
}
}
}
Could someone point me in the right direction? Some link would be great as well.
Thank you.
Reply
Answers (
3
)
DataTable, DataSet or DataView
Scope of MonoDevelop