Beispiel #1
0
        private void Add(AttributeType attributeType, string name, AttributeTypeFlags attributeTypeFlags, int minSize, int maxSize)
        {
            AttributeDefinitionRecord adr = new AttributeDefinitionRecord();

            adr.Type    = attributeType;
            adr.Name    = name;
            adr.Flags   = attributeTypeFlags;
            adr.MinSize = minSize;
            adr.MaxSize = maxSize;
            _attrDefs.Add(attributeType, adr);
        }
        public AttributeDefinitions(File file)
        {
            _attrDefs = new Dictionary<AttributeType, AttributeDefinitionRecord>();

            byte[] buffer = new byte[AttributeDefinitionRecord.Size];
            using (Stream s = file.OpenStream(AttributeType.Data, null, FileAccess.Read))
            {
                while (Utilities.ReadFully(s, buffer, 0, buffer.Length) == buffer.Length)
                {
                    AttributeDefinitionRecord record = new AttributeDefinitionRecord();
                    record.Read(buffer, 0);

                    // NULL terminator record
                    if (record.Type != AttributeType.None)
                    {
                        _attrDefs.Add(record.Type, record);
                    }
                }
            }
        }
Beispiel #3
0
        public AttributeDefinitions(File file)
        {
            _attrDefs = new Dictionary <AttributeType, AttributeDefinitionRecord>();

            byte[] buffer = new byte[AttributeDefinitionRecord.Size];
            using (Stream s = file.OpenStream(AttributeType.Data, null, FileAccess.Read))
            {
                while (Utilities.ReadFully(s, buffer, 0, buffer.Length) == buffer.Length)
                {
                    AttributeDefinitionRecord record = new AttributeDefinitionRecord();
                    record.Read(buffer, 0);

                    // NULL terminator record
                    if (record.Type != AttributeType.None)
                    {
                        _attrDefs.Add(record.Type, record);
                    }
                }
            }
        }
Beispiel #4
0
        public void WriteTo(File file)
        {
            List <AttributeType> attribs = new List <AttributeType>(_attrDefs.Keys);

            attribs.Sort();

            using (Stream s = file.OpenStream(AttributeType.Data, null, FileAccess.ReadWrite))
            {
                byte[] buffer;
                for (int i = 0; i < attribs.Count; ++i)
                {
                    buffer = new byte[AttributeDefinitionRecord.Size];
                    AttributeDefinitionRecord attrDef = _attrDefs[attribs[i]];
                    attrDef.Write(buffer, 0);

                    s.Write(buffer, 0, buffer.Length);
                }

                buffer = new byte[AttributeDefinitionRecord.Size];
                s.Write(buffer, 0, buffer.Length);
            }
        }
 private void Add(AttributeType attributeType, string name, AttributeTypeFlags attributeTypeFlags, int minSize, int maxSize)
 {
     AttributeDefinitionRecord adr = new AttributeDefinitionRecord();
     adr.Type = attributeType;
     adr.Name = name;
     adr.Flags = attributeTypeFlags;
     adr.MinSize = minSize;
     adr.MaxSize = maxSize;
     _attrDefs.Add(attributeType, adr);
 }