In This Topic
using System;
using LiquidTechnologies.Runtime;
namespace LiquidTechnologies.Test
{
class SampleApp
{
[STAThread]
static void Main(string[] args)
{
if (System.IO.File.Exists(@"BookStoreSample.xml"))
TestRead(@"BookStoreSample.xml");
else
TestRead(@"..\..\..\..\..\BookStoreSample.xml");
TestWrite();
}
public static void TestWrite()
{
BookStoreLib.Bookstore bs = new BookStoreLib.Bookstore();
BookStoreLib.BookType book = new BookStoreLib.BookType();
bs.Book.Add(book);
book.Title = "The Autobiography of Benjamin Franklin";
book.Price = 8.99;
book.Publicationdate = new LiquidTechnologies.Runtime.XmlDateTime(1981, 5, 11);
book.ISBN = "1-861003-11-0";
book.Author.First_name = "Benjamin";
book.Author.Last_name = "Franklin";
book.Genre = "autobiography";
string strXml = book.ToXml();
System.Console.WriteLine(strXml);
Test.SimpleViewer viewer = new Test.SimpleViewer(bs);
viewer.ShowDialog();
}
public static void TestRead(string filename)
{
BookStoreLib.Bookstore bs = new BookStoreLib.Bookstore();
bs.FromXmlFile(filename);
foreach (BookStoreLib.BookType book in bs.Book)
{
System.Console.WriteLine("Book Title {0}", book.Title);
System.Console.WriteLine(" Price {0}", book.Price);
System.Console.WriteLine(" Author {0} {1}", book.Author.First_name, book.Author.Last_name);
if (book.IsValidPublicationdate)
System.Console.WriteLine(" Publicationdate {0}", book.Publicationdate.ToString());
else
System.Console.WriteLine(" Publicationdate Not Listed");
if (book.IsValidISBN)
System.Console.WriteLine(" ISBN {0}", book.ISBN);
else
System.Console.WriteLine(" ISBN Not Listed");
if (book.IsValidGenre)
System.Console.WriteLine(" Genre {0}", book.Genre);
else
System.Console.WriteLine(" Genre Not Listed");
}
}
}
}