本文整理汇总了C#中IStorage.Seek方法的典型用法代码示例。如果您正苦于以下问题:C# IStorage.Seek方法的具体用法?C# IStorage.Seek怎么用?C# IStorage.Seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStorage
的用法示例。
在下文中一共展示了IStorage.Seek方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteReadStorageTestAssert
private void WriteReadStorageTestAssert(int elementSize, byte[] data, IStorage storage)
{
Element expected = new Element(data);
byte[] expectedBytes = expected.Serialize().ExtendTo(elementSize);
storage.WriteByteArray(expectedBytes);
storage.Seek(0);
Element actual = Element.ReadFromStorage(storage, elementSize);
storage.Seek(0);
AssertElementsAreSame(expected, actual);
}
示例2: UpdateEdges
private void UpdateEdges(IStorage storage, List<IVisualEdge> edgeList)
{
DataHeader header = new DataHeader();
storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of edges stored
foreach (IVisualEdge edge in edgeList)
{
header.Deserialize(storage);
edge.Deserialize(storage);
}
}
示例3: UpdateNodesAndSlostWithResolveMissingSlotAfterAction
private void UpdateNodesAndSlostWithResolveMissingSlotAfterAction(IStorage storage, List<IVisualNode> nodeList, List<uint> slotIdList)
{
DataHeader header = new DataHeader();
storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of slots stored
foreach (uint slotId in slotIdList)
{
header.Deserialize(storage);
if (this.graphController.ContainSlotKey(slotId))
{
ISlot slot = this.graphController.GetSlot(slotId);
slot.Deserialize(storage);
}
else
{
ISlot slot = Slot.Create(this.graphController, storage);
this.graphController.AddSlot(slot);
}
}
storage.Seek(12, SeekOrigin.Current); //By-pass the reading of total number of nodes stored
foreach (IVisualNode node in nodeList)
{
header.Deserialize(storage);
node.Deserialize(storage);
}
}
示例4: 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);
}
示例5: RetrieveSlotIdsFromStorage
private List<uint> RetrieveSlotIdsFromStorage(IStorage storage)
{
DataHeader header = new DataHeader();
List<uint> slotIdList = new List<uint>();
int slotCount = storage.ReadInteger(FieldCode.SlotCount);
for (int i = 0; i < slotCount; i++)
{
header.Deserialize(storage);
storage.Seek(36, SeekOrigin.Current);
slotIdList.Add(storage.ReadUnsignedInteger(FieldCode.SlotId));
storage.Seek(header.DataSize - 48, SeekOrigin.Current);
}
return slotIdList;
}
示例6: 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);
}
示例7: 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);
}
示例8: Create
public static IVisualNode Create(IGraphController graphController, IStorage storage)
{
if (graphController == null || storage == null)
throw new ArgumentNullException("graphcontroller, storage");
storage.Seek(12, SeekOrigin.Current); //Skip NodeSignature
NodeType type = (NodeType)storage.ReadInteger(FieldCode.NodeType);
storage.Seek(-24, SeekOrigin.Current); //Shift cursor back to the start point of reading NodeSignature
VisualNode node = null;
switch (type)
{
case NodeType.CodeBlock:
node = new CodeBlockNode(graphController);
node.Deserialize(storage);
break;
case NodeType.Condensed:
node = new CondensedNode(graphController);
node.Deserialize(storage);
break;
case NodeType.Driver:
node = new DriverNode(graphController);
node.Deserialize(storage);
break;
case NodeType.Function:
node = new FunctionNode(graphController);
node.Deserialize(storage);
break;
case NodeType.Identifier:
node = new IdentifierNode(graphController);
node.Deserialize(storage);
break;
case NodeType.Property:
node = new PropertyNode(graphController);
node.Deserialize(storage);
break;
case NodeType.Render:
node = new RenderNode(graphController);
node.Deserialize(storage);
break;
default:
throw new ArgumentException("Invalid 'nodeType'");
}
return node;
}
示例9: ReadUserHeader
private UserHeader ReadUserHeader(IStorage storage)
{
int userHeaderSizeSize = UserHeader.GetSizeSize();
byte[] userHeaderSizeBytes = new byte[userHeaderSizeSize];
storage.Seek(UserHeader.GetUserHeaderPosition());
storage.ReadByteArray(userHeaderSizeBytes);
int userHeaderSize = UserHeader.GetSizeFromData(userHeaderSizeBytes);
byte[] userHeaderBytes = new byte[userHeaderSize];
storage.ReadByteArray(userHeaderBytes);
return UserHeader.Deserialize(userHeaderSizeBytes.Append(userHeaderBytes));
}
示例10: WriteToStorageTestHelper
private static UserHeader WriteToStorageTestHelper(IStorage storage, int size, byte[] data)
{
storage.Seek(UserHeader.GetUserHeaderPosition());
UserHeader target = new UserHeader(size);
target.Data = data.ExtendTo(size);
storage.WriteByteArray(target.Serialize());
return target;
}