Best way to get custom profile properties

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
7/23/2010 12:38:57 PM
Gravatar
Total Posts 72

Best way to get custom profile properties

Joe,

This is how I'm doing it currently. Is there a better way - feels a bit smelly

            if (user != null) {
                var obj = user.GetProperty("MyBoolProperty", SettingsSerializeAs.String);
                if (obj != null)
                    if (!string.IsNullOrEmpty(obj.ToString()))
                        boolProp = bool.Parse(obj.ToString());
            }

7/25/2010 6:28:00 AM
Gravatar
Total Posts 18439

Re: Best way to get custom profile properties

That is the way to do it, but you could possibly hide the ugliness by creating extension methods for SiteUser in a custom class. Then at least consuming the properties could be done without repeating the ugly code in multiple places. I would declare a variable and only call .ToString() one time.

Hope that helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.