Example #1
0
            public bool Equals([AllowNull] GenericPerson <T> other)
            {
                if (other is null)
                {
                    return(false);
                }

                return(Name == other.Name && Infos.Equals(other.Infos));
            }
Example #2
0
        public void RoundtripGenericClass_AllowPrivateStandardResolver()
        {
            var person = new GenericPerson <int> {
                Name = "bob"
            };
            var options = StandardResolverAllowPrivate.Options;

            byte[] msgpack      = MessagePackSerializer.Serialize(person, options);
            var    deserialized = MessagePackSerializer.Deserialize <GenericPerson <int> >(msgpack, options);

            Assert.Equal(person.Name, deserialized.Name);
        }
Example #3
0
        static void Main(string[] args)
        {
            //Generic type is a string in this case
            GenericClass <string> genStr = new GenericClass <string>();
            string name = genStr.GenericMethod("Tochukwu");

            genStr.GenericProperty = "Programmer";
            Console.WriteLine("{0}, {1}", name, genStr.GenericProperty);

            //Generic type is now an int in this case
            GenericClass <int> genInt = new GenericClass <int>();
            int salary = genInt.GenericMethod(33000);

            genInt.GenericProperty = 4;
            Console.WriteLine("R{0} - {1}yrs", salary, genInt.GenericProperty);

            /*Generic class with restrictions*/
            GenericRef <Person>     person  = new GenericRef <Person>();
            GenericVal <int>        number  = new GenericVal <int>();
            GenericPerson <Person>  madu    = new GenericPerson <Person>();
            GenericPerson <Student> learner = new GenericPerson <Student>();

            /*Generic method*/
            Example             example = new Example();
            int                 wages   = example.NoRestrict(33000);
            GenericRef <Person> someone = example.Restrict(person);

            Console.WriteLine(wages);
            Console.WriteLine(someone);

            example.Multiple <string, int>("Tochi", 33000);
            example.Multiple("Tochi", 33000);



            Console.ReadLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            List <Person> peolpe     = new FakeDatabase().GetGenericPeolple();
            List <Person> personlist = new FakeDatabase().GetGenericPeolple();


            Person Eric = new Person()
            {
                FirstName = "F", Lastname = "l", Startdate = new DateTime(1900, 01, 01)
            };
            //peolpe.Add(new Person() { FirstName = "Eric", Lastname = "Kunga", Rating = 5, Startdate = new DateTime() });
            //peolpe.Add(new Person() { FirstName = "Zekira", Lastname = "Mabanga", Rating = 6, Startdate = new DateTime() });
            //personlist.Add(new Person() { FirstName = "First1", Lastname = "Lastname1", Rating = 1, Startdate = new DateTime(1900,01,01) });
            //personlist.Add(new Person() { FirstName = "First2", Lastname = "Lastname2", Rating = 2, Startdate = new DateTime(2000,1,1) });
            //personlist.Add(new Person() { FirstName = "First3", Lastname = "Lastname3", Rating = 3, Startdate = new DateTime(2010,1,1) });
            //personlist.Add(new Person() { FirstName = "First4", Lastname = "Lastname4", Rating = 4, Startdate = new DateTime(2020,1,1) });

            //foreach (Person item in peolpe)
            //{
            //    Console.WriteLine(item.FirstName + "  " + item.Lastname + " " + item.Rating + " " + item.Startdate);
            //}
            //Console.WriteLine(new string('-', 10));
            //foreach (Person item in personlist)
            //{
            //    Console.WriteLine(item.FirstName + "  " + item.Lastname + " " + item.Rating + " " + item.Startdate);
            //}

            IPersonRepository repository = new PersonRepository();

            repository.AddPerson(new Person()
            {
                FirstName = "New first", Lastname = "New Last", Startdate = new DateTime(2012, 8, 14), Rating = 1000
            });

            Console.WriteLine(new string('-', 10));
            Console.WriteLine("Get People");
            Console.WriteLine(new string('-', 10));

            var repo = repository.GetPeople();

            foreach (Person item in repo)
            {
                Console.WriteLine("Firstname: " + item.FirstName + " - Lastname: " + item.Lastname + " - Rating: " + item.Rating + " - Startdate" + item.Startdate);
            }
            Console.WriteLine(new string('-', 10));
            Console.WriteLine("Get Person");
            Console.WriteLine(new string('-', 10));

            var repoperson = repository.GetPerson("Lastname1");

            Console.WriteLine("Firstname: " + repoperson.FirstName + " - Lastname: " + repoperson.Lastname + " - Rating: " + repoperson.Rating + " - Startdate" + repoperson.Startdate);

            repoperson = repository.GetPerson("Lastname4");
            Console.WriteLine("Firstname: " + repoperson.FirstName + " - Lastname: " + repoperson.Lastname + " - Rating: " + repoperson.Rating + " - Startdate" + repoperson.Startdate);


            Console.WriteLine(" ");
            Console.WriteLine(new string('-', 10));


            IRepository <Person, string> Joran = new GenericPerson();

            List <Person> people = Joran.AddItem(Eric);


            foreach (var item in people)
            {
                //////Console.WriteLine("Firstname: " + item.FirstName + " - Lastname: " + item.Lastname + " - Rating: " + item.Rating + " - Startdate" + item.Startdate);
            }
            //Show();
            Console.ReadKey();
        }
    //Changed on 19/12/2018
    //Added a function called teleport

    void OnTriggerStay2D(Collider2D col)
    {
        if (isWorldDoor)
        {
            //World doors can only teleport players
            if (col.CompareTag("Player"))
            {
                if (worldID != 11)
                {
                    Teleport();
                }
                else
                {
                    SceneManager.LoadScene("End");
                }
            }

            if (col.gameObject.name == "Person")
            {
                GenericPerson person = col.GetComponent <GenericPerson>();
                //checks item person is holding
                if (person.item != null)
                {
                    //if the player isn't holding the key, they can leave the world
                    if (person.item.name != "Key")
                    {
                        Teleport();
                    }
                    //if the person holds nothing it proceeds
                }
            }
        }
        else
        {
            //given it is a subworld door
            if (col.CompareTag("NPC") && col.GetComponent <CharacterBase>().manipulated == CharacterBase.isControlled.player)
            {
                //checks if it is the person NPC
                if (col.gameObject.name == "Person")
                {
                    GenericPerson person = col.GetComponent <GenericPerson>();
                    //checks item person is holding
                    if (person.item != null)
                    {
                        //if the player isn't holding clothes, they can go
                        if (person.item.name != "RedClothes" || person.item.name != "BlueClothes")
                        {
                            Teleport();
                        }

                        //if the person holds nothing it proceeds
                    }
                    else
                    {
                        Teleport();
                    }
                }
                else
                {
                    Teleport();
                }
            }
            else
            {
                //if it's a player, proceed
                if (col.CompareTag("Player"))
                {
                    Teleport();
                }
            }
        }
    }
Example #6
0
 public GenericPerson <T> Op(GenericPerson <T> x, GenericPerson <T> y)
 {
     return(new GenericPerson <T>(x.Name + y.Name, x.Infos));
 }