//also copied from PropertyCollector.cs
        private List <ObjectContent> retrieveAllProperties(PropertyFilterSpec pfSpec)
        {
            List <ObjectContent> listobjcontent = new List <ObjectContent>();
            // RetrievePropertiesEx() returns the properties
            // selected from the PropertyFilterSpec
            RetrieveResult rslts = _service.RetrievePropertiesEx(_sic.propertyCollector, new PropertyFilterSpec [] { pfSpec }, new RetrieveOptions());

            if (rslts != null && rslts.objects != null && rslts.objects.Length != 0)
            {
                listobjcontent.AddRange(rslts.objects);
            }
            String token = null;

            if (rslts != null && rslts.token != null)
            {
                token = rslts.token;
            }
            while (token != null && token.Length != 0)
            {
                rslts = _service.ContinueRetrievePropertiesEx(_sic.propertyCollector, token);
                token = null;
                if (rslts != null)
                {
                    token = rslts.token;
                    if (rslts.objects != null && rslts.objects.Length != 0)
                    {
                        listobjcontent.AddRange(rslts.objects);
                    }
                }
            }
            return(listobjcontent);
        }
Ejemplo n.º 2
0
        private VimApi_55.ObjectContent[] RetrievePropertiesEx(VimApi_55.ManagedObjectReference propertyCollector, VimApi_55.PropertyFilterSpec[] specs, int?maxObjects)
        {
            List <VimApi_55.ObjectContent> objectList = new List <VimApi_55.ObjectContent>();
            //VimService _service = new VimService();
            var result =
                vimService.RetrievePropertiesEx(propertyCollector, specs, new VimApi_55.RetrieveOptions()
            {
                maxObjects          = maxObjects.GetValueOrDefault(),
                maxObjectsSpecified = (maxObjects != null)
            });

            if (result != null)
            {
                string token = result.token;
                objectList.AddRange(result.objects.AsEnumerable());
                while (token != null && !string.Empty.Equals(token))
                {
                    result = vimService.ContinueRetrievePropertiesEx(propertyCollector, token);
                    if (result != null)
                    {
                        token = result.token;
                        objectList.AddRange(result.objects.AsEnumerable());
                    }
                }
            }
            return(objectList.ToArray());
        }