Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Xml;
- using System.Xml.Linq;
- using System.Xml.Serialization;
- namespace ConsoleApplication6
- {
- class Program
- {
- static void Main(string[] args)
- {
- XmlSerializer serializer = new XmlSerializer(typeof(NotepadPlus));
- NotepadPlus pawnDeserialized;
- StreamReader streamReader = new StreamReader("pawn.xml");
- using (XmlReader xmlReader = XmlReader.Create(streamReader))
- {
- pawnDeserialized = (NotepadPlus)serializer.Deserialize(xmlReader);
- }
- int i = 1;
- using (System.IO.StreamWriter file = new System.IO.StreamWriter("pawn.sublime-temp"))
- {
- foreach (var e in pawnDeserialized.Items)
- {
- foreach (var x in e.KeyWord)
- {
- if (x.func != null)
- {
- file.Write("{ \"trigger\": " + "\"" + x.name);
- if (x.Overload != null)
- {
- foreach (var c in x.Overload)
- {
- file.Write("\\t" + c.descr + "\", " + "\"contents\": \""+ x.name + "(");
- foreach (var p in c.Param)
- {
- int cn = c.Param.Count();
- if (p.name != "" && cn != 0)
- {
- file.Write("${" + i + ":" + p.name);
- file.Write(cn != i ? "}, " : "}");
- i++;
- }
- }
- }
- }
- i = 1;
- file.Write(")\" },\n");
- }
- }
- }
- }
- Console.WriteLine("Jobs done!");
- /* EXTRACT functions to function.txt
- var xdoc = XDocument.Load("pawn.xml");
- var keyWord = from e in xdoc.Descendants("KeyWord")
- select new
- {
- name = e.Attribute("name"),
- isFunc = e.Attribute("func"),
- };
- using (System.IO.StreamWriter file = new System.IO.StreamWriter("function.txt"))
- {
- foreach (var functions in keyWord)
- {
- if (functions.isFunc != null)
- {
- Console.WriteLine("Function name: " + functions.name.Value);
- file.Write(functions.name.Value + "|");
- }
- }
- }
- */
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement