public List<RmResource> CreateResource(PullResponse pullOrEnumerateResponse)
{
if (pullOrEnumerateResponse == null) {
throw new ArgumentNullException("pullOrEnumerateResponse");
}
if (pullOrEnumerateResponse.Items == null || pullOrEnumerateResponse.Items.Values == null) {
return new List<RmResource>();
}
lock (pullOrEnumerateResponse) {
List<RmResource> retList = new List<RmResource>();
foreach (XmlNode obj in pullOrEnumerateResponse.Items.Values) {
// look ahead for the type info;
String objectType = null;
foreach (XmlNode child in obj.ChildNodes) {
if (child.NodeType == XmlNodeType.Element) {
if (child.LocalName.Equals(@"ObjectType")) {
objectType = child.InnerText;
break;
}
}
}
if (objectType == null) {
objectType = String.Empty;
}
RmResource rmResource = this.resourceTypeFactory.CreateResource(objectType);
// now add the attributes to the resource object
foreach (XmlNode child in obj.ChildNodes) {
if (child.NodeType == XmlNodeType.Element) {
RmAttributeName attributeName = new RmAttributeName(child.LocalName);
IComparable attributeValue = this.ConstructAttributeValue(attributeName, child.InnerText);
if (attributeValue == null)
continue;
RmAttributeValue newAttribute = null;
if (rmResource.TryGetValue(attributeName, out newAttribute) == false) {
newAttribute = CreateRmAttributeValue(attributeName);
rmResource[attributeName] = newAttribute;
}
if (base.IsMultiValued(attributeName) == false)
newAttribute.Values.Clear();
if (attributeName.Name.Equals(ObjectType) || attributeName.Name.Equals(ObjectID))
newAttribute.Values.Clear();
newAttribute.Values.Add(attributeValue);
}
}
retList.Add(rmResource);
}
return retList;
}
}