Пример #1
0
        static AmqpMessageReader()
        {
            MessageSections = new SectionInfo[]
            {
                new SectionInfo()
                {
                    Flag    = SectionFlag.Header,
                    Code    = Header.Code,
                    Name    = Header.Name,
                    Ctor    = () => new Header(),
                    Scanner = (a, b) => ScanListSection(a, b)
                },
                new SectionInfo()
                {
                    Flag    = SectionFlag.DeliveryAnnotations,
                    Code    = DeliveryAnnotations.Code,
                    Name    = DeliveryAnnotations.Name,
                    Ctor    = () => new DeliveryAnnotations(),
                    Scanner = (a, b) => ScanMapSection(a, b)
                },
                new SectionInfo()
                {
                    Flag    = SectionFlag.MessageAnnotations,
                    Code    = MessageAnnotations.Code,
                    Name    = MessageAnnotations.Name,
                    Ctor    = () => new MessageAnnotations(),
                    Scanner = (a, b) => ScanMapSection(a, b)
                },
                new SectionInfo()
                {
                    Flag    = SectionFlag.Properties,
                    Code    = Properties.Code,
                    Name    = Properties.Name,
                    Ctor    = () => new Properties(),
                    Scanner = (a, b) => ScanListSection(a, b)
                },
                new SectionInfo()
                {
                    Flag    = SectionFlag.ApplicationProperties,
                    Code    = ApplicationProperties.Code,
                    Name    = ApplicationProperties.Name,
                    Ctor    = () => new ApplicationProperties(),
                    Scanner = (a, b) => ScanMapSection(a, b)
                },
                new SectionInfo()
                {
                    Flag    = SectionFlag.Data,
                    Code    = Data.Code,
                    Name    = Data.Name,
                    Ctor    = () => new Data(),
                    Scanner = (a, b) => ScanDataSection(a, b)
                },
                new SectionInfo()
                {
                    Flag    = SectionFlag.AmqpSequence,
                    Code    = AmqpSequence.Code,
                    Name    = AmqpSequence.Name,
                    Ctor    = () => new AmqpSequence(),
                    Scanner = (a, b) => ScanListSection(a, b)
                },
                new SectionInfo()
                {
                    Flag    = SectionFlag.AmqpValue,
                    Code    = AmqpValue.Code,
                    Name    = AmqpValue.Name,
                    Ctor    = () => new AmqpValue(),
                    Scanner = (a, b) => ScanValueSection(a, b)
                },
                new SectionInfo()
                {
                    Flag    = SectionFlag.Footer,
                    Code    = Footer.Code,
                    Name    = Footer.Name,
                    Ctor    = () => new Footer(),
                    Scanner = (a, b) => ScanMapSection(a, b)
                },
            };

            for (int i = 0; i < MessageSections.Length; i++)
            {
                SectionInfo info = MessageSections[i];
                AmqpCodec.RegisterKnownTypes(info.Name, info.Code, info.Ctor);
            }
        }