private Type CreateStruct(NdrBaseStructureTypeReference struct_type)
        {
            if (m_structs.ContainsKey(struct_type))
            {
                return(m_structs[struct_type]);
            }

            ReportProgress($"Creating Type {struct_type.Name}");

            TypeBuilder tb = m_module.DefineType(
                MakeIdentifier(struct_type.Name),
                TypeAttributes.Public | TypeAttributes.SequentialLayout | TypeAttributes.Sealed);

            tb.SetParent(typeof(ValueType));
            m_structs[struct_type] = tb;

            foreach (var member in struct_type.Members)
            {
                var type_desc = GetTypeDescriptor(0, member.MemberType, true);
                if (type_desc == null)
                {
                    break;
                }
                var field = tb.DefineField(MakeIdentifier(member.Name), type_desc.BuiltinType, FieldAttributes.Public);
                foreach (var attr in type_desc.CustomAttributes)
                {
                    field.SetCustomAttribute(attr);
                }
            }

            m_fixup.Enqueue(tb);
            return(m_structs[struct_type]);
        }
Пример #2
0
        public void UpdateNames(NdrBaseStructureTypeReference type)
        {
            type.Name = Name;
            var members = type.Members.ToList();

            foreach (var member in Members)
            {
                if (members.Count > member.Index)
                {
                    members[member.Index].Name = member.Name;
                }
            }
        }
Пример #3
0
 public NdrStructureNameData(NdrBaseStructureTypeReference type, int index)
 {
     Index   = index;
     Name    = type.Name;
     Members = type.Members.Select((m, i) => new NdrStructureMemberNameData(m, i)).ToList();
 }