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


C# BinaryReader.ReadGuid方法代码示例

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


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

示例1: ReadFromFile

 public static void ReadFromFile(IndexUnit indexPage, BinaryReader reader)
 {
     long initPos = reader.Seek(100L + (indexPage.UnitID * 0x1000L));
     if (reader.ReadByte() != 2)
     {
         throw new FileDBException("PageID {0} is not a Index Page", new object[] { indexPage.UnitID });
     }
     indexPage.NextUnitID = reader.ReadUInt32();
     indexPage.NodeIndex = reader.ReadByte();
     reader.Seek(initPos + 0x2eL);
     for (int i = 0; i <= indexPage.NodeIndex; i++)
     {
         IndexNode node = indexPage.Nodes[i];
         node.ID = reader.ReadGuid();
         node.IsDeleted = reader.ReadBoolean();
         node.Right.Index = reader.ReadByte();
         node.Right.PageID = reader.ReadUInt32();
         node.Left.Index = reader.ReadByte();
         node.Left.PageID = reader.ReadUInt32();
         node.DataPageID = reader.ReadUInt32();
         node.FileName = reader.ReadString(0x29);
         node.FileExtension = reader.ReadString(5);
         node.FileLength = reader.ReadUInt32();
     }
 }
开发者ID:mind0n,项目名称:hive,代码行数:25,代码来源:UnitFactory.cs

示例2: RetrieveChildren

        public IEnumerable<Guid> RetrieveChildren(Guid id)
        {
            List<Guid> children = new List<Guid>();
            string file = GetChildrenFilename(id);
            if (!File.Exists(file)) return null;

            try {

                using (Stream fs = ReadFileStream(file)) {
                    BinaryReader br = new BinaryReader(fs);
                    lock (children) {
                        var count = br.ReadInt32();
                        var itemsRead = 0;
                        while (itemsRead < count) {
                            children.Add(br.ReadGuid());
                            itemsRead++;
                        }
                    }
                }
            } catch (Exception e) {
                Logger.ReportException("Failed to retrieve children:", e);
            #if DEBUG
                throw;
            #else
                return null;
            #endif

            }

            return children.Count == 0 ? null : children;
        }
开发者ID:purplecow,项目名称:Media-Browser,代码行数:31,代码来源:ItemRepository.cs

示例3: ReadFromFile

        public static void ReadFromFile(IndexPage indexPage, BinaryReader reader)
        {
            // Seek the stream to the fist byte on page
            long initPos = reader.Seek(Header.HEADER_SIZE + ((long)indexPage.PageID * BasePage.PAGE_SIZE));

            if (reader.ReadByte() != (byte)PageType.Index)
                throw new FileDBException("PageID {0} is not a Index Page", indexPage.PageID);

            indexPage.NextPageID = reader.ReadUInt32();
            indexPage.NodeIndex = reader.ReadByte();

            // Seek the stream to end of header data page
            reader.Seek(initPos + IndexPage.HEADER_SIZE);

            for (int i = 0; i <= indexPage.NodeIndex; i++)
            {
                var node = indexPage.Nodes[i];

                node.ID = reader.ReadGuid();

                node.IsDeleted = reader.ReadBoolean();

                node.Right.Index = reader.ReadByte();
                node.Right.PageID = reader.ReadUInt32();
                node.Left.Index = reader.ReadByte();
                node.Left.PageID = reader.ReadUInt32();

                node.DataPageID = reader.ReadUInt32();

                node.FileName = reader.ReadString(IndexNode.FILENAME_SIZE);
                node.FileExtension = reader.ReadString(IndexNode.FILE_EXTENSION_SIZE);
                node.FileLength = reader.ReadUInt32();
            }
        }
开发者ID:RainsSoft,项目名称:FileDB,代码行数:34,代码来源:PageFactory.cs

示例4: Deserialize

        public static DataPointToAuction Deserialize(Stream stream)
        {
            var reader = new BinaryReader(stream);
            var snapshot = new DataPointToAuction();
            snapshot.Id = reader.ReadGuid();
            snapshot.DataPointTimeStamp = reader.ReadDouble();
            snapshot.DataPointRealmSlug = reader.ReadString();
            snapshot.Auction = reader.ReadInt64();
            snapshot.TimeLeft = reader.ReadString();

            return snapshot;
        }
开发者ID:wingertge,项目名称:AuctionTrends,代码行数:12,代码来源:DataPointToAuction.cs

示例5: ReadFromFile

        public static void ReadFromFile(IndexPage indexPage, BinaryReader reader)
        {
            // Seek the stream to the first byte on page
            long initPos = reader.SetReadPos(Header.FILE_START_HEADER_SIZE + (indexPage.PageID * BasePage.PAGE_SIZE));

            if (reader.ReadByte() != (byte)PageType.Index)
                throw new FileDBException("PageID {0} is not a Index Page", indexPage.PageID);

            indexPage.NextPageID = reader.ReadUInt32();
            indexPage.SetUsedNodeCount(reader.ReadByte());
            // Seek the stream to end of header data page
            reader.SetReadPos(initPos + IndexPage.INDEX_HEADER_SIZE);

            //in this version 
            //each node uses buffer= 16+1+1+4+1+4+4+8+4+2+36 =81 
            //IndexPage.NODES_PER_PAGE = 50;
            //so it use 81*50 = 4050
            //IndexPage.INDEX_HEADER_SIZE =46
            //so => 4050 +46 = 4096 
            //and each page has BasePage.PAGE_SIZE = 4096 => matched

            for (int i = 0; i <= indexPage.UsedNodeCount; i++)
            {
                var node = indexPage.Nodes[i];

                node.ID = reader.ReadGuid(); //16

                node.IsDeleted = reader.ReadBoolean(); //1 

                node.Right.Index = reader.ReadByte(); //1 
                node.Right.PageID = reader.ReadUInt32(); //4
                node.Left.Index = reader.ReadByte(); //1 
                node.Left.PageID = reader.ReadUInt32();//4

                node.DataPageID = reader.ReadUInt32();//4

                node.FileMetaDataLength = reader.ReadUInt16();//2
                node.FileLength = reader.ReadUInt32();//4

                int filenameCount = reader.ReadByte(); //1
                if (filenameCount > IndexNode.FILENAME_SIZE)
                {
                    node.FileUrl = reader.ReadUtf8String(IndexNode.FILENAME_SIZE);
                }
                else
                {
                    string filename = reader.ReadUtf8String(IndexNode.FILENAME_SIZE);
                    node.FileUrl = filename.Substring(0, filenameCount);
                }
            }
        }
开发者ID:prepare,项目名称:FileDB,代码行数:51,代码来源:PageFactory.cs

示例6: Deserialize

      public SectorCollection Deserialize(BinaryReader reader)
      {
         var sectorCollectionMagic = reader.ReadUInt32();

         if (sectorCollectionMagic != SECTOR_COLLECTION_MAGIC) {
            throw new FormatException("Expected Sector Collection Magic " + SECTOR_COLLECTION_MAGIC + " but read " + sectorCollectionMagic);
         }

         var sectorCount = reader.ReadUInt32();
         var collection = new SectorCollection();
         for (var i = 0; i < sectorCount; i++) {
            var guid = reader.ReadGuid();
            var startInclusive = reader.ReadInt64();
            var endExclusive = reader.ReadInt64();
            var sector = (ISector)Activator.CreateInstance(sectorTypesByGuid[guid]);
            sector.Deserialize(reader);
            collection.AssignSector(new SectorRange(startInclusive, endExclusive), sector);
         }
         return collection;
      }
开发者ID:ItzWarty,项目名称:Dargon.VirtualFileMaps,代码行数:20,代码来源:SectorCollectionSerializer.cs

示例7: ReadParameterValue

        private static JToken ReadParameterValue(BinaryReader reader, ParameterMetadata parameterMetadata)
        {
            switch (parameterMetadata.DataType)
            {
                case DataType.Null:
                    return null;

                case DataType.Byte:
                    return (int) reader.ReadByte();
                
                case DataType.Word:
                    return reader.ReadUInt16();

                case DataType.Dword:
                    return reader.ReadUInt32();

                case DataType.Qword:
                    return reader.ReadUInt64();

                case DataType.SignedByte:
                    return reader.ReadSByte();

                case DataType.SignedWord:
                    return reader.ReadInt16();

                case DataType.SignedDword:
                    return reader.ReadInt32();
                
                case DataType.SignedQword:
                    return reader.ReadInt64();

                case DataType.Single:
                    return reader.ReadSingle();

                case DataType.Double:
                    return reader.ReadDouble();

                case DataType.Boolean:
                    return reader.ReadByte() != 0;

                case DataType.Guid:
                    return reader.ReadGuid();

                case DataType.UtfString:
                    return reader.ReadUtfString();

                case DataType.Binary:
                    return reader.ReadBinary();

                case DataType.Array:
                    return new JArray(reader
                        .ReadArray(r => ReadParameterValue(r, parameterMetadata.Children[0]))
                        .Cast<object>()
                        .ToArray());

                case DataType.Object:
                    return new JObject(parameterMetadata.Children
                        .Select(p => new JProperty(p.Name, ReadParameterValue(reader, p)))
                        .Cast<object>()
                        .ToArray());

                default:
                    throw new NotSupportedException(parameterMetadata.DataType + " is not supported for parameters");
            }
        }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:65,代码来源:BinaryServiceBase.cs

示例8: RegisterDevice

        private void RegisterDevice(byte[] data)
        {
            var registrationInfo = new DeviceRegistrationInfo();

            using (var stream = new MemoryStream(data))
            using (var reader = new BinaryReader(stream))
            {
                registrationInfo.Id = reader.ReadGuid();
                registrationInfo.Key = reader.ReadUtfString();
                registrationInfo.Name = reader.ReadUtfString();
                registrationInfo.ClassName = reader.ReadUtfString();
                registrationInfo.ClassVersion = reader.ReadUtfString();
                registrationInfo.Equipment = reader.ReadArray(ReadEquipmentInfo);
                registrationInfo.Notifications = reader.ReadArray(ReadNotificationInfo);
                registrationInfo.Commands = reader.ReadArray(ReadCommandInfo);
            }

            RegisterDeviceCore(registrationInfo);
        }
开发者ID:bestpetrovich,项目名称:devicehive-.net,代码行数:19,代码来源:BinaryServiceBase.cs

示例9: RetrieveChildrenOld


//.........这里部分代码省略.........
        //                double total = cacheFiles.Count();
        //                foreach (var file in cacheFiles)
        //                {
        //                    UpdateProgress("Items", (double)(cnt / total));
        //                    try
        //                    {
        //                        using (Stream fs = MediaBrowser.Library.Filesystem.ProtectedFileStream.OpenSharedReader(file))
        //                        {
        //                            BinaryReader reader = new BinaryReader(fs);
        //                            item = Serializer.Deserialize<MediaBrowser.Library.Entities.BaseItem>(fs);
        //                        }
        //                        if (item != null)
        //                        {
        //                            Logger.ReportInfo("Migrating Item: " + item.Name);
        //                            newRepo.SaveItem(item);
        //                            if (item is Folder)
        //                            {
        //                                //need to save our children refs
        //                                var children = RetrieveChildrenOld(item.Id);
        //                                if (children != null) newRepo.SaveChildren(item.Id, children);
        //                            }
        //                            cnt++;
        //                            if (item is Video && (item as Video).RunningTime != null)
        //                            {
        //                                TimeSpan duration = TimeSpan.FromMinutes((item as Video).RunningTime.Value);
        //                                if (duration.Ticks > 0)
        //                                {
        //                                    PlaybackStatus ps = newRepo.RetrievePlayState(item.Id);
        //                                    decimal pctIn = Decimal.Divide(ps.PositionTicks, duration.Ticks) * 100;
        //                                    if (pctIn > Kernel.Instance.ConfigData.MaxResumePct)
        //                                    {
        //                                        Logger.ReportInfo("Setting " + item.Name + " to 'Watched' based on last played position.");
        //                                        ps.PositionTicks = 0;
        //                                        newRepo.SavePlayState(ps);
        //                                    }
        //                                }
        //                            }
        //                        }
        //                    }
        //                    catch (Exception e)
        //                    {
        //                        //this could fail if some items have already been refreshed before we migrated them
        //                        Logger.ReportException("Could not migrate item (probably just old data) " + file + e != null && e.InnerException != null ? " Inner Exception: " + e.InnerException.Message : "", e);
        //                    }
        //                }
        //                Logger.ReportInfo(cnt + " Items migrated successfully.");
        //            }
        //        }
        //        catch (Exception e)
        //        {
        //            Logger.ReportException("Error in migration - will need to re-build cache.", e);
        //            try
        //            {
        //                File.Delete(sqliteDb);
        //            }
        //            catch { }
        //        }
        //        UpdateProgress("Finishing up...",1);
        //        try
        //        {
        //            Async.RunWithTimeout(newRepo.ShutdownDatabase, 30000); //be sure all writes are flushed
        //        }
        //        catch
        //        {
        //            Logger.ReportWarning("Timed out attempting to close out DB.  Assuming all is ok and moving on...");
        //        }
        //    }
        //    else Logger.ReportInfo("Nothing to Migrate.  Version is: " + _config.MBVersion);
        //}
        public IEnumerable<Guid> RetrieveChildrenOld(Guid id)
        {
            List<Guid> children = new List<Guid>();
            string file = Path.Combine(Path.Combine(ApplicationPaths.AppCachePath, "Children"), id.ToString("N"));
            if (!File.Exists(file)) return null;

            try
            {

                using (Stream fs = MediaBrowser.Library.Filesystem.ProtectedFileStream.OpenSharedReader(file))
                {
                    BinaryReader br = new BinaryReader(fs);
                    lock (children)
                    {
                        var count = br.ReadInt32();
                        var itemsRead = 0;
                        while (itemsRead < count)
                        {
                            children.Add(br.ReadGuid());
                            itemsRead++;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Logger.ReportException("Failed to retrieve children:", e);
                return null;
            }
            return children.Count == 0 ? null : children;
        }
开发者ID:xantilas,项目名称:videobrowser,代码行数:101,代码来源:MainWindow.xaml.cs

示例10: Deserialize

        public static Upgrade Deserialize(Stream stream)
        {
            var reader = new BinaryReader(stream);
            var upgrade = new Upgrade();
            upgrade.Id = reader.ReadGuid();
            upgrade.UpgradeId = reader.ReadInt32();
            upgrade.Auction = reader.ReadInt64();

            return upgrade;
        }
开发者ID:wingertge,项目名称:AuctionTrends,代码行数:10,代码来源:Auction.cs


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