My Blog

Oct9

Written by:Philip Beadle
Thursday, October 09, 2008 2:39 PM 

I have been working on a Silverlight (RC0) module for DotNetNuke and I needed to have access to some of the objects that DotNetNuke supports such as the userInfo object inside my Silverlight Module. 

So what I have done is use the XmlSerializer to serialise the UserInfo object then pass the string in the initParams of the Silverlight control and Deserailise inside the Silverlight app.

I have also created a UserInfo class in my Silverlight module to deserialise into.

This gives me a UserInfo object to use inside my Silverlight module, nice.

 Serialise the object Server Side:

            Dim slUserInfo As String
            Dim sbUi As StringBuilder = New StringBuilder()
            Dim writerUi As XmlWriter = XmlWriter.Create(sbUi)
            Dim xsUi As XmlSerializer = New XmlSerializer(GetType(Users.UserInfo))
            xsUi.Serialize(writerUi, Me.UserInfo)
            slUserInfo = sbUi.ToString()
            writerUi.Close()

 

Deserialise Client Side:

            var rdr = XmlReader.Create(new StringReader(slUserInfo));
            XmlSerializer xs = new XmlSerializer(typeof(DotNetNuke.UserInfo));
            userInfo = (UserInfo)xs.Deserialize(rdr);
 
    public class UserInfo
    {
        public int AffiliateID { get; set; }
        public string DisplayName { get; set; }
        public string Email { get; set; }
        public string FirstName { get; set; }
        public bool IsSuperUser { get; set; }
        public string LastName { get; set; }
        public int PortalID { get; set; }
        public int UserID { get; set; }
        public string Username { get; set; }
        public List<string> Roles { get; set; }
    }

Works a treat.  Now to work on a Silverlight Framework for DotNetNuke modules.

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
CAPTCHA image
Enter the code shown above in the box below
Add Comment  Cancel 
DNN Template Maker

Artisteer - Web Design Generator

  
UsersOnline
MembershipMembership:
Latest New UserLatest:andpro
Past 24 HoursPast 24 Hours:0
Prev. 24 HoursPrev. 24 Hours:0
User CountOverall:32

People OnlinePeople Online:
VisitorsVisitors:12
MembersMembers:0
TotalTotal:12

Online NowOnline Now:
  
Talk to me
  
Good Books
My Logos


MVP Logo
From: 2004-2009

Lorraine Young's DNN Site

DotNetNuke Sponsor and Platinum Benefactor logo

 Microsoft ASP.net logo

microsoftcertifiedprofessional.gif

vicnet_logo.gif