Пример #1
0
 private static SimpleTypeRestrictions GetSimpleTypeRestrictions(FileFormatVersions fileFormat)
 {
     using (var simpleTypes = GetStream(fileFormat, SimpleTypes))
     {
         return(SimpleTypeRestrictions.Deserialize(simpleTypes, fileFormat));
     }
 }
Пример #2
0
        /// <summary>
        /// Load the schema constraint data from the stream.
        /// </summary>
        /// <param name="dataStream">The data stream.</param>
        internal void Load(Stream dataStream)
        {
            Debug.Assert(dataStream != null);
            Debug.Assert(dataStream.CanRead);
            Debug.Assert(dataStream.CanSeek);
            Debug.Assert(dataStream.Length > SdbDataHead.HeadSize);

            byte[] headBytes = new byte[SdbDataHead.HeadSize];

            dataStream.Read(headBytes, 0, SdbDataHead.HeadSize);
            this.SdbDataHead.LoadFromBytes(headBytes, 0);

#if DEBUG
            CheckDataHead((int)dataStream.Length);
#endif

            byte[] dataBytes;
            int    count;

            // class ID map
            count     = this.SdbDataHead.ClassIdsCount * SdbClassIdToSchemaTypeIndex.TypeSize;
            dataBytes = new byte[count];
            dataStream.Read(dataBytes, 0, count);
            this.SdbClassIdMap = new SdbDataArray <SdbClassIdToSchemaTypeIndex>(dataBytes, SdbDataHead.ClassIdsCount);

            // schema types
            count     = this.SdbDataHead.SchemaTypeCount * SdbSchemaType.TypeSize;
            dataBytes = new byte[count];
            dataStream.Read(dataBytes, 0, count);
            this.SdbSchemaTypes = new SdbDataArray <SdbSchemaType>(dataBytes, SdbDataHead.SchemaTypeCount);

            // particle constraints
            count     = this.SdbDataHead.ParticleCount * SdbParticleConstraint.TypeSize;
            dataBytes = new byte[count];
            dataStream.Read(dataBytes, 0, count);
            this.SdbParticles = new SdbDataArray <SdbParticleConstraint>(dataBytes, SdbDataHead.ParticleCount);

            // particle children index
            count     = this.SdbDataHead.ParticleChildrenIndexCount * SdbParticleChildrenIndex.TypeSize;
            dataBytes = new byte[count];
            dataStream.Read(dataBytes, 0, count);
            this.SdbParticleIndexs = new SdbDataArray <SdbParticleChildrenIndex>(dataBytes, SdbDataHead.ParticleChildrenIndexCount);

            // attribute constraints
            count     = this.SdbDataHead.AttributeCount * SdbAttributeConstraint.TypeSize;
            dataBytes = new byte[count];
            dataStream.Read(dataBytes, 0, count);
            this.SdbAttributes = new SdbDataArray <SdbAttributeConstraint>(dataBytes, SdbDataHead.AttributeCount);

            // simple type constraints
            dataStream.Seek(this.SdbDataHead.SimpleTypeDataOffset, SeekOrigin.Begin);
            this.SimpleTypeRestrictions = SimpleTypeRestrictions.Deserialize(dataStream, this._fileFormat);

#if DEBUG
            Assert(this.SdbDataHead.SimpleTypeCount == this.SimpleTypeRestrictions.SimpleTypeCount);

            CheckData();
#endif
        }