示例#1
0
文件: IdList.cs 项目: RaphaelK12/WSF
        /// <summary>
        /// Get Parent Id which is always the first part
        /// minus last (child) id in the sequence.
        /// </summary>
        /// <returns>ParentId or null if the id list
        /// contains only 1 or less items (parent is unknown).</returns>
        public IdList GetParentId()
        {
            if (Size <= 1)
            {
                return(null);
            }

            IdList parentList = null;

            var parent = new List <ShellId>();

            for (int i = 0; i < Ids.Count - 1; i++)
            {
                parent.Add(ShellId.FromData(Ids[i].RawId));
            }

            parentList = IdList.Create(parent);

            return(parentList);
        }
示例#2
0
文件: IdList.cs 项目: RaphaelK12/WSF
        /// <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 idList = 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);
                }

                idList.Add(ShellId.FromData(id));
            }

            //  Return the list.
            return(new IdList(idList));
        }