示例#1
0
        static void Main(string[] args)
        {
            Index library = new Index(1);
            Topic topic   = new Topic("jesus_christ", "Jesus Christ");

            Reference scriptureA = new Reference(Volume.BookOfMormon, Book.Alma, 32, new uint[] { 22, 21, 21 });
            Reference scriptureB = new Reference(Volume.BookOfMormon, Book.Alma, 32, new uint[] { 20, 23 });

            topic.references.Add(scriptureA);
            topic.references.Add(scriptureB);
            library.topics.Add(topic);

            Console.WriteLine(library.ToJson());
        }
示例#2
0
        static void Main(string[] args)
        {
            // Check arguments
            if (args.Length < 2)
            {
                throw new ArgumentException("Not enough arguments provided.");
            }

            if (!File.Exists(args[0]))
            {
                throw new FileNotFoundException("The given input file does not exist.");
            }

            // Read XML file
            StreamReader inputXml = new StreamReader(args[0]);

            XmlDocument doc = new XmlDocument();

            doc.Load(inputXml);
            Xml.Library library = new Xml.Library(doc.GetElementsByTagName("library")[0]);

            inputXml.Close();

            // Convert XML to JSON
            Json.Index index = Converter.LibraryToIndex(library);
            string     json  = index.ToJson();

            // Write JSON file
            StreamWriter outputJson = new StreamWriter(args[1], false);

            outputJson.Write(json);
            outputJson.Close();

            // Print human readable format
            Console.WriteLine(index.ToString());
        }