public IEnumerable AllMessages()

in shims/amqpnetlite/src/amqp_large_content_test/Sender/Sender.cs [628:712]


        public IEnumerable<Message> AllMessages()
        {
            if (String.Equals(amqpType, "binary", StringComparison.OrdinalIgnoreCase) ||
                String.Equals(amqpType, "string", StringComparison.OrdinalIgnoreCase) ||
                String.Equals(amqpType, "symbol", StringComparison.OrdinalIgnoreCase))
            {
                // Deserialize the count spec list
                var itMsgs = JsonConvert.DeserializeObject<dynamic>(countSpec);
                //if (!(itMsgs is Array))
                //    throw new ApplicationException(String.Format(
                //        "Messages are not formatted as a json list: {0}, but as type: {1}", countSpec, itMsgs.GetType().Name));

                // Generate messages
                if (String.Equals(amqpType, "binary", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (Int32 mbSize in itMsgs)
                    {
                        string binStr = new string(Convert.ToChar(0), mbSize * mbFactor);
                        MessageValue mv = new MessageValue(amqpType, binStr);
                        yield return mv.ToMessage();
                    }
                }
                else if (String.Equals(amqpType, "string", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (Int32 mbSize in itMsgs)
                    {
                        string binStr = new string('s', mbSize * mbFactor);
                        MessageValue mv = new MessageValue(amqpType, binStr);
                        yield return mv.ToMessage();
                    }
                }
                else if (String.Equals(amqpType, "symbol", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (Int32 mbSize in itMsgs)
                    {
                        string binStr = new string('b', mbSize * mbFactor);
                        MessageValue mv = new MessageValue(amqpType, binStr);
                        yield return mv.ToMessage();
                    }
                }
            }
            else if (String.Equals(amqpType, "list", StringComparison.OrdinalIgnoreCase))
            {
                mbSpec = new MbSpec(countSpec);
                foreach (MbBlock mbBlock in mbSpec.MbBlocks)
                {
                    foreach (Int32 eCount in mbBlock.nChunks)
                    {
                        Int32 sizePerEltBytes = (mbBlock.mBytes * mbFactor) / eCount;
                        string[] testList = new string[eCount];
                        for (int i = 0; i < eCount; i++)
                        {
                            testList[i] = new string('L', sizePerEltBytes);
                        }
                        MessageValue mv = new MessageValue(amqpType, testList);
                        yield return mv.ToMessage();
                    }
                }
            }
            else if (String.Equals(amqpType, "map", StringComparison.OrdinalIgnoreCase))
            {
                mbSpec = new MbSpec(countSpec);
                foreach (MbBlock mbBlock in mbSpec.MbBlocks)
                {
                    foreach (Int32 eCount in mbBlock.nChunks)
                    {
                        Int32 sizePerEltBytes = (mbBlock.mBytes * mbFactor) / eCount;
                        Dictionary<string, object> testMap = new Dictionary<string, object>();
                        for (int i = 0; i < eCount; i++)
                        {
                            testMap[i.ToString("000000")] = new string('M', sizePerEltBytes);
                        }
                        MessageValue mv = new MessageValue(amqpType, testMap);
                        yield return mv.ToMessage();
                    }
                }
            }
            // else if (String.Equals(amqpType, "array", StringComparison.OrdinalIgnoreCase))
            //{ /* TODO */ }
            else
            {
                throw new ApplicationException(String.Format(
                    "unsupported amqp type: {0}", amqpType));
            }
        }