none
Help with Property List RRS feed

  • Question

  • I have a List with in another list as a property. I'm trying to create a two demential list. I think I might of setup my property list wrong and I have a syntax error currently when trying to add items to my list.

    Current Code:

    Function to Build List

    private bool Build_IdentityDetails()
            {           
                try
                {
                    
                    bool IDM_Setup = true;
    
                    if (tbIDM_Name.Text == string.Empty | tbIDM_AvectraID.Text == string.Empty | tbIDM_Password.Text == string.Empty | tbIDM_FirstName.Text == string.Empty
                         | tbIDM_LastName.Text == string.Empty | tbIDM_Email.Text == string.Empty | tbIDM_AccountStatus.Text == string.Empty | tbIDM_BirthYear.Text == string.Empty
                          | tbIDM_City.Text == string.Empty | tbIDM_Gender.Text == string.Empty | tbIDM_JobTitle.Text == string.Empty | tbIDM_LeadScore.Text == string.Empty
                           | tbIDM_State.Text == string.Empty | tbIDM_OrgID.Text == string.Empty | tbIDM_MemberGroup.Text == string.Empty | tbIDM_RegMethod.Text == string.Empty)
                    { 
                        return false;
                    }
    
                    IdentityDetails.attribute.Add("avectraid", tbIDM_AvectraID.Text);
                    IdentityDetails.attribute.Add("userpassword", tbIDM_Password.Text);
                    IdentityDetails.attribute.Add("givenname", tbIDM_FirstName.Text);
                    IdentityDetails.attribute.Add("sn", tbIDM_LastName.Text);
                    IdentityDetails.attribute.Add("mail", tbIDM_Email.Text);
                    IdentityDetails.attribute.Add("cn", tbIDM_FirstName.Text);
                    IdentityDetails.attribute.Add("AHApw", "");
                    IdentityDetails.attribute.ToArray();
    
                    return IDM_Setup;
                }
                catch(Exception ex)
                {
                    return false;
                }
            }

    Properties Class:

    public class IdentityDetails
        {
            public const string type = "user";
            public const string realm = "dc=aha,dc=org";
            public const string AccountStatus = "Active";
            public string name { get; set; }        
            public List<List<string>> attribute { get; set; }
            public List<string> groups { get; set; }
        }

    Tuesday, October 17, 2017 7:26 PM

Answers

  • Hello old_School,

    Because the format of Store data is KeyValue pairs, dictionary object  is a good choice for you.

    public class IdentityDetails { ... //According to your output the value of dictionary may be array format.So I define the generic as below. public Dictionary<string, string[]> attribute { get; set; } ...

    }

    Add Properties to dictionary object

    IdentityDetails.attribute = new Dictionary<string, string[]>();
    IdentityDetails.attribute.Add("avectraid", new string[] { tbIDM_AvectraID.Text });
    IdentityDetails.attribute.Add("userpassword", new string[] { tbIDM_Password.Text});
    //IdentityDetails.attribute.Add("givenname", new string[] { tbIDM_FirstName.Text });                
    ...
    IdentityDetails.attribute.Add("ahaMemberGroup", new string[] { "AHA", "AONE" });
    ...

    Traverse the dictionary object.

    foreach (var s in IdentityDetails.attribute) {
                        Console.WriteLine(s.Key+":"+String.Join(",",s.Value));                 
                    }


    Sincerely,
    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Edited by Fei HuModerator Wednesday, October 18, 2017 2:43 AM
    • Marked as answer by old_School Wednesday, October 18, 2017 1:24 PM
    Wednesday, October 18, 2017 2:39 AM
    Moderator

All replies

  • Here is roughly what I'm trying to accomplish:

    {
     "userName": "testuser1@aha.org",
     "mail": "testuser1@aha.org",
     "givenName": "Test",
     "sn": "User",
     "accountStatus": "Active",
     "avectraId": "9999999998",
     "AHApw":
    "/Z5/5OXUBquzAtXesIjN0WjxFp1z05jMXKoynFyVKwa1+RdaUxmrFU6/nCOLedqh",
     "password" : "Password1",
     "ahaBirthYear" : "1980",
     "city" : "Chicago",
     "ahaGender" : "Male",
     "ahaJobTitle" : "Director",
     "ahaLeadScore" : "101",
     "stateProvince" : "IL",
     "orgId" : "0006432413",
     "ahaMemberGroup" : [
     "AHA",
     "AONE"
     ],
     "ahaMemberType" : [
     "INST_V_NF",
      "FULL"
     ],
     "regMethod": "AMS"
    }
    

    Tuesday, October 17, 2017 8:37 PM
  • Hello old_School,

    Because the format of Store data is KeyValue pairs, dictionary object  is a good choice for you.

    public class IdentityDetails { ... //According to your output the value of dictionary may be array format.So I define the generic as below. public Dictionary<string, string[]> attribute { get; set; } ...

    }

    Add Properties to dictionary object

    IdentityDetails.attribute = new Dictionary<string, string[]>();
    IdentityDetails.attribute.Add("avectraid", new string[] { tbIDM_AvectraID.Text });
    IdentityDetails.attribute.Add("userpassword", new string[] { tbIDM_Password.Text});
    //IdentityDetails.attribute.Add("givenname", new string[] { tbIDM_FirstName.Text });                
    ...
    IdentityDetails.attribute.Add("ahaMemberGroup", new string[] { "AHA", "AONE" });
    ...

    Traverse the dictionary object.

    foreach (var s in IdentityDetails.attribute) {
                        Console.WriteLine(s.Key+":"+String.Join(",",s.Value));                 
                    }


    Sincerely,
    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Edited by Fei HuModerator Wednesday, October 18, 2017 2:43 AM
    • Marked as answer by old_School Wednesday, October 18, 2017 1:24 PM
    Wednesday, October 18, 2017 2:39 AM
    Moderator