예제 #1
0
        public static void GetIceBuilderItems(IVsHierarchy h, uint itemId, ref List <String> items)
        {
            IntPtr nestedValue = IntPtr.Zero;
            uint   nestedId    = 0;
            Guid   nestedGuid  = typeof(IVsHierarchy).GUID;
            int    result      = h.GetNestedHierarchy(itemId, ref nestedGuid, out nestedValue, out nestedId);

            if (ErrorHandler.Succeeded(result) && nestedValue != IntPtr.Zero && nestedId == VSConstants.VSITEMID_ROOT)
            {
                // Get the nested hierachy
                IVsProject project = Marshal.GetObjectForIUnknown(nestedValue) as IVsProject;
                Marshal.Release(nestedValue);
                if (project != null)
                {
                    GetIceBuilderItems(project as IVsHierarchy, VSConstants.VSITEMID_ROOT, ref items);
                }
            }
            else
            {
                // Get the first visible child node
                object value;
                result = h.GetProperty(itemId, (int)__VSHPROPID.VSHPROPID_FirstVisibleChild, out value);
                while (result == VSConstants.S_OK && value != null)
                {
                    uint child = DTEUtil.GetItemId(value);
                    if (child == VSConstants.VSITEMID_NIL)
                    {
                        // No more nodes
                        break;
                    }
                    else
                    {
                        result = h.GetProperty(child, (int)__VSHPROPID.VSHPROPID_Name, out value);
                        string path = value as string;
                        if (IsSliceFileName(path))
                        {
                            items.Add(path);
                        }
                        GetIceBuilderItems(h, child, ref items);

                        // Get the next visible sibling node
                        result = h.GetProperty(child, (int)__VSHPROPID.VSHPROPID_NextVisibleSibling, out value);
                    }
                }
            }
        }