示例#1
0
        /// <summary>
        /// Parses the LinkTargetIdList
        /// </summary>
        /// <exception cref="LinkTargetIdListException">Thrown if doesn't get to terminal ID</exception>
        private void ParseLinkTargetIdList()
        {
            LinkTargetIdList = new Structs.LinkTargetIDList
            {
                Size = Stream.ReadStruct <short>(),
                List = new Structs.IDList {
                    ItemIDList = new List <Structs.ItemID>()
                }
            };

            var pos = 0;

            while (pos < LinkTargetIdList.Size - 2)
            {
                var itemId = new Structs.ItemID {
                    Size = Stream.ReadStruct <ushort>()
                };

                itemId.Data = new byte[itemId.Size - 2];
                Stream.Read(itemId.Data, 0, itemId.Data.Length);

                LinkTargetIdList.List.ItemIDList.Add(itemId);

                pos += itemId.Size;
            }

            LinkTargetIdList.List.TerminalID = Stream.ReadStruct <ushort>();

            if (LinkTargetIdList.List.TerminalID != 0)
            {
                throw new LinkTargetIdListException("LinkTargetIdList.TerminalID must be 0",
                                                    nameof(LinkTargetIdList.List.TerminalID));
            }
        }
        /// <summary>
        /// Resets the Stream position to the beginning and clears the fields
        /// </summary>
        private void Reset()
        {
            Stream.Seek(0, SeekOrigin.Begin);

            ShellLinkHeader  = new Structs.ShellLinkHeader();
            LinkTargetIdList = new Structs.LinkTargetIDList();
            LinkInfo         = new Structs.LinkInfo();
            StringData       = new Structs.StringData();
        }