コード例 #1
0
        //???????????????
        public static void TestProductHierarchy2()
        {
            ProductController pc = new ProductController(WS_USERNAME, WS_PASSWORD);

            VinProduct.Product product = new VinProduct.Product();
            product = pc.PS_GetProductDetailsBySKU("746969b");  //"746969c"

            List <bool> myIsArray = new List <bool>();

            myIsArray = loop(product);
            foreach (bool propIsArray in myIsArray)
            {
                if (!propIsArray)
                {
                    loop(product);
                }
                else if (propIsArray)
                {
                    loop(propIsArray);      //recursive
                }
                else
                {
                    Console.WriteLine("...something went wrong...");
                }
            }
        }
コード例 #2
0
        public static void TestDumpAllProductDetailsLong()
        {
            ProductController pc = new ProductController(WS_USERNAME, WS_PASSWORD);

            VinProduct.Product product = new VinProduct.Product();
            product = pc.PS_GetProductDetailsBySKU("746969b");  //"746969c"

            //print long description
            Console.WriteLine(pc.PS_DisplayProductDetailsLong(product));
        }
コード例 #3
0
        public static void TestGetProductDetails1()
        {
            ProductController pc = new ProductController(WS_USERNAME, WS_PASSWORD);

            //----
            //ERROR
            //"There is an error in XML document (99, 15)." (THIS FIXED BY PATHING TO
            VinProduct.Product product = new VinProduct.Product();
            product = pc.PS_GetProductDetailsBySKU("746969c");
            //Console.WriteLine(product.Title);
            //----

            //OBJECT PROPERTY DUMP
            Console.WriteLine("------");
            Console.WriteLine("PRODUCT");
            Utility.Utility.DumpProperties(product);
            Console.WriteLine("------");
            //foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(product))
            //{
            //    string name = descriptor.Name;
            //    object value = descriptor.GetValue(product);
            //    Console.WriteLine("{0}={1}", name, value);
            //}
        }
コード例 #4
0
        public static void TestProductHierarchy()
        {
            ProductController pc = new ProductController(WS_USERNAME, WS_PASSWORD);

            VinProduct.Product product = new VinProduct.Product();
            product = pc.PS_GetProductDetailsBySKU("746969b");  //"746969c"

            //get all elements
            Type productType = product.GetType();
            IList <PropertyInfo> productProperties = new List <PropertyInfo>(productType.GetProperties());

            foreach (PropertyInfo prop in productProperties)
            {
                //get property name
                object propName = prop.Name;
                //get property value
                object propValue = prop.GetValue(product, null);
                //get type of object (so I know if it is an array, or other)
                bool IsPropertyAnArray = prop.PropertyType.IsArray;

                if (!IsPropertyAnArray)
                {
                    Console.WriteLine("{0}: {1}", propName, propValue);
                }
                else if (IsPropertyAnArray)
                {
                    //go into array and print same...
                    Console.WriteLine("{0}: {1}", propName, propValue);
                }
                else
                {
                    Console.WriteLine("...there is a problem here...");
                }
            }

            //System.Reflection.PropertyInfo[] myarray = productType.GetProperties();
            //var x = myarray.GetValue(0);

            //foreach(PropertyInfo elem in myarray)
            //{
            //    //find key and value

            //    elem.GetValue(myarray);
            //    //elem.CanRead
            //    //elem.GetValue
            //}

            //Type myType = myObject.GetType();
            //IList<PropertyInfo> props = new List<PropertyInfo>(myType.GetProperties());

            //foreach (PropertyInfo prop in props)
            //{
            //    object propValue = prop.GetValue(myObject, null);

            //    // Do something with propValue
            //}

            //for each element in PRODUCT get type
            // if an array
            //how long is array
            //show all elements
            // if not array (what is it?) single element
            //show one element (key and value)
            // if it's something else how to handle this...
        }