Exemplo n.º 1
0
        /// <summary>
        /// Creates an idlist from parsing string format.
        /// </summary>
        /// <param name="str">The string.</param>
        /// <returns>The idlist represented by the string.</returns>
        public static IdList FromParsingString(string str)
        {
            //  Create the id storage.
            var ids = new List <ShellId>();

            //  Repeatedly read a short length then the data.
            int index = 0;

            while (index < str.Length)
            {
                var length = Convert.ToInt16(str.Substring(index, 4), 16);
                var id     = new byte[length];
                index += 4;
                for (var i = 0; i < length; i++, index += 2)
                {
                    id[i] = Convert.ToByte(str.Substring(index, 2), 16);
                }
                ids.Add(ShellId.FromData(id));
            }

            //  Return the list.
            return(new IdList(ids));
        }
Exemplo n.º 2
0
        private static IShellNamespaceFolder GetChildFolder(IShellNamespaceFolder folder, ShellId itemId)
        {
            //  Get the item that is represented by the shell id.
            var childFolder = folder
                .GetChildren(ShellNamespaceEnumerationFlags.Folders)
                .OfType<IShellNamespaceFolder>()
                .SingleOrDefault(i => i.GetShellId().Equals(itemId));

            //  If we don't find the item, we've got a problem.
            if (childFolder == null)
            {
                //  TODO how will we handle this error?
                var me = folder.GetDisplayName(DisplayNameContext.Normal);
                var you = itemId.ToString();
                return null;
            }
            return childFolder;
        }