示例#1
0
        static void Main(string[] args)
        {
            //Support UTF-8
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            //Parse event file
            var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt");

            var eventFile = parsed.GetResult();

            //"Process" result into nicer format
            var processed = CK2Process.processEventFile(eventFile);

            //Find interesting event
            var myEvent = processed.Events.FirstOrDefault(x => x.ID == "test.1");

            //Add is_triggered_only = true
            var leaf = new Leaf("is_triggered_only", Value.NewBool(true));

            myEvent.AllChildren.Add(Child.NewLeafC(leaf));
            // or
            // myEvent.AllChildren.Add(Leaf.Create("is_triggered_only", Value.NewBool(true)));

            //Output
            var output = processed.ToRaw;

            Console.WriteLine(CKPrinter.printKeyValueList(output, 0));
            PrintfModule
            .PrintFormatLine(
                new PrintfFormat <FSharpFunc <FSharpList <Statement>, Unit>, TextWriter, Unit, Unit, FSharpList <Statement> >("%A"))
            .Invoke(output);
        }
示例#2
0
        public static MyNode MapToMyNode()
        {
            //Support UTF-8
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            //Parse event file
            var parsed = CWTools.Parser.CKParser.parseEventFile("./testevent.txt");

            var eventFile = parsed.GetResult();

            //"Process" result into nicer format
            var processed = CK2Process.processEventFile(eventFile);

            return(ToMyNode(processed));
        }
示例#3
0
        /// <inheritdoc />
        public CWNode ParseParadoxFile(string filePath)
        {
            // raw parsing
            var parsed = CKParser.parseEventFile(filePath);

            if (parsed.IsSuccess)
            {
                // this is an extension method in CWTools.CSharp
                var eventFile = parsed.GetResult();

                //"Process" result into nicer format
                CK2Process.EventRoot processed = CK2Process.processEventFile(eventFile);

                // marshall this into a more c# fieldy type using the CWTools example
                CWNode marshaled = ToMyNode(processed);

                return(marshaled);
            }
            else
            {
                throw new Exception(parsed.GetError());
            }
        }