Beispiel #1
0
        static void Main(string[] args)
        {
            Person[]     persons = new Person[3];
            Copywriter[] copyrat = new Copywriter[3];
            persons[0] = new Person("Vladimir", "Ahakov", new DateTime(2000, 11, 13));
            persons[1] = new Person("Artemiy", "Begasov", new DateTime(1997, 03, 05));
            persons[2] = new Person("John", "Cook", new DateTime(1999, 09, 27));
            copyrat[0] = new Copywriter(persons[0], "King", (Level)1, 4);
            copyrat[1] = new Copywriter(persons[1], "Rognak", 0, 3);
            copyrat[2] = new Copywriter(persons[2], "Kilimonjaru", 0, 2);


            CopywriterCollection c1 = new CopywriterCollection();
            CopywriterCollection c2 = new CopywriterCollection();

            c1.ColName = "Collection 1";
            c2.ColName = "Сollection 2";
            Journal j1 = new Journal();
            Journal j2 = new Journal();

            c1.CopywritersCountChanged    += j1.Changer;
            c1.CopywriterReferenceChanged += j1.Changer;
            c1.CopywriterReferenceChanged += j2.Changer;
            c2.CopywriterReferenceChanged += j2.Changer;
            c1.AddDefaults();
            c2.AddDefaults();
            c1.Remove(0);
            c2.Remove(1);
            c1[1] = copyrat[0];
            c2[1] = copyrat[1];
            Console.WriteLine(j1.ToString());
            Console.WriteLine(j2.ToString());
            Console.ReadKey();
        }
 public TestCollections(int amount)
 {
     for (int i = 1; i <= amount; ++i)
     {
         Copywriter copy = GenerateCopywriter(i);
         people.Add(copy.AuthorInfo);
         str.Add(copy.AuthorInfo.ToString());
         peopdic.Add(copy.AuthorInfo, copy);
         strdic.Add(copy.AuthorInfo.ToString(), copy);
     }
 }
        public long TimeStrDic(Copywriter copy)
        {
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            if (!strdic.ContainsValue(copy))
            {
                return(-1);
            }

            stopwatch.Stop();
            return(stopwatch.ElapsedTicks);
        }
        public long TimeCopyDicKey(Copywriter copy)
        {
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            if (!peopdic.ContainsKey(copy.AuthorInfo))
            {
                return(-1);
            }

            stopwatch.Stop();
            return(stopwatch.ElapsedTicks);
        }
        public long TimeStr(Copywriter copy)
        {
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();

            if (!str.Contains(copy.AuthorInfo.ToString()))
            {
                return(-1);
            }

            stopwatch.Stop();
            return(stopwatch.ElapsedTicks);
        }
Beispiel #6
0
 public bool Remove(Copywriter cw)
 {
     if (!dic.ContainsValue(cw))
     {
         return(false);
     }
     else
     {
         var item = dic.First(kvp => kvp.Value == cw);
         CopywritersChanged?.Invoke(cw, new CopywritersChangedEventArgs <TKey>(ColName, Action.Remove, null, GenerateKey(item.Value)));
         dic.Remove(item.Key);
         return(true);
     }
 }
Beispiel #7
0
        public new object DeepCopy()
        {
            Copywriter test = new Copywriter();

            test.Name     = this.Name;
            test.Surname  = this.Surname;
            test.Data     = this.Data;
            test.Nickname = this.Nickname;
            test.Level    = this.Level;
            test.Rating   = this.Rating;
            test.artinfo  = this.artinfo.ConvertAll(article => new Article(article.ArName, article.ArSymbols, article.ArDate));
            test.ordinfo  = this.ordinfo.ConvertAll(order => new Order(order.Theme, order.Orderdate, order.Deadline));
            return(test);
        }
Beispiel #8
0
 static string GenerateKeyByTeamName(Copywriter cw)
 {
     return(cw.Name);
 }
Beispiel #9
0
        static void Main(string[] args)
        {
            Person[]     persons  = new Person[3];
            Copywriter[] copyrat  = new Copywriter[3];
            Person[]     persons1 = new Person[3];
            Copywriter[] copyrat1 = new Copywriter[3];
            persons[0]  = new Person("Vladimir", "Ahakov", new DateTime(2000, 11, 13));
            persons[1]  = new Person("Artemiy", "Begasov", new DateTime(1997, 03, 05));
            persons[2]  = new Person("John", "Cook", new DateTime(1999, 09, 27));
            copyrat[0]  = new Copywriter(persons[0], "King", (Level)1, 4);
            copyrat[1]  = new Copywriter(persons[1], "Rognak", 0, 3);
            copyrat[2]  = new Copywriter(persons[2], "Kilimonjaru", 0, 2);
            persons1[0] = new Person("1Vladimir", "Ahakov1", new DateTime(2010, 11, 13));
            persons1[1] = new Person("1Artemiy", "Begasov1", new DateTime(1911, 03, 05));
            persons1[2] = new Person("1John", "Cook1", new DateTime(1999, 09, 27));
            copyrat1[0] = new Copywriter(persons1[0], "1King1", (Level)1, 4);
            copyrat1[1] = new Copywriter(persons1[1], "1Rognak1", 0, 3);
            copyrat1[2] = new Copywriter(persons1[2], "1Kilimonjaru1", 0, 2);

            CopywriterCollection <string> c1 = new CopywriterCollection <string>();
            CopywriterCollection <string> c2 = new CopywriterCollection <string>();

            c1.ColName      = "Collection 1";
            c2.ColName      = "Сollection 2";
            c1.GenerateKey += GenerateKeyByTeamName;
            c2.GenerateKey += GenerateKeyByTeamName;

            Journal <string> j1 = new Journal <string>();

            c1.CopywritersChanged += j1.Changer;
            c2.CopywritersChanged += j1.Changer;
            c1.AddCopywriters(copyrat);
            c2.AddCopywriters(copyrat1);
            c1["Vladimir"].Nickname = "CHANGED!";
            //c2["1John"].Rating = 3;
            c1["Artemiy"].Surname = "CHANGED!";
            c1.Remove(copyrat[0]);
            //c1["Vladimir"].Nickname = "Deleted";
            List <Copywriter> list1 = new List <Copywriter>();

            foreach (var item in copyrat)
            {
                list1.Add(item);
            }
            foreach (var item in copyrat1)
            {
                list1.Add(item);
            }
            foreach (var item in list1)
            {
                Console.WriteLine(item.ToShortString());
            }
            c1.Sort_ColList(list1);

            //Journal j1 = new Journal();
            //c1.CopywritersCountChanged += j1.Changer;
            //c1.CopywriterReferenceChanged += j1.Changer;
            //c1.CopywriterReferenceChanged += j2.Changer;
            //c2.CopywriterReferenceChanged += j2.Changer;
            //c1.AddDefaults();
            //c2.AddDefaults();
            //c1.Remove(0);
            //c2.Remove(1);
            //c1[1] = copyrat[0];
            //c2[1] = copyrat[1];
            //Console.WriteLine(j1.ToString());
            //Console.WriteLine(j2.ToString());
            Console.WriteLine(j1.ToString());
            foreach (var item in list1)
            {
                Console.WriteLine(item.ToShortString());
            }
            Console.ReadKey();
        }
Beispiel #10
0
 public int Compare(Copywriter x)
 {
     return(this.Rating.CompareTo(x.Rating));
 }
 public CopywriterListHandlerEventArgs(string cn, string cc, Copywriter link)
 {
     ColName    = cn;
     ColChanges = cc;
     Link       = link;
 }