private static IEnumerable <PortableDeviceObject> FindInternal(IEnumerable <PortableDeviceObject> objectCollection, IObjectEnumerateHelper enumerateHelper)
        {
            var res = new List <PortableDeviceObject>();

            foreach (PortableDeviceObject deviceObject in objectCollection.Where(enumerateHelper.IsObjectMatching))
            {
                if (enumerateHelper.IsLastNode)
                {
                    res.Add(deviceObject);
                }
                else
                {
                    var folder = deviceObject as PortableDeviceContainerObject;
                    if (folder != null)
                    {
                        res.AddRange(FindInternal(folder.Childs, enumerateHelper.Next()));
                    }
                }
            }

            return(res);
        }
        internal void Enumerate(ref IPortableDeviceContent pContent, string parentID, PortableDeviceContainerObject node, IObjectEnumerateHelper helper, bool detectNewObjects = false)
        {
            IPortableDeviceProperties properties;

            pContent.Properties(out properties);

            foreach (var objectID in ExtractObjectIds(pContent, parentID))
            {
                if (detectNewObjects && ParentContainsChildsId(node, objectID))
                {
                    continue;
                }

                PortableDeviceObject current = ExtractInformation(properties, objectID);
                if (!helper.IsObjectMatching(current))
                {
                    continue;
                }

                node.AddChild(current);

                if (!helper.IsLastNode && current is PortableDeviceContainerObject)
                {
                    Enumerate(ref pContent, objectID, (PortableDeviceContainerObject)current, helper.Next(), detectNewObjects);
                }
            }
        }
Пример #3
0
        internal void Enumerate(ref IPortableDeviceContent pContent, string parentID, PortableDeviceContainerObject node, IObjectEnumerateHelper helper, bool detectNewObjects = false)
        {
            IPortableDeviceProperties properties;
            pContent.Properties(out properties);

            foreach (var objectID in ExtractObjectIds(pContent, parentID))
            {
                if (detectNewObjects && ParentContainsChildsId(node, objectID))
                    continue;

                PortableDeviceObject current = ExtractInformation(properties, objectID);
                if(!helper.IsObjectMatching(current))
                    continue;

                node.AddChild(current);

                if (!helper.IsLastNode && current is PortableDeviceContainerObject)
                    Enumerate(ref pContent, objectID, (PortableDeviceContainerObject)current, helper.Next(), detectNewObjects);
            }
        }
        private static IEnumerable<PortableDeviceObject> FindInternal(IEnumerable<PortableDeviceObject> objectCollection, IObjectEnumerateHelper enumerateHelper)
        {
            var res = new List<PortableDeviceObject>();

            foreach (PortableDeviceObject deviceObject in objectCollection.Where(enumerateHelper.IsObjectMatching))
            {
                if (enumerateHelper.IsLastNode)
                {
                    res.Add(deviceObject);
                }
                else
                {
                    var folder = deviceObject as PortableDeviceContainerObject;
                    if (folder != null)
                        res.AddRange(FindInternal(folder.Childs, enumerateHelper.Next()));
                }
            }

            return res;
        }