public CreateResource ( |
||
pullOrEnumerateResponse | The pull or enumerate response to use when creating resources. | |
return | List |
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;
}
}
RmResourceFactory::CreateResource ( |
public bool MoveNext() { lock (this.client) { if (resultIndex < results.Count) { this.current = results[resultIndex++]; return(true); } else { PullResponse response; if (this.context == null) { if (resultIndex > 0) { // case: previous pull returned an invalid context return(false); } EnumerationRequest request = new EnumerationRequest(filter); if (attributes != null) { request.Selection = new List <string>(); request.Selection.AddRange(this.attributes); } response = client.Enumerate(request); this.endOfSequence = response.EndOfSequence != null; } else { if (this.endOfSequence == true) { // case: previous pull returned an end of sequence flag this.current = null; return(false); } PullRequest request = new PullRequest(); request.EnumerationContext = this.context; response = client.Pull(request); } if (response == null) { return(false); } resultIndex = 0; this.results = resourceFactory.CreateResource(response); this.context = response.EnumerationContext; this.endOfSequence = response.IsEndOfSequence; if (this.results.Count > 0) { this.current = results[resultIndex++]; return(true); } else { this.current = null; return(false); } } } }