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


C# IStorage.GetPosition方法代码示例

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


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

示例1: Serialize

        public bool Serialize(IStorage storage)
        {
            if (storage == null)
                throw new ArgumentNullException("storage");

            try
            {
                long before = storage.GetPosition();
                storage.WriteUnsignedInteger(FieldCode.DataHeaderSignature, Configurations.DataHeaderSignature);
                storage.WriteInteger(FieldCode.DataHeaderVersion, (int)DataHeader.Version.Current);
                storage.WriteLong(FieldCode.HeaderSize, this.HeaderSize);
                storage.WriteLong(FieldCode.DataSize, this.DataSize);
                long after = storage.GetPosition();

                // Ensuring the header size agrees with what we say it is.
                System.Diagnostics.Debug.Assert((after - before) == this.HeaderSize);
                return true;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message + "\n Data header serialization failed.");
                return false;
            }
        }
开发者ID:samuto,项目名称:designscript,代码行数:24,代码来源:DataHeader.cs

示例2: RecordRuntimeStates

        private void RecordRuntimeStates(IStorage storage, RuntimeStates runtimeStates, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long initialPosition = storage.GetPosition();

            //Record states
            storage.Seek(header.HeaderSize, SeekOrigin.Current);
            long initialPositionForData = storage.GetPosition();
            runtimeStates.Serialize(storage);
            long currentPositionforData = storage.GetPosition();
            header.DataSize = currentPositionforData - initialPositionForData;
            storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
            header.Serialize(storage);
            storage.Seek(header.DataSize, SeekOrigin.Current);

            this.RecordFlag(storage, initialPosition, userAction);
        }
开发者ID:samuto,项目名称:designscript,代码行数:17,代码来源:UndoRedoRecorder.cs

示例3: RecordNodesAndSlots

        private void RecordNodesAndSlots(IStorage storage, List<IVisualNode> nodeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long initialPostionForData, currentPositionForData = 0;
            long initialPosition = storage.GetPosition();

            //Retrieve all the slots Id in nodeList
            List<uint> allSlotsId = new List<uint>();
            foreach (IVisualNode node in nodeList)
            {
                if (node.GetInputSlots() != null)
                    allSlotsId.AddRange(node.GetInputSlots());
                if (node.GetOutputSlots() != null)
                    allSlotsId.AddRange(node.GetOutputSlots());
            }

            //Record the number of slots and the slot itself
            storage.WriteInteger(FieldCode.SlotCount, allSlotsId.Count());
            foreach (uint slotId in allSlotsId)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                ISlot slot = this.graphController.GetSlot(slotId);
                slot.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            //Record the number of nodes and the node itself
            storage.WriteInteger(FieldCode.NodeCount, nodeList.Count);
            foreach (IVisualNode node in nodeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                node.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
开发者ID:samuto,项目名称:designscript,代码行数:47,代码来源:UndoRedoRecorder.cs

示例4: RecordNodeIds

        private void RecordNodeIds(IStorage storage, List<IVisualNode> nodeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            header.DataSize = Configurations.UndoReDoDataHeaderSize;
            long initialPosition = storage.GetPosition();

            //Record the number of nodes and the nodeIds
            storage.WriteInteger(FieldCode.NodeCount, nodeList.Count);
            foreach (IVisualNode node in nodeList)
            {
                header.Serialize(storage);
                storage.WriteUnsignedInteger(FieldCode.NodeId, node.NodeId);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
开发者ID:samuto,项目名称:designscript,代码行数:16,代码来源:UndoRedoRecorder.cs

示例5: RecordFlag

 private void RecordFlag(IStorage storage, long initialPosition, UserAction userAction)
 {
     //Record the number of bytes shifted
     long currentPosition = storage.GetPosition();
     long shift = currentPosition - initialPosition;
     storage.WriteLong(FieldCode.Shift, shift);
     storage.WriteInteger(FieldCode.UserAction, (int)userAction);
 }
开发者ID:samuto,项目名称:designscript,代码行数:8,代码来源:UndoRedoRecorder.cs

示例6: RecordEdges

        private void RecordEdges(IStorage storage, List<IVisualEdge> edgeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            long initialPostionForData, currentPositionForData = 0;
            long initialPosition = storage.GetPosition();

            //Record the number of edges and the edge itself
            storage.WriteInteger(FieldCode.EdgeCount, edgeList.Count);
            foreach (IVisualEdge edge in edgeList)
            {
                storage.Seek(header.HeaderSize, SeekOrigin.Current);
                initialPostionForData = storage.GetPosition();
                edge.Serialize(storage);
                currentPositionForData = storage.GetPosition();
                header.DataSize = currentPositionForData - initialPostionForData;
                storage.Seek(-(header.HeaderSize + header.DataSize), SeekOrigin.Current);
                header.Serialize(storage);
                storage.Seek(header.DataSize, SeekOrigin.Current);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
开发者ID:samuto,项目名称:designscript,代码行数:22,代码来源:UndoRedoRecorder.cs

示例7: RecordEdgeIds

        private void RecordEdgeIds(IStorage storage, List<IVisualEdge> edgeList, UserAction userAction)
        {
            DataHeader header = new DataHeader();
            header.DataSize = 12;
            long initialPosition = storage.GetPosition();

            //Record the number of edges and the edgeIds
            storage.WriteInteger(FieldCode.EdgeCount, edgeList.Count);
            foreach (IVisualEdge edge in edgeList)
            {
                header.Serialize(storage);
                storage.WriteUnsignedInteger(FieldCode.EdgeId, edge.EdgeId);
            }

            this.RecordFlag(storage, initialPosition, userAction);
        }
开发者ID:samuto,项目名称:designscript,代码行数:16,代码来源:UndoRedoRecorder.cs


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