Ejemplo n.º 1
0
        private void WriteNodeAttributes(Node node)
        {
            UInt32 lastOffset = (UInt32)ValueStream.Position;

            foreach (KeyValuePair <string, NodeAttribute> entry in node.Attributes)
            {
                WriteAttributeValue(ValueWriter, entry.Value);

                var attributeInfo = new AttributeEntry();
                var length        = (UInt32)ValueStream.Position - lastOffset;
                attributeInfo.TypeAndLength      = (UInt32)entry.Value.Type | (length << 6);
                attributeInfo.NameHashTableIndex = AddStaticString(entry.Key);
                attributeInfo.NodeIndex          = NextNodeIndex;
                BinUtils.WriteStruct <AttributeEntry>(AttributeWriter, ref attributeInfo);

                if (Version >= FileVersion.VerExtendedNodes &&
                    ExtendedNodes)
                {
                    var extendedInfo = new AttributeEntryV3();
                    extendedInfo.Offset = (UInt32)ValueStream.Position;
                    BinUtils.WriteStruct <AttributeEntryV3>(AttributeWriter, ref extendedInfo);
                }

                NextAttributeIndex++;

                lastOffset = (UInt32)ValueStream.Position;
            }
        }
Ejemplo n.º 2
0
        private void WriteNodeAttributesV3(Node node)
        {
            UInt32 lastOffset = (UInt32)ValueStream.Position;
            int numWritten = 0;
            foreach (KeyValuePair<string, NodeAttribute> entry in node.Attributes)
            {
                WriteAttributeValue(ValueWriter, entry.Value);
                numWritten++;

                var attributeInfo = new AttributeEntryV3();
                var length = (UInt32)ValueStream.Position - lastOffset;
                attributeInfo.TypeAndLength = (UInt32)entry.Value.Type | (length << 6);
                attributeInfo.NameHashTableIndex = AddStaticString(entry.Key);
                if (numWritten == node.Attributes.Count)
                {
                    attributeInfo.NextAttributeIndex = -1;
                }
                else
                {
                    attributeInfo.NextAttributeIndex = NextAttributeIndex + 1;
                }
                attributeInfo.Offset = (UInt32)ValueStream.Position;
                BinUtils.WriteStruct<AttributeEntryV3>(AttributeWriter, ref attributeInfo);
                
                NextAttributeIndex++;

                lastOffset = (UInt32)ValueStream.Position;
            }
        }