Return IList with more data.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RobRasti

    Return IList with more data.

    I'm trying to return a class that implements the IList interface and
    has a few other data members as well.

    // User Node class
    [Serializable]
    [XmlRootAttribut e("User")]
    public class User
    {
    private string m_username = "";
    private string m_userpassword = "";
    private string m_userDisplayNa me = "";

    public User()
    {
    }

    public User(string pUsername, string pUserpassword, string
    pUserDisplayNam e)
    {
    m_username = pUsername;
    m_userpassword = pUserpassword;
    m_userDisplayNa me = pUserDisplayNam e;
    }

    [XmlElementAttri bute(Type = typeof(string), IsNullable = false)]
    public string UserName
    {
    get { return m_username; }
    set { m_username = value; }
    }

    [XmlElementAttri bute(Type = typeof(string), IsNullable = false)]
    public string UserDisplayName
    {
    get { return m_userDisplayNa me; }
    set { m_userDisplayNa me = value; }
    }

    [XmlElementAttri bute(Type = typeof(string), IsNullable = false)]
    public string UserPassword
    {
    get { return m_userpassword; }
    set { m_userpassword = value; }
    }
    }

    // UserList class
    [Serializable]
    [XmlRootAttribut e("UserList")]
    public class UserList : ReturnSet, IList<User>
    {
    // IList members

    [XmlArrayAttribu te("Users")]
    [XmlArrayItemAtt ribute("User", typeof(User))]
    public User[] Users
    {
    get { return (User[])m_list.ToArray (typeof(User)); }
    set
    {
    m_list = new ArrayList(value );
    }
    }

    private bool m_lockdownHandh eld = false;
    private bool m_deleteAllData = false;

    [XmlElementAttri bute("Lockdown" )]
    public bool Lockdown
    {
    get { return m_lockdown; }
    set { m_lockdown = value; }
    }

    [XmlElementAttri bute("DeleteAll Data")]
    public bool DeleteAllData
    {
    get { return m_deleteAllData ; }
    set { m_deleteAllData = value; }
    }
    }

    What I expect to get back when the web service call is made is an XML
    similar to the following:

    <UserList xmlns...>
    <Lockdown>False </Lockdown>
    <DeleteAllData> False</DeleteAllData>
    <Users>
    <User>
    <UserName>Rob </UserName>
    <UserPassword>1 2345</UserPassword>
    <UserDisplayNam e>Rob Smith</UserDisplayName >
    <User>
    <User>....</User>
    </Users>
    </UserList>

    What I am seeing instead is the following:

    <UserList xmlns...>
    <User>
    <UserName>Rob </UserName>
    <UserPassword>1 2345</UserPassword>
    <UserDisplayNam e>Rob Smith</UserDisplayName >
    </User>
    <User>....</User>
    </UserList>

    The Lockdown and DeleteAllData properties of the UserList class are
    being ignored.

    I'm trying to return a list of Users (Or whatever data object) and
    some control data to a client application. (i.e. Lockdown = True take
    some action to disable the client software) Is there anyway to
    accomplish what I am trying to do here?

    Thanks for your help.

    -Rob-
  • RobRasti

    #2
    Re: Return IList with more data.

    Solved my own problem. Turns out by implementing IList ASP treated it
    as a list only. I created a wrapper class that contained my two
    properties and a List and all is working fine now.

    Thanks for any consideration.

    -Rob-

    Comment

    Working...