Exemple #1
0
        private short AddType(BamlTypeInfo type)
        {
            short typeId = (short)_typeToID.Count;

            _typeToID.Add(type, typeId);

            return(typeId);
        }
Exemple #2
0
        private void WriteTypeInfo(BamlTypeInfo node)
        {
            BeginVarSize();

            short typeId = AddType(node);

            _blob.Write(ref _pos, (short)typeId);
            _blob.Write(ref _pos, (short)((ushort)GetAssemblyId(node.Assembly) | ((byte)node.Flags) << 12));
            _blob.WriteLengthPrefixedString(ref _pos, (string)node.Name);

            WriteVarSize(RecordType.TypeInfo);
        }
Exemple #3
0
        private void AddType(short typeId, BamlTypeInfo type)
        {
            int typeCount = _types.Count;

            if (typeId > typeCount)
            {
                throw new BamlException(SR.BamlLoadError);
            }

            if (typeId == typeCount)
            {
                _types.Add(type);
            }
        }
Exemple #4
0
        private void ReadTypeInfo()
        {
            ReadRecordSize();

            var node = new BamlTypeInfo();

            short typeId             = _accessor.ReadInt16();
            short flagsAndAssemblyId = _accessor.ReadInt16();

            node.Flags    = (BamlTypeFlags)(flagsAndAssemblyId >> 12);
            node.Assembly = GetAssembly((short)(flagsAndAssemblyId & 0xfff));
            node.Name     = _accessor.ReadLengthPrefixedString(Encoding.UTF8);

            AddType(typeId, node);
            AddNode(node);
        }