Exemplo n.º 1
0
        // GET: Demo
        public ActionResult Index()
        {
            person person = new person();

            person.name = " my first data structure project";

            person.phoneNumbr = 088682;

            irepo <person> p = new generic <person>();

            p.addAddperson(person);

            string myReturn = p.DidpersonAdd();



            return(View(p));
        }
Exemplo n.º 2
0
    static void Main(string [] args)
    {
        String[] array = { "Ade", "George", "Bale", "Santi", "Chris" };
        Console.WriteLine("Array before sorting: ");
        foreach (var item in array)
        {
            Console.WriteLine(item.ToString());
        }

        Console.WriteLine("\n\n");
        generic <string> intGeneric = new generic <string>(array);

        intGeneric.arrayInsertionSort(array);
        Console.WriteLine("Array after sorting: ");
        foreach (var item in array)
        {
            Console.WriteLine(item.ToString());
        }
        Console.ReadLine();
    }
Exemplo n.º 3
0
        public void Parsing(string FileName)
        {
            char[]        razd = { ' ', ';', ',', '(', ')', '-', '+', '=', ':', '\t', '\n', '\r' };
            FileStream    fs   = new FileStream(FileName, FileMode.Open);
            StreamReader  sr   = new StreamReader(fs);
            string        str;
            string        str2;
            string        var_type = "";
            string        bus_size = "";
            string        bus_var  = "";
            vhdEntity     ent;
            vhdPort       port;
            generic       gener;
            string        type = "";
            portInOut     inout;
            bool          bus        = false;
            int           gen_num    = 0;
            int           leftBound  = 0;
            int           rightBound = 0;
            List <string> names      = new List <string>();

            while (!(sr.EndOfStream))
            {
                str = nextWord(fs, sr, razd);
                if (str.CompareTo("entity") == 0)
                {
                    ent      = new vhdEntity();
                    gener    = new generic();
                    ent.name = nextWord(fs, sr, razd);


                    if (nextWord(fs, sr, razd).CompareTo("is") == 0)
                    {
                        str = nextWord(fs, sr, razd);
                        while (str.CompareTo("generic") == 0)
                        {
                            bus_var  = nextWord(fs, sr, razd);
                            var_type = nextWord(fs, sr, razd);
                            var_type = var_type.ToLower();
                            bus_size = nextWord(fs, sr, razd);
                            //str = nextWord(fs,sr,razd);
                            if (var_type == "real" || var_type == "natural" || var_type == "integer")
                            {
                                gen_num           = gen_num + 1;
                                gener.number      = gen_num;
                                gener.var_name    = bus_var;
                                gener.type_of_var = var_type;
                                gener.var_value   = StrToInt(bus_size);
                                ent.gen_cont.Add(new generic(gener));
                            }
                            str = nextWord(fs, sr, razd);
                        }
                        str  = nextWord(fs, sr, razd);
                        str2 = nextWord(fs, sr, razd);
                        while (str.CompareTo("end") != 0)
                        {
                            names.Clear();
                            names.Add(str);
                            while (!(str2.CompareTo("in") == 0 ||
                                     str2.CompareTo("out") == 0 ||
                                     str2.CompareTo("inout") == 0 ||
                                     str2.CompareTo("buffer") == 0))
                            {
                                names.Add(str2);
                                str2 = nextWord(fs, sr, razd);
                            }
                            if (str2.CompareTo("in") == 0)
                            {
                                inout = portInOut.In;
                            }
                            else
                            if (str2.CompareTo("out") == 0)
                            {
                                inout = portInOut.Out;
                            }
                            else
                            {
                                inout = portInOut.InOut;
                            }
                            type       = nextWord(fs, sr, razd);
                            bus        = false;
                            leftBound  = 0;
                            rightBound = 0;
                            str        = nextWord(fs, sr, razd);
                            if (str != "end")
                            {
                                str2 = nextWord(fs, sr, razd);
                            }
                            while (str2.CompareTo("to") == 0 || str2.CompareTo("downto") == 0)
                            {
                                str2 = nextWord(fs, sr, razd);

                                foreach (generic gen in ent.gen_cont)
                                {
                                    //if (str == gen.var_name || str2 == gen.var_name)
                                    //{
                                    if (str == gen.var_name)
                                    {
                                        leftBound  = gen.var_value;
                                        rightBound = StrToInt(str2);
                                    }

                                    /*else
                                     * leftBound = gen.var_value;
                                     * rightBound = StrToInt(str2);*/

                                    if (str2 == gen.var_name)
                                    {
                                        leftBound  = StrToInt(str);
                                        rightBound = gen.var_value;
                                    }

                                    //}
                                }

                                bus = true;
                                //leftBound = StrToInt(str);
                                //rightBound = StrToInt(str2);
                                str  = nextWord(fs, sr, razd);
                                str2 = nextWord(fs, sr, razd);
                            }
                            int i;
                            for (i = 0; i < names.Count; i++)
                            {
                                port            = new vhdPort();
                                port.name       = names[i];
                                port.inout      = inout;
                                port.type       = type;
                                port.bus        = bus;
                                port.leftBound  = leftBound;
                                port.rightBound = rightBound;
                                ent.ports.Add(port);
                            }
                        }

                        entities.Add(ent);
                    }
                }
            }
            sr.Close();
        }