Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 20th, 2009, 04:52 AM
Authorized User
 
Join Date: Jun 2005
Location: , , Philippines.
Posts: 97
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aldwinenriquez
Default Reflection for MembershipUser class

I would like to modify the readonly property of the MembershipUser class, however I was not able to do it for the IsOnline property since I was not able to get its readonly fieldname.

Iterating through its properties(Instance | Public) and fields(Instance |NonPublic) gives me these:

Properties
0:UserName
1:ProviderUserKey
2:Email
3:PasswordQuestion
4:Comment
5:IsApproved
6:IsLockedOut
7:LastLockoutDate
8:CreationDate
9:LastLoginDate
10:LastActivityDate
11:LastPasswordChangedDate
12:IsOnline
13:ProviderName
Fields
0:_UserName
1:_ProviderUserKey
2:_Email
3:_PasswordQuestion
4:_Comment
5:_IsApproved
6:_IsLockedOut
7:_LastLockoutDate
8:_CreationDate
9:_LastLoginDate
10:_LastActivityDate
11:_LastPasswordChangedDate
12:_ProviderName

How come there isn't a field for the IsOnline property?

Thanks in advance...
__________________
\"Dont you ever give up!\"
  #2 (permalink)  
Old March 20th, 2009, 09:44 AM
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

Not entirely sure what you're trying to achieve, but here's the source code (via Reflector):

Code:
public bool IsOnline
{
    get
    {
        TimeSpan span = new TimeSpan(0, Membership.UserIsOnlineTimeWindow, 0);
        DateTime time = DateTime.UtcNow.Subtract(span);
        return (this.LastActivityDate.ToUniversalTime() > time);
    }
}
Phil
  #3 (permalink)  
Old March 20th, 2009, 10:30 AM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

In practice, there is no need to have a backing field for a property whose value is directly calculated from the value of another property which has a backing field.

In this case, the value of IsOnline is directly derived from the value of LastActivityDate. Since the backing field for LastActivityDate (_LastActivityDate) contains all the information required to derive IsOnline, having a backing field for IsOnline would be redundant.

Hope that makes sense.

P.S. Like Philip, I'm not sure what you're trying to achieve either. But, the way to modify the value of IsOnline would be to do so indirectly with the Membership.UpdateUser method.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dim user As MembershipUser = Membership.GetUser(us sstuber BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 May 8th, 2008 03:42 PM
get tagged properties of class using reflection Baby_programmer C# 2005 1 November 26th, 2007 05:54 AM
Editing a MembershipUser without changing it’s log madok BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 September 13th, 2006 09:42 PM
Reflection jayakumar.cj ASP.NET 1.0 and 1.1 Basics 1 July 15th, 2006 06:12 AM
Reflection ffbalota C# 2 January 8th, 2004 03:07 PM



All times are GMT -4. The time now is 05:36 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.