Ejemplo n.º 1
0
        protected override void WriteChildren(SwiftWriter writer)
        {
            var firstTime           = true;
            var previousValueHadDoc = false;

            foreach (var value in _values)
            {
                var hasDoc = !String.IsNullOrWhiteSpace(value.BriefComment);

                if (!firstTime)
                {
                    if (hasDoc)
                    {
                        writer.WriteLine("\t");
                    }
                    else if (previousValueHadDoc)
                    {
                        writer.WriteLine("\t");
                    }
                }

                value.WriteDeclaration(writer);

                firstTime           = false;
                previousValueHadDoc = hasDoc;
            }
        }
Ejemplo n.º 2
0
        public override void Write(SwiftWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            WriteDeclaration(writer, false);
        }
Ejemplo n.º 3
0
        public override void Write(SwiftWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            writer.Write(this.Name);
        }
Ejemplo n.º 4
0
        public override void Write(SwiftWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            this.InnerType.Write(writer);
            writer.Write(_implicitlyUnwrapped ? "!" : "?");
        }
Ejemplo n.º 5
0
        public void WriteDeclaration(SwiftWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            SwiftComposite.WriteComment(1, writer, this.BriefComment);
            writer.WriteLine("\tcase {0} = {1}", _name, _value);
        }
Ejemplo n.º 6
0
        public override void Write(SwiftWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            writer.Write(writer.IsEmittingSwift_12 ? "Set<" : "[");
            _elementType.Write(writer);
            writer.Write(writer.IsEmittingSwift_12 ? ">" : "]");
        }
Ejemplo n.º 7
0
        public override void Write(SwiftWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            writer.Write("[");
            _elementType.Write(writer);
            writer.Write("]");
        }
Ejemplo n.º 8
0
        public void WriteDeclaration(SwiftWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            SwiftComposite.WriteComment(1, writer, this.BriefComment);
            writer.Write("\t{0} {1}: ", _isConstant ? "let" : "var", this.Name);
            this.Type.Write(writer);
            writer.WriteLine();
        }
Ejemplo n.º 9
0
        protected override void WriteChildren(SwiftWriter writer)
        {
            var firstTime = true;

            foreach (var property in _orderedProperties)
            {
                if (!firstTime)
                {
                    writer.WriteLine("\t");
                }

                property.WriteDeclaration(writer);

                firstTime = false;
            }
        }
Ejemplo n.º 10
0
        internal static bool WriteComment(int indent, SwiftWriter writer, string comment)
        {
            bool wroteComment = false;

            if (!String.IsNullOrWhiteSpace(comment))
            {
                var lines = comment.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.None);

                foreach (var line in lines)
                {
                    writer.WriteLine("{0}/// {1}", new string('\t', indent), line.Trim());
                    wroteComment = true;
                }
            }

            return(wroteComment);
        }
Ejemplo n.º 11
0
        protected void WriteDeclaration(SwiftWriter writer, bool forDefinition)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            writer.Write(this.Name);

            if (this.TypeParameterNames.Any())
            {
                var separator = "";

                writer.Write("<");

                foreach (var name in this.TypeParameterNames)
                {
                    writer.Write(separator);

                    var parameter = GetTypeParameter(name);

                    parameter.Write(writer);

                    if (forDefinition)
                    {
                        var constraint = GetTypeParameterConstraint(name);

                        if (constraint != null)
                        {
                            writer.Write(": ");
                            constraint.Write(writer);
                        }
                    }

                    separator = ", ";
                }

                writer.Write(">");
            }
        }
Ejemplo n.º 12
0
        public void WriteDefinition(SwiftWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            WriteComment(0, writer, this.BriefComment);
            WriteKeyword(writer);
            writer.Write(" ");
            WriteDeclaration(writer, true);

            if (this.BaseType != null)
            {
                writer.Write(": ");
                this.BaseType.Write(writer);
            }

            writer.WriteLine(" {");
            WriteChildren(writer);
            writer.WriteLine("}");
        }
Ejemplo n.º 13
0
        public void TestInitialize()
        {
            var configuration = new Poco2SwiftType
            {
                imports       = new ModuleType[0],
                skiptypes     = new SkipType[0],
                externaltypes = new ExternalType[0],
                enumerations  = new EnumType[0],
                classes       = new ClassType[0],
            };
            var filter        = new NullTypeFilter();
            var documentation = new DocumentationCache();
            var callback      = new NullProxyCallback();

            _proxyUtils = new NullProxyUtils {
                Callback = callback
            };
            _appDomain = new NullAppDomain {
                Utils = _proxyUtils
            };
            _translator = new SwiftTranslator(configuration, filter, documentation, _appDomain);
            _writer     = new NullWriter(configuration);
        }
Ejemplo n.º 14
0
 protected abstract void WriteKeyword(SwiftWriter writer);
Ejemplo n.º 15
0
 protected override void WriteKeyword(SwiftWriter writer)
 {
     writer.Write("enum");
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Emit the type's declaration, as used in property definitions.
 /// </summary>
 /// <param name="writer"></param>
 public abstract void Write(SwiftWriter writer);
Ejemplo n.º 17
0
 protected abstract void WriteChildren(SwiftWriter writer);
Ejemplo n.º 18
0
        public void GetFinMessage_SwiftMessageObject_ReturnFinMessage()
        {
            string finMessage = "";

            using (StreamReader stream = new StreamReader(@"..\..\..\SwiftFiles\GetFinMessage_SwiftMessageObject_ReturnFinMessage"))
            {
                finMessage = stream.ReadToEnd();
            }
            SwiftMessage swiftMessage = new SwiftMessage()
            {
                Block1 = new SwiftBlock1()
                {
                    ApplicationId          = "F",
                    ServiceId              = "01",
                    LogicalTerminalAddress = "TESTBIC12XXX",
                    SessionNumber          = "0360",
                    SequenceNumber         = "105154",
                },
                Block2 = new SwiftBlock2Output()
                {
                    Direction             = Direction.Output,
                    MessageType           = "564",
                    InputTime             = "1057",
                    MessageInputReference = new MessageInputReference()
                    {
                        InputDate = "130214",
                        LogicalTerminalAddress = "TESTBIC34XXX",
                        SessionNumber          = "2626",
                        SequenceNumber         = "493828"
                    },
                    ReceiverOutputDate = "130214",
                    ReceiverOutputTime = "1757",
                    MessagePriority    = "N"
                },
                Block3 = new SwiftBlock3()
                {
                    new SwiftTag("103", "CAD"),
                    new SwiftTag("108", "2RDRQDHM3WO"),
                },
                Block4 = new SwiftBlock4()
                {
                    new SwiftTag("16R", "GENL"),
                    new SwiftTag("20C", ":CORP//1234567890123456"),
                    new SwiftTag("20C", ":SEME//9876543210987654"),
                    new SwiftTag("23G", "NEWM"),
                    new SwiftTag("22F", ":CAEV//INTR"),
                    new SwiftTag("22F", ":CAMV//MAND"),
                    new SwiftTag("98C", ":PREP//20220202105733"),
                    new SwiftTag("25D", ":PROC//ENTL"),
                    new SwiftTag("16S", "GENL"),
                    new SwiftTag("16R", "USECU"),
                    new SwiftTag("35B", "ISIN CH0101010101\r\n/XS/232323232\r\nFINANCIAL INSTRUMENT ACME"),
                    new SwiftTag("16R", "FIA"),
                    new SwiftTag("22F", ":MICO//A007"),
                    new SwiftTag("16S", "FIA"),
                    new SwiftTag("16R", "ACCTINFO"),
                    new SwiftTag("97A", ":SAFE//99999"),
                    new SwiftTag("94F", ":SAFE//NCSD/TESTBIC0ABC"),
                    new SwiftTag("93B", ":ELIG//FAMT/500000,"),
                    new SwiftTag("93B", ":SETT//FAMT/500000,"),
                    new SwiftTag("16S", "ACCTINFO"),
                    new SwiftTag("16S", "USECU"),
                    new SwiftTag("16R", "CADETL"),
                    new SwiftTag("98A", ":ANOU//20220113"),
                    new SwiftTag("98A", ":RDTE//20220113"),
                    new SwiftTag("69A", ":INPE//20220214/20220214"),
                    new SwiftTag("99A", ":DAAC//360"),
                    new SwiftTag("92K", ":INTR//UKWN"),
                    new SwiftTag("22F", ":ADDB//CAPA"),
                    new SwiftTag("16S", "CADETL"),
                    new SwiftTag("16R", "CAOPTN"),
                    new SwiftTag("13A", ":CAON//001"),
                    new SwiftTag("22F", ":CAOP//CASH"),
                    new SwiftTag("11A", ":OPTN//USD"),
                    new SwiftTag("17B", ":DFLT//Y"),
                    new SwiftTag("16R", "CASHMOVE"),
                    new SwiftTag("22H", ":CRDB//CRED"),
                    new SwiftTag("22H", ":CONT//ACTU"),
                    new SwiftTag("97A", ":CASH//89898"),
                    new SwiftTag("19B", ":ENTL//USD3333,"),
                    new SwiftTag("19B", ":TXFR//USD3333,"),
                    new SwiftTag("19B", ":NETT//USD3333,"),
                    new SwiftTag("98A", ":PAYD//20220214"),
                    new SwiftTag("98A", ":VALU//20220214"),
                    new SwiftTag("98A", ":EARL//20220214"),
                    new SwiftTag("92A", ":INTP//0,75"),
                    new SwiftTag("92A", ":TAXR//0,"),
                    new SwiftTag("16S", "CASHMOVE"),
                    new SwiftTag("16S", "CAOPTN"),
                    new SwiftTag("16R", "ADDINFO"),
                    new SwiftTag("70E", ":ADTX//PAYMENT UPON RECEIPT OF FUNDS - \r\nTIMELY PAYMENT EXPECTED"),
                    new SwiftTag("16S", "ADDINFO"),
                },
                Block5 = new SwiftBlock5()
                {
                    new SwiftTag("CHK", "C77F8E009597")
                }
            };
            SwiftWriter writer = new SwiftWriter();
            var         result = writer.GetFinMessage(swiftMessage);

            Assert.AreEqual(result, finMessage);
        }