public void LoadAssociations() { var document = XElement.Load("Resources/Associations.plist"); foreach (var dict in from element in document.Elements() where element.Name == "array" from dict in element.Elements(XName.Get("dict")) select dict) { // <dict> // <key>displayName</key> // <string>Vlaamse Biomedische Kring</string> // <key>internalName</key> // <string>VBK</string> // <key>parentAssociation</key> // <string>FKCENTRAAL</string> //</dict> //<dict> // <key>displayName</key> // <string>ChiSAG</string> // <key>fullName</key> // <string>Chinese Student Association Ghent</string> // <key>internalName</key> // <string>CHISAG</string> // <key>parentAssociation</key> // <string>IKCENTRAAL</string> //</dict> foreach (var node in dict.Elements()) { string display = null, intern; string parent; Association asso = null; var el = (XElement)node.NextNode; if (node.Value.Equals("displayName")) display = el.Value; el = (XElement)node.NextNode.NextNode; if (el.Value.Equals("internalName")) { intern = ((XElement)el.NextNode).Value; el = (XElement)el.NextNode.NextNode; parent = ((XElement)el.NextNode).Value; asso = new Association { In = intern, Fn = display, Dn = display, Parent = parent }; } else if (el.Value.Equals("fullName")) { var full = ((XElement)el.NextNode).Value; el = (XElement)el.NextNode.NextNode; intern = ((XElement)el.NextNode).Value; el = (XElement)el.NextNode.NextNode; parent = ((XElement)el.NextNode).Value; asso = new Association { In = intern, Fn = full, Dn = display, Parent = parent }; } if (asso != null) Associtions.Add(asso); break; } } _asso = true; }
public void LoadAssociations() { var document = XElement.Load("Resources/Associations.plist"); foreach (var dict in from element in document.Elements() where element.Name == "array" from dict in element.Elements(XName.Get("dict")) select dict) { // <dict> // <key>displayName</key> // <string>Vlaamse Biomedische Kring</string> // <key>internalName</key> // <string>VBK</string> // <key>parentAssociation</key> // <string>FKCENTRAAL</string> //</dict> //<dict> // <key>displayName</key> // <string>ChiSAG</string> // <key>fullName</key> // <string>Chinese Student Association Ghent</string> // <key>internalName</key> // <string>CHISAG</string> // <key>parentAssociation</key> // <string>IKCENTRAAL</string> //</dict> foreach (var node in dict.Elements()) { string display = null, intern; string parent; Association asso = null; var el = (XElement)node.NextNode; if (node.Value.Equals("displayName")) { display = el.Value; } el = (XElement)node.NextNode.NextNode; if (el.Value.Equals("internalName")) { intern = ((XElement)el.NextNode).Value; el = (XElement)el.NextNode.NextNode; parent = ((XElement)el.NextNode).Value; asso = new Association { In = intern, Fn = display, Dn = display, Parent = parent }; } else if (el.Value.Equals("fullName")) { var full = ((XElement)el.NextNode).Value; el = (XElement)el.NextNode.NextNode; intern = ((XElement)el.NextNode).Value; el = (XElement)el.NextNode.NextNode; parent = ((XElement)el.NextNode).Value; asso = new Association { In = intern, Fn = full, Dn = display, Parent = parent }; } if (asso != null) { Associtions.Add(asso); } break; } } _asso = true; }