Пример #1
0
        static void ReflectiveWay()
        {
            //Construct my own custom object
            Tavern tavern = new Tavern();

            tavern.Business    = "Tractor Tavern";
            tavern.Address     = "5213 Ballard Ave NW";
            tavern.City        = "Seattle";
            tavern.State       = "WA";
            tavern.Zipcode     = 98107;
            tavern.Latitude    = 47.665663;
            tavern.Longitude   = -122.382343;
            tavern.CoverCharge = true;
            tavern.Url         = "http://tractortavern.citysearch.com/";
            tavern.AddPaymentMethod(PaymentMethod.Cash);
            tavern.AddPaymentMethod(PaymentMethod.Visa);
            tavern.AddPaymentMethod(PaymentMethod.Mastercard);
            tavern.AddPaymentMethod(PaymentMethod.AmericanExpress);

            //Pass it to our static reflector, which will build
            JSONReflector jsonReflector = new JSONReflector(tavern);

            // The ToString() is the compact representation of the object's JSON output
            Console.WriteLine("JSONReflector.ToString()");
            Console.WriteLine("===============================");
            Console.WriteLine(jsonReflector.ToString());
            Console.WriteLine("===============================");
            Console.WriteLine();
            // PrettyPrint() is great for readability
            Console.WriteLine("JSONReflector.PrettyPrint()");
            Console.WriteLine("===============================");
            Console.WriteLine(jsonReflector.PrettyPrint());
            Console.WriteLine("===============================");
        }
Пример #2
0
        static void ReflectiveWay()
        {
            //Construct my own custom object
            Tavern tavern = new Tavern();
            tavern.Business = "Tractor Tavern";
            tavern.Address = "5213 Ballard Ave NW";
            tavern.City = "Seattle";
            tavern.State = "WA";
            tavern.Zipcode = 98107;
            tavern.Latitude = 47.665663;
            tavern.Longitude = -122.382343;
            tavern.CoverCharge = true;
            tavern.Url = "http://tractortavern.citysearch.com/";
            tavern.AddPaymentMethod(PaymentMethod.Cash);
            tavern.AddPaymentMethod(PaymentMethod.Visa);
            tavern.AddPaymentMethod(PaymentMethod.Mastercard);
            tavern.AddPaymentMethod(PaymentMethod.AmericanExpress);

            //Pass it to our static reflector, which will build
            JSONReflector jsonReflector = new JSONReflector(tavern);

            // The ToString() is the compact representation of the object's JSON output
            Console.WriteLine("JSONReflector.ToString()");
            Console.WriteLine("===============================");
            Console.WriteLine(jsonReflector.ToString());
            Console.WriteLine("===============================");
            Console.WriteLine();
            // PrettyPrint() is great for readability
            Console.WriteLine("JSONReflector.PrettyPrint()");
            Console.WriteLine("===============================");
            Console.WriteLine(jsonReflector.PrettyPrint());
            Console.WriteLine("===============================");
        }