Ejemplo n.º 1
0
        /// <summary>
        /// Writes the order list to a file.
        /// </summary>
        /// <param name="path">The file.</param>
        /// <param name="list">The order list.</param>
        public static void WriteOrders(string path, OrderList list)
        {
            // Implicitly convert the instance to a DTO and serialize it
            DTOOrderList dtoList = list;

            using (TextWriter writer = new StreamWriter(path))
                _listSerializer.Serialize(writer, dtoList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads an order list from a file.
        /// </summary>
        /// <param name="orderFile">The file.</param>
        /// <param name="instance">The instance to submit to.</param>
        /// <returns>The order list.</returns>
        public static OrderList ReadOrders(string orderFile, Instance instance)
        {
            // Read the list
            OrderList list = null;

            using (StreamReader sr = new StreamReader(orderFile))
            {
                // Deserialize the xml-file
                DTOOrderList dtoConfig = (DTOOrderList)_listSerializer.Deserialize(sr);
                // Submit list to the instance object
                list = dtoConfig.Submit(instance);
            }
            return(list);
        }