当前位置: 首页>>代码示例>>C#>>正文


C# DataReader.ReadUInt32方法代码示例

本文整理汇总了C#中DataReader.ReadUInt32方法的典型用法代码示例。如果您正苦于以下问题:C# DataReader.ReadUInt32方法的具体用法?C# DataReader.ReadUInt32怎么用?C# DataReader.ReadUInt32使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataReader的用法示例。


在下文中一共展示了DataReader.ReadUInt32方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadFrom

        public static DirectoryEntry ReadFrom(DataReader reader)
        {
            long startPos = reader.Position;

            long length = reader.ReadInt64();
            if (length == 0)
            {
                return null;
            }

            DirectoryEntry result = new DirectoryEntry();
            result.Length = length;
            result.Attributes = (FileAttributes)reader.ReadUInt32();
            result.SecurityId = reader.ReadUInt32();
            result.SubdirOffset = reader.ReadInt64();
            reader.Skip(16);
            result.CreationTime = reader.ReadInt64();
            result.LastAccessTime = reader.ReadInt64();
            result.LastWriteTime = reader.ReadInt64();
            result.Hash = reader.ReadBytes(20);
            reader.Skip(4);
            result.ReparseTag = reader.ReadUInt32();
            result.HardLink = reader.ReadUInt32();
            result.StreamCount = reader.ReadUInt16();
            int shortNameLength = reader.ReadUInt16();
            int fileNameLength = reader.ReadUInt16();

            if (fileNameLength > 0)
            {
                result.FileName = Encoding.Unicode.GetString(reader.ReadBytes(fileNameLength + 2)).TrimEnd('\0');
            }
            else
            {
                result.FileName = string.Empty;
            }

            if (shortNameLength > 0)
            {
                result.ShortName = Encoding.Unicode.GetString(reader.ReadBytes(shortNameLength + 2)).TrimEnd('\0');
            }
            else
            {
                result.ShortName = null;
            }

            if (startPos + length > reader.Position)
            {
                int toRead = (int)(startPos + length - reader.Position);
                reader.Skip(toRead);
            }

            if (result.StreamCount > 0)
            {
                result.AlternateStreams = new Dictionary<string, AlternateStreamEntry>();
                for (int i = 0; i < result.StreamCount; ++i)
                {
                    AlternateStreamEntry stream = AlternateStreamEntry.ReadFrom(reader);
                    result.AlternateStreams.Add(stream.Name, stream);
                }
            }

            return result;
        }
开发者ID:alexcmd,项目名称:DiscUtils,代码行数:63,代码来源:DirectoryEntry.cs

示例2: ReadResourceRecord

        private static DNSRRBase ReadResourceRecord(byte[] data, DataReader reader)
        {
            DNSRRBase rr = null;

            string name = ReadString(data, reader);
            DNSType type = (DNSType)reader.ReadUInt16(false);
            DNSClass cls = (DNSClass)reader.ReadUInt16(false);
            uint ttl = reader.ReadUInt32(false);
            ushort rlen = reader.ReadUInt16(false);
            byte[] rdata = reader.ReadBytes(rlen);

            switch (type)
            {
                case DNSType.CNAME:
                    {
                        CNameDNSRR newRec = new CNameDNSRR(data, rdata);
                        rr = newRec;
                    }
                    break;
                case DNSType.A:
                    {
                        ADNSRR aRec = new ADNSRR(rdata);
                        rr = aRec;
                    }
                    break;
                case DNSType.AAAA:
                    {
                        AAAADNSRR aRec = new AAAADNSRR(rdata);
                        rr = aRec;
                    }
                    break;
                case DNSType.PTR:
                    {
                        PTRDNSRR aRec = new PTRDNSRR(data, rdata);
                        rr = aRec;
                    }
                    break;
                default:
                    {
                        UnknownDNSRR newRec = new UnknownDNSRR();
                        newRec.RData = rdata;
                        rr = newRec;
                    }
                    break;
            }

            rr.Name = name;
            rr.Class = cls;
            rr.Type = type;
            rr.TimeToLive = ttl;

            return rr;
        }
开发者ID:michyer,项目名称:canape,代码行数:53,代码来源:DNSPacket.cs


注:本文中的DataReader.ReadUInt32方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。