コード例 #1
0
        public void InsertAt(int index, ResearchTeam team)
        {
            if (index <= 0 || index > _list.Count())
            {
                _list.Add(team);
            }
            else
            {
                _list.Add(team);
                for (int i = 1; i < _list.Count() - 1 - index; ++i)
                {
                    _list[_list.Count() - i] = _list[_list.Count() - 1 - i];
                }
                _list[index] = team;
                TeamListHandlerEventArgs argss = new TeamListHandlerEventArgs();
                argss.Name  = "Inserted";
                argss.Info  = "ResearchTeam inserted";
                argss.Index = index;
                if (ResearchTeamInserted != null)
                {
                    ResearchTeamInserted(this, argss);
                }
            }

            TeamListHandlerEventArgs args = new TeamListHandlerEventArgs();

            args.Name  = "Inserted";
            args.Info  = "ResearchTeam added";
            args.Index = index;
            if (ResearchTeamAdded != null)
            {
                ResearchTeamAdded(this, args);
            }
        }
コード例 #2
0
 public void AddDefaults(int n)
 {
     for (int i = 0; i < n; i++)
     {
         ResearchTeam tTeam = new ResearchTeam("A" + i, "C" + i, i, "T" + i, TimeFrame.Long);
         AddResearchTeams(tTeam);
     }
 }
コード例 #3
0
 public TestCollections(int elementsCount)
 {
     foreach (var num in Enumerable.Range(1, elementsCount).RandomShuffle())
     {
         ResearchTeam newObject = GenElement(num);
         teamList.Add(newObject.Team);
         strList.Add(newObject.Name);
         resTeamDict.Add(newObject.Team, newObject);
         resTeamDict2.Add(newObject.Name, newObject);
     }
 }
コード例 #4
0
        public static ResearchTeam GenElement(int num)
        {
            var result = new ResearchTeam("ResName" + num, "CompName" + num, num, "TeamName" + num, TimeFrame.Long);

            int artNum = new Random(Seed: DateTime.Now.Millisecond).Next(10);

            for (int i = 0; i < artNum; i++)
            {
                result.AddPapers(new Paper("ArtName" + num, new Person("Author" + num, "Surname" + num, new DateTime(2000, 1, 1)), new DateTime(2020, 10, 10)));
            }

            return(result);
        }
コード例 #5
0
        public bool Remove(ResearchTeam rt)
        {
            if (!resTeamDict.Values.Contains(rt))
            {
                return(false);
            }

            foreach (var pair in resTeamDict)
            {
                if (pair.Value == rt)
                {
                    pair.Value.PropertyChanged -= ControlPropertyChanging;
                    resTeamDict.Remove(pair.Key);
                    ResearchTeamsChanged.Invoke(this, new ResearchTeamsChangedEventArgs <Tkey>(CollectionName, Revision.Remove, "", rt.LicenceNumber));
                    break;
                }
            }

            return(true);
        }
コード例 #6
0
        public bool Replace(ResearchTeam rold, ResearchTeam rnew)
        {
            if (!resTeamDict.Values.Contains(rold))
            {
                return(false);
            }

            Tkey tempKey = default(Tkey);

            foreach (var pair in resTeamDict)
            {
                if (pair.Value == rold)
                {
                    pair.Value.PropertyChanged -= ControlPropertyChanging;
                    tempKey = pair.Key;
                    rnew.PropertyChanged += ControlPropertyChanging;
                }
            }

            resTeamDict[tempKey] = rnew;
            ResearchTeamsChanged.Invoke(this, new ResearchTeamsChangedEventArgs <Tkey>(CollectionName, Revision.Replace, "", rold.LicenceNumber));

            return(true);
        }
コード例 #7
0
        public static void Main(string[] args)
        {
            ResearchTeam stud1 = new ResearchTeam();
            Person       stud  = new Person("Andre", "Jitarju", new DateTime(1997, 5, 21));

            Paper Ex1 = new Paper("Matan", stud, new DateTime(2017, 12, 11));
            Paper Ex2 = new Paper("Programing", stud, new DateTime(2017, 12, 24));

            stud1.Publications.Add(Ex1);
            stud1.Publications.Add(Ex2);


            ResearchTeam StudCopy = (Lab5.ResearchTeam)stud1.DeepCopy();

            //1
            Console.WriteLine("---------------->1");
            Console.WriteLine("------------------------------------->Original");
            Console.WriteLine(stud1.ToString());
            Console.WriteLine("------------------------------------->Copy");
            Console.WriteLine(StudCopy.ToString());

            Console.WriteLine("file:");
            string filename = Console.ReadLine() + ".dat";

            //2
            try
            {
                FileStream fileOpen = new FileStream(filename, FileMode.Open, FileAccess.Write, FileShare.Write);
                fileOpen.Close();
                Console.WriteLine(stud1.Load(filename));
            }
            catch
            {
                Console.WriteLine("No File");
                FileStream file = new FileStream(filename, FileMode.Create);
                file.Close();
            }

            //3
            Console.WriteLine("---------------->3");
            Console.WriteLine(stud1.ToString());

            //4
            Console.WriteLine("---------------->4");
            Console.WriteLine(stud1.AddFromConsole());
            Console.WriteLine(stud1.Save(filename));
            Console.WriteLine(stud1.ToString());

            //5
            ResearchTeam test = new ResearchTeam();

            Console.WriteLine("---------------->5");
            Console.WriteLine(ResearchTeam.Load(filename, stud1));
            Console.WriteLine(stud1.AddFromConsole());
            Console.WriteLine(ResearchTeam.Save(filename, stud1));

            //6
            Console.WriteLine("---------------->6");
            Console.WriteLine(stud1.ToString());

            Console.ReadLine();
        }
コード例 #8
0
        public static void Main()
        {
            int lineLen = 60;

            ResearchTeam tTeam = new ResearchTeam("First", "OAO", 1, "TSquad1", TimeFrame.Long);

            for (int i = 0; i < 3; i++)
            {
                tTeam.ArticleList.Add(new Paper(
                                          "Article №" + i,
                                          new Person("Author №" + i, "Surname №" + i, new DateTime(2000, 10, (i % 25) + 1)),
                                          new DateTime(2020, 11, (i % 25) + 1)));
            }

            PrintLine(lineLen);
            //1
            ResearchTeam tTeamCopy = tTeam.DeepCopy() as ResearchTeam;

            Console.WriteLine("Основной объект:");
            Console.WriteLine(tTeam);

            Console.WriteLine("Копия: ");
            Console.WriteLine(tTeamCopy);

            PrintLine(lineLen);
            //2
            Console.Write("Введите имя файла для сохранения файла: ");
            string filePath = Console.ReadLine();

            Console.WriteLine();

            ResearchTeam tTeam2 = new ResearchTeam();

            if (File.Exists(filePath))
            {
                Console.WriteLine("Попытка загрузить объект из файла...");
                if (tTeam2.Load(filePath))
                {
                    Console.WriteLine("Успех!");
                }
                else
                {
                    Console.WriteLine("Ошибка загрузки файла, состояние установлено по умолчанию");
                }
            }
            else
            {
                Console.WriteLine("Файла с таким именем не обнаружено, состояние установлено по умолчанию");
            }
            Console.WriteLine("Данный файл будет использован для хранения данных");

            PrintLine(lineLen);
            //3
            Console.WriteLine(tTeam2);

            PrintLine(lineLen);
            //4
            do
            {
                Console.WriteLine("\n\nДобавление статьи: \n");
            } while (!tTeam2.AddFromConsole());

            tTeam2.Save(filePath);

            PrintLine(lineLen);
            Console.WriteLine("Вывод объекта после добавления статьи: \n");
            Console.WriteLine(tTeam2);

            PrintLine(lineLen);
            //5
            if (ResearchTeam.Load(filePath, ref tTeam2))
            {
                Console.WriteLine("\n\nЧтениe объекта из файла успешно\n");
            }
            Console.WriteLine(tTeam2);

            PrintLine(lineLen);
            do
            {
                Console.WriteLine("\n\nДобавление статьи: \n");
            } while (!tTeam2.AddFromConsole());
            ResearchTeam.Save(filePath, tTeam2);
            Console.WriteLine(tTeam2);
        }
コード例 #9
0
        public int GetTiming()
        {
            SetDefaults();
            Console.WriteLine("\n\n--------List-------\n");
            Team team      = this[0];
            var  taskBegin = Environment.TickCount;

            _a.Contains(team);
            var taskEnd = Environment.TickCount;

            Console.WriteLine("\nSearch for first: {0}", taskEnd - taskBegin);

            team      = this[1];
            taskBegin = Environment.TickCount;
            _a.Contains(team);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for second: {0}", taskEnd - taskBegin);

            team      = this[2];
            taskBegin = Environment.TickCount;
            _a.Contains(team);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for third: {0}", taskEnd - taskBegin);

            team      = this[3];
            taskBegin = Environment.TickCount;
            _a.Contains(team);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for fourth: {0}", taskEnd - taskBegin);


            Console.WriteLine("\n\n----Dictionary Keys----\n");
            Team[] keys = new Team[4];
            _c.Keys.CopyTo(keys, 0);

            taskBegin = Environment.TickCount;
            _c.ContainsKey(keys[0]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for first: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsKey(keys[1]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for second: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsKey(keys[2]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for third: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsKey(keys[3]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for fourth: {0}", taskEnd - taskBegin);


            Console.WriteLine("\n\n----Dictionary Values----\n");
            ResearchTeam[] values = new ResearchTeam[4];
            _c.Values.CopyTo(values, 0);

            taskBegin = Environment.TickCount;
            _c.ContainsValue(values[0]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for first: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsValue(values[1]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for second: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsValue(values[2]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for third: {0}", taskEnd - taskBegin);

            taskBegin = Environment.TickCount;
            _c.ContainsValue(values[3]);
            taskEnd = Environment.TickCount;
            Console.WriteLine("\nSearch for fourth: {0}", taskEnd - taskBegin);



            return(0);
        }