コード例 #1
0
        public void TestMultipleMessages()
        {
            var outStream = new MemoryStream();
            var output    = new MessageOutputStream(outStream);

            output.RegisterTemplate(ObjectMother.AllocInstrctnTemplateId,
                                    ObjectMother.AllocationInstruction);

            var allocations = new SequenceValue(ObjectMother.AllocationInstruction
                                                .GetSequence("Allocations"));

            allocations.Add(ObjectMother.NewAllocation("fortyFiveFund", 22.5, 75.0));
            allocations.Add(ObjectMother.NewAllocation("fortyFund", 24.6, 25.0));

            Message ai1 = ObjectMother.NewAllocInstrctn(
                "ltg0001", 1, 100.0, 23.4, ObjectMother.NewInstrument("CTYA", "200910"), allocations);

            allocations = new SequenceValue(
                ObjectMother.AllocationInstruction.GetSequence("Allocations"));

            allocations.Add(ObjectMother.NewAllocation("fortyFiveFund", 22.5, 75.0));
            allocations.Add(ObjectMother.NewAllocation("fortyFund", 24.6, 25.0));

            Message ai2 = ObjectMother.NewAllocInstrctn(
                "ltg0001", 1, 100.0, 23.4, ObjectMother.NewInstrument("CTYA", "200910"), allocations);

            allocations = new SequenceValue(
                ObjectMother.AllocationInstruction.GetSequence("Allocations"));
            allocations.Add(ObjectMother.NewAllocation("fortyFiveFund", 22.5, 75.0));
            allocations.Add(ObjectMother.NewAllocation("fortyFund", 24.6, 25.0));

            Message ai3 = ObjectMother.NewAllocInstrctn(
                "ltg0001", 1, 100.0, 23.4, ObjectMother.NewInstrument("CTYA", "200910"), allocations);

            output.WriteMessage(ai1);
            output.WriteMessage(ai2);
            output.WriteMessage(ai3);

            byte[] bytes = outStream.ToArray();
            var    input = new MessageInputStream(new MemoryStream(bytes));

            input.RegisterTemplate(ObjectMother.AllocInstrctnTemplateId,
                                   ObjectMother.AllocationInstruction);

            Message message = input.ReadMessage();

            Assert.AreEqual(ai1, message);
            message = input.ReadMessage();
            Assert.AreEqual(ai2, message);
            Assert.AreEqual(ai3, input.ReadMessage());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            string myString = string.Empty;

            byte[] data = new byte[] {
                215, 255, 148, 50, 48, 49, 56, 48, 50, 49, 50, 45, 48, 54, 58, 51, 56, 58, 51, 55, 46, 54, 53, 185, 177, 49, 27, 154, 128, 128, 128, 129, 95, 127, 127, 192, 128, 243, 83, 89, 66, 69, 65, 78, 73, 68, 82, 50, 48, 70, 69, 66, 50, 48, 49, 184, 50, 56, 53, 54, 183, 248, 11, 25, 38, 62, 14, 253, 128, 128, 128, 128, 128, 128, 128, 2, 29, 156, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128
            };



            string s = Encoding.ASCII.GetString(data);


            //TemplateTest objTempTest = new TemplateTest();
            //objTempTest.SetUp();
            //objTempTest.TestTemplates();


            //EncodeDecodeTest objEncodeDecodeTest = new EncodeDecodeTest();
            //objEncodeDecodeTest.TestComplexMessage();


            MessageTemplate[] objMessageTemplate = null;
            _loader = new XmlMessageTemplateLoader();

            using (FileStream stream = File.OpenRead("NCEDX.xml"))
                objMessageTemplate = _loader.Load(stream);


            var outStream = new MemoryStream();

            MessageTemplate template = _loader.TemplateRegistry[new QName("IncRefreshMDEntries")];



            var input = new MessageInputStream(new MemoryStream(data));

            input.RegisterTemplate(7, template);

            Message message = input.ReadMessage();



            Console.WriteLine(myString);
            Console.ReadLine();
        }
コード例 #3
0
        public void TestComplexMessage()
        {
            var template = new MessageTemplate(
                "Company",
                new Field[]
            {
                new Scalar("Name", FastType.String, Operator.None, ScalarValue.Undefined, false),
                new Scalar("Id", FastType.U32, Operator.Increment, ScalarValue.Undefined, false),
                new Sequence(
                    "Employees",
                    new Field[]
                {
                    new Scalar("First Name", FastType.String, Operator.Copy, ScalarValue.Undefined,
                               false),
                    new Scalar("Last Name", FastType.String, Operator.Copy, ScalarValue.Undefined, false)
                    ,
                    new Scalar("Age", FastType.U32, Operator.Delta, ScalarValue.Undefined, false)
                }, false),
                new Group(
                    "Tax Information",
                    new Field[]
                {
                    new Scalar("EIN", FastType.String, Operator.None, ScalarValue.Undefined, false)
                }, false)
            });

            var aaaInsurance = new Message(template);

            aaaInsurance.SetFieldValue(1, new StringValue("AAA Insurance"));
            aaaInsurance.SetFieldValue(2, new IntegerValue(5));

            var employees = new SequenceValue(template.GetSequence(
                                                  "Employees"));

            employees.Add(new IFieldValue[]
            {
                new StringValue("John"), new StringValue("Doe"),
                new IntegerValue(45)
            });
            employees.Add(new IFieldValue[]
            {
                new StringValue("Jane"), new StringValue("Doe"),
                new IntegerValue(48)
            });
            aaaInsurance.SetFieldValue(3, employees);
            aaaInsurance.SetFieldValue(4,
                                       new GroupValue(template.GetGroup("Tax Information"),
                                                      new IFieldValue[] { new StringValue("99-99999999") }));

            var outStream = new MemoryStream();
            var output    = new MessageOutputStream(outStream);

            output.RegisterTemplate(2, template);
            output.WriteMessage(aaaInsurance);

            var abcBuilding = new Message(template);

            abcBuilding.SetFieldValue(1, new StringValue("ABC Building"));
            abcBuilding.SetFieldValue(2, new IntegerValue(6));
            employees = new SequenceValue(template.GetSequence("Employees"));
            employees.Add(new IFieldValue[]
            {
                new StringValue("Bob"), new StringValue("Builder"),
                new IntegerValue(3)
            });
            employees.Add(new IFieldValue[]
            {
                new StringValue("Joe"), new StringValue("Rock"),
                new IntegerValue(59)
            });
            abcBuilding.SetFieldValue(3, employees);
            abcBuilding.SetFieldValue(4,
                                      new GroupValue(template.GetGroup("Tax Information"),
                                                     new IFieldValue[] { new StringValue("99-99999999") }));
            output.WriteMessage(abcBuilding);

            var input = new MessageInputStream(new MemoryStream(outStream.ToArray()));

            input.RegisterTemplate(2, template);

            GroupValue message = input.ReadMessage();

            Assert.AreEqual(aaaInsurance, message);

            message = input.ReadMessage();
            Assert.AreEqual(abcBuilding, message);
        }
コード例 #4
0
        public void TestComplexMessage()
        {
            var template = new MessageTemplate(
                "Company",
                new Field[]
                    {
                        new Scalar("Name", FastType.String, Operator.None, ScalarValue.Undefined, false),
                        new Scalar("Id", FastType.U32, Operator.Increment, ScalarValue.Undefined, false),
                        new Sequence(
                            "Employees",
                            new Field[]
                                {
                                    new Scalar("First Name", FastType.String, Operator.Copy, ScalarValue.Undefined,
                                               false),
                                    new Scalar("Last Name", FastType.String, Operator.Copy, ScalarValue.Undefined, false)
                                    ,
                                    new Scalar("Age", FastType.U32, Operator.Delta, ScalarValue.Undefined, false)
                                }, false),
                        new Group(
                            "Tax Information",
                            new Field[]
                                {
                                    new Scalar("EIN", FastType.String, Operator.None, ScalarValue.Undefined, false)
                                }, false)
                    });

            var aaaInsurance = new Message(template);
            aaaInsurance.SetFieldValue(1, new StringValue("AAA Insurance"));
            aaaInsurance.SetFieldValue(2, new IntegerValue(5));

            var employees = new SequenceValue(template.GetSequence(
                "Employees"));
            employees.Add(new IFieldValue[]
                              {
                                  new StringValue("John"), new StringValue("Doe"),
                                  new IntegerValue(45)
                              });
            employees.Add(new IFieldValue[]
                              {
                                  new StringValue("Jane"), new StringValue("Doe"),
                                  new IntegerValue(48)
                              });
            aaaInsurance.SetFieldValue(3, employees);
            aaaInsurance.SetFieldValue(4,
                                       new GroupValue(template.GetGroup("Tax Information"),
                                                      new IFieldValue[] {new StringValue("99-99999999")}));

            var outStream = new MemoryStream();
            var output = new MessageOutputStream(outStream);
            output.RegisterTemplate(1, template);
            output.WriteMessage(aaaInsurance);

            var abcBuilding = new Message(template);
            abcBuilding.SetFieldValue(1, new StringValue("ABC Building"));
            abcBuilding.SetFieldValue(2, new IntegerValue(6));
            employees = new SequenceValue(template.GetSequence("Employees"));
            employees.Add(new IFieldValue[]
                              {
                                  new StringValue("Bob"), new StringValue("Builder"),
                                  new IntegerValue(3)
                              });
            employees.Add(new IFieldValue[]
                              {
                                  new StringValue("Joe"), new StringValue("Rock"),
                                  new IntegerValue(59)
                              });
            abcBuilding.SetFieldValue(3, employees);
            abcBuilding.SetFieldValue(4,
                                      new GroupValue(template.GetGroup("Tax Information"),
                                                     new IFieldValue[] {new StringValue("99-99999999")}));
            output.WriteMessage(abcBuilding);

            var input = new MessageInputStream(new MemoryStream(outStream.ToArray()));
            input.RegisterTemplate(1, template);

            GroupValue message = input.ReadMessage();
            Assert.AreEqual(aaaInsurance, message);

            message = input.ReadMessage();
            Assert.AreEqual(abcBuilding, message);
        }
コード例 #5
0
        public void TestMultipleMessages()
        {
            var outStream = new MemoryStream();
            var output = new MessageOutputStream(outStream);
            output.RegisterTemplate(ObjectMother.AllocInstrctnTemplateId,
                                    ObjectMother.AllocationInstruction);

            var allocations = new SequenceValue(ObjectMother.AllocationInstruction
                                                    .GetSequence("Allocations"));
            allocations.Add(ObjectMother.NewAllocation("fortyFiveFund", 22.5, 75.0));
            allocations.Add(ObjectMother.NewAllocation("fortyFund", 24.6, 25.0));

            Message ai1 = ObjectMother.NewAllocInstrctn(
                "ltg0001", 1, 100.0, 23.4, ObjectMother.NewInstrument("CTYA", "200910"), allocations);

            allocations = new SequenceValue(
                ObjectMother.AllocationInstruction.GetSequence("Allocations"));

            allocations.Add(ObjectMother.NewAllocation("fortyFiveFund", 22.5, 75.0));
            allocations.Add(ObjectMother.NewAllocation("fortyFund", 24.6, 25.0));

            Message ai2 = ObjectMother.NewAllocInstrctn(
                "ltg0001", 1, 100.0, 23.4, ObjectMother.NewInstrument("CTYA", "200910"), allocations);

            allocations = new SequenceValue(
                ObjectMother.AllocationInstruction.GetSequence("Allocations"));
            allocations.Add(ObjectMother.NewAllocation("fortyFiveFund", 22.5, 75.0));
            allocations.Add(ObjectMother.NewAllocation("fortyFund", 24.6, 25.0));

            Message ai3 = ObjectMother.NewAllocInstrctn(
                "ltg0001", 1, 100.0, 23.4, ObjectMother.NewInstrument("CTYA", "200910"), allocations);

            output.WriteMessage(ai1);
            output.WriteMessage(ai2);
            output.WriteMessage(ai3);

            byte[] bytes = outStream.ToArray();
            var input = new MessageInputStream(new MemoryStream(bytes));
            input.RegisterTemplate(ObjectMother.AllocInstrctnTemplateId,
                                   ObjectMother.AllocationInstruction);

            Message message = input.ReadMessage();
            Assert.AreEqual(ai1, message);
            message = input.ReadMessage();
            Assert.AreEqual(ai2, message);
            Assert.AreEqual(ai3, input.ReadMessage());
        }