Beispiel #1
0
        /// <summary>
        /// Read the tag from the supplied I\O stream
        /// </summary>
        public void Read()
        {
            if (InputStream == null)
            {
                Debug.Assert.If(false, "Tried to read a tag that we didn't open. {0}:{1}", engine, this.Path);
            }

            if (engine == BlamVersion.Unknown)
            {
                CalculateVersion();
            }

            ReadPreprocess();
            bool needs_upgrading = false;

            // Read past the tag field set header of the tag group
            if (DefinitionState.FieldSetRequiresVersioningHeader(this))
            {
                IFieldSetVersioning fs = tagDefinition.State.FieldSetReadVersion(this, FieldType.Tag, InputStream.PositionUnsigned);

                if (needs_upgrading = fs.NeedsUpgrading)
                {
                    int index, size_of;
                    fs.GetUpgradeParameters(out index, out size_of);

                    if (!fs.UseImplicitUpgrading)
                    {
                        tagDefinition = tagDefinition.NewInstance((tagDefinition as IStructureOwner).OwnerObject, index, size_of);
                        flags.Add(IO.ITagStreamFlags.DefinitionWasUpgraded);
                    }
                    else
                    {
                        tagDefinition.VersionImplicitUpgradeBegin(size_of, this);
                    }
                }
            }

            tagDefinition.Read(this);

            if (needs_upgrading)
            {
                if (tagDefinition.VersionImplicitUpgradeIsActive)
                {
                    tagDefinition.VersionImplicitUpgradeEnd();
                }
                else
                {
#if DEBUG
                    if (!tagDefinition.Upgrade())
                    {
                        Debug.Assert.If(false, "Failed to upgrade tag group. {0} {1}", tagDefinition.GetType().Name, tagDefinition.ToVersionString());
                    }
#else
                    tagDefinition.Upgrade();
#endif
                }
            }
        }
Beispiel #2
0
        void WriteImpl()
        {
            WritePreprocess();

            // Write the tag field set header for the tag group
            if (DefinitionState.FieldSetRequiresVersioningHeader(this))
            {
                tagDefinition.State.FieldSetWriteVersion(this, FieldType.Tag);
            }

            if (!tagDefinition.PostProcessGroup(false))
            {
                Debug.Warn.If(false, "{0} failed to postprocess. {1}.{2}", tagDefinition.GetType().FullName, this.Name, this.tagGroup.Name);
            }
            tagDefinition.Write(this);
        }