예제 #1
0
        public static List<Auto> HaeAutot()
        {
            AutoLista autot = new AutoLista();
            List<Auto> autoLista = new List<Auto>();

            Serialisointi.DeSerialisoiXml(HttpContext.Current.Server.MapPath("~/data/WanhatAutot.xml"), ref autot);

            for (int i = 0; i < autot.Autot.Count; i++)
            {
                autoLista.Add(autot.Autot[i]);
            }
            return autoLista;
        }
예제 #2
0
    public static List<Auto> getAutot()
    {
        AutoLista xmlista = new AutoLista();
        List<Auto> autoLista = new List<Auto>();

        Serialisointi.DeSerialisoiXml(HttpContext.Current.Server.MapPath("~/App_Data/WanhatAutot.xml"), ref xmlista);

        for(int i=0; i < xmlista.Autot.Count; i++)
        {
            autoLista.Add(xmlista.Autot[i]);
        }

        return autoLista;
    }
예제 #3
0
    public static List <Auto> getAutot()
    {
        AutoLista   xmlista   = new AutoLista();
        List <Auto> autoLista = new List <Auto>();

        Serialisointi.DeSerialisoiXml(HttpContext.Current.Server.MapPath("~/App_Data/WanhatAutot.xml"), ref xmlista);

        for (int i = 0; i < xmlista.Autot.Count; i++)
        {
            autoLista.Add(xmlista.Autot[i]);
        }

        return(autoLista);
    }
 // Serialisointi
 public static void SerialisoiXml(string tiedosto, AutoLista autot)
 {
     XmlSerializer xs = new XmlSerializer(autot.GetType());
     TextWriter tw = new StreamWriter(tiedosto);
     try
     {
         xs.Serialize(tw, autot);
     }
     catch (Exception e)
     {
         throw e;
     }
     finally
     {
         tw.Close();
     }
 }
예제 #5
0
    public static void SerialisoiXml(string tiedosto, AutoLista autot)
    {
        XmlSerializer xs = new XmlSerializer(autot.GetType());
        TextWriter    tw = new StreamWriter(tiedosto);

        try
        {
            xs.Serialize(tw, autot);
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            tw.Close();
        }
    }
예제 #6
0
    public static void DeSerialisoiXml(string filePath, ref AutoLista autot)
    {
        XmlSerializer deserializer = new XmlSerializer(typeof(AutoLista));

        try
        {
            FileStream xmlFile = new FileStream(filePath, FileMode.Open);
            autot = (AutoLista)deserializer.Deserialize(xmlFile);
            xmlFile.Close();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
        }
    }
    // Deserialisointi
    public static void DeSerialisoiXml(string filePath, ref AutoLista autot)
    {
        XmlSerializer deserializer = new XmlSerializer(typeof(AutoLista));
        try
        {
            FileStream xmlFile = new FileStream(filePath, FileMode.Open);
            autot = (AutoLista)deserializer.Deserialize(xmlFile);
            xmlFile.Close();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {

        }
    }
예제 #8
0
        protected void initMyStuff()
        {
            try
            {
                AutoLista autot = new AutoLista();
                Serialisointi.DeSerialisoiXml(Server.MapPath("~/data/WanhatAutot.xml"), ref autot);
                Random rnd = new Random();
                List<Auto> ekatNelja = new List<Auto>();

                while (ekatNelja.Count < 4)
                {
                    int luku = rnd.Next(0, autot.Autot.Count - 1);
                    if (!ekatNelja.Contains(autot.Autot.ElementAt(luku)))
                    {
                        ekatNelja.Add(autot.Autot.ElementAt(luku));
                    }

                }
                Autot = autot.Autot;
                ViewState["AutotLista"] = Autot;
                List<string> merkit = new List<string>();
                merkit.Add("Kaikki");
                foreach (Auto auto in autot.Autot)
                {
                    string merkki = auto.Merkki;
                    if (!merkit.Contains(merkki))
                    {
                        merkit.Add(merkki);
                    }
                }

                    ListBox1.DataSource = merkit;

                    ListBox1.DataBind();
                    ListBox1.Height = 150;
                    SortExpression = "DESC";
                    loadListWiew(ekatNelja);

            }
            catch (Exception ex)
            {
                er.InnerText = ex.Message;
            }
        }
예제 #9
0
    private void initMyStuff()
    {
        try
        {
            AutoLista autot = new AutoLista();
            Serialisointi.DeSerialisoiXml(Server.MapPath("~/App_Data/WanhatAutot.xml"), ref autot);
            Random      random = new Random();
            List <Auto> nelja  = new List <Auto>();

            while (nelja.Count < 4)
            {
                int luku = random.Next(0, autot.Autot.Count - 1);
                if (!nelja.Contains(autot.Autot.ElementAt(luku)))
                {
                    nelja.Add(autot.Autot.ElementAt(luku));
                }
            }
            Autot = autot.Autot;
            ViewState["AutotLista"] = Autot;
            List <string> merkit = new List <string>();
            merkit.Add("Kaikki");

            foreach (Auto auto in autot.Autot)
            {
                string merkki = auto.Merkki;

                if (!merkit.Contains(merkki))
                {
                    merkit.Add(merkki);
                }
            }

            ListBox1.DataSource = merkit;
            ListBox1.DataBind();
            ListBox1.Height = 150;
            SortExpression  = "DESC";
            loadListWiew(nelja);
        }
        catch (Exception ex)
        {
            er.InnerText = ex.Message;
        }
    }
예제 #10
0
    public static void VieAutot(List<Auto> autoLista)
    {
        AutoLista autot = new AutoLista();
        foreach (Auto item in autoLista)
        {
            autot.Autot.Add(item);
        }

        Serialisointi.SerialisoiXml(HttpContext.Current.Server.MapPath("~/App_Data/WanhatAutot.xml"), autot);
    }
예제 #11
0
 public static void TallennaAutot(AutoLista autot)
 {
     Serialisointi.SerialisoiXml(HttpContext.Current.Server.MapPath("~/App_Data/WanhatAutot.xml"), autot);
 }
예제 #12
0
 public static void TallennaAutot(AutoLista autot)
 {
     Serialisointi.SerialisoiXml(HttpContext.Current.Server.MapPath("~/App_Data/WanhatAutot.xml"), autot);
 }