Beispiel #1
0
    void ConncetServer_test()
    {
        IPAddress  ipAdr = IPAddress.Parse("101.132.135.198");
        IPEndPoint ipEp  = new IPEndPoint(ipAdr, 1234);

        Socket clientScoket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

        clientScoket.Connect(ipEp);
        Local loc = new Local {
            PosX = 12, PosY = 12, PosZ = 32, Name = "abc", RotX = 12, RotY = 123, RotZ = 34
        };

        byte[] concent = loc.ToByteArray();
        clientScoket.Send(concent);
        byte[] response = new byte[1024];
        int    len_recv = clientScoket.Receive(response);

        byte[]  data    = response.Take(len_recv).ToArray();
        Another another = Another.Parser.ParseFrom(data);

        GameObject.Find("ghi").GetComponent <Transform>().position = new Vector3(another.PosX, another.PosY, another.PosZ);
        transform.localEulerAngles = new Vector3(another.RotX, another.RotY, another.RotZ);

        clientScoket.Shutdown(SocketShutdown.Both);
        clientScoket.Close();
    }
Beispiel #2
0
    void ConncetServer_local()
    {
        IPAddress  ipAdr = IPAddress.Parse("101.132.135.198");
        IPEndPoint ipEp  = new IPEndPoint(ipAdr, 1234);

        Socket clientScoket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

        clientScoket.Connect(ipEp);

        float xx  = GameObject.Find("def").GetComponent <Transform>().position.x;
        float yy  = GameObject.Find("def").GetComponent <Transform>().position.y;
        float zz  = GameObject.Find("def").GetComponent <Transform>().position.z;
        float rx  = GameObject.Find("def").GetComponent <Transform>().localEulerAngles.x;
        float ry  = GameObject.Find("def").GetComponent <Transform>().localEulerAngles.y;
        float rz  = GameObject.Find("def").GetComponent <Transform>().localEulerAngles.z;
        Local loc = new Local {
            PosX = xx, PosY = yy, PosZ = zz, RotX = rx, RotY = ry, RotZ = rz, Name = "def"
        };

        byte[] concent = loc.ToByteArray();
        clientScoket.Send(concent);
        byte[] response = new byte[1024];
        int    len_recv = clientScoket.Receive(response);

        byte[]  data    = response.Take(len_recv).ToArray();
        Another another = Another.Parser.ParseFrom(data);

        clientScoket.Shutdown(SocketShutdown.Both);
        clientScoket.Close();
    }
        public void MainTest()
        {
            using (var session = Domain.OpenSession())
                using (TransactionScope transactionScope = session.OpenTransaction())
                {
                    // Creating new persistent object
                    var helloWorld = new MyEntity
                    {
                        Text = "Hello World!"
                    };
                    // Committing transaction

                    var hw2 = new Another {
                        Text = "ololo", MyEnt = helloWorld
                    };

                    transactionScope.Complete();
                }

            // Reading all persisted objects from another Session
            using (var session = Domain.OpenSession())
                using (TransactionScope transactionScope = session.OpenTransaction())
                {
                    foreach (MyEntity myEntity in session.Query.All <MyEntity>())
                    {
                        Console.WriteLine(myEntity.Text);
                    }


                    var query = session.Query.All <Another>().Where(a => a.MyEntText.Contains("e")).Select(a => new { a.Id, a.MyEntText });
                    foreach (var item in query)
                    {
                        // OK
                        Console.WriteLine(item);
                    }


                    var aggregateQuery = from q in query
                                         select new { Item = q, FakeKey = 0 }
                    into i
                    group i by i.FakeKey;
                    var aggregate = aggregateQuery.Select(a => new { Count = a.Count() });

                    foreach (var item in aggregate)
                    {
                        // OK
                        Console.WriteLine(item);
                    }

                    // Exception!
                    var nowCount = aggregate.FirstOrDefault();

                    var futureCount = session.Query.ExecuteDelayed(_ => aggregate.FirstOrDefault());

                    transactionScope.Complete();
                }
        }
    public static int Main()
    {
        Blah k = new Blah();

        Foo f = k;

        object o = k;

        if (f is Foo)
        {
            Console.WriteLine("I am a Foo!");
        }

        Hello ihello = f;

        Another ianother = f;

        ihello = ianother;

        bool b = f.MyMethod(22);

        MyDelegate del = new MyDelegate(k.Bar);

        del(2, 3);

        Delegate tmp = del;

        // Explicit reference conversions

        MyDelegate adel = (MyDelegate)tmp;

        adel(4, 7);

        Blah l = (Blah)o;

        l.Bar(20, 30);

        l = (Blah)f;

        l.Bar(2, 5);

        f = (Foo)ihello;

        // The following cause exceptions even though they are supposed to work
        // according to the spec

        // This one sounds ridiculous !
        // ITest t = (ITest) l;

        // ITest u = (ITest) ihello;

        return(0);
    }
        public void WrongStream()
        {
            // Array
            using var _context = new DBContext(_dbInit.DbContextOptions);
            ISelector _selector       = new Select.Selector(_serviceProvider);
            var       _selectRequest  = new Another();
            var       _expectedResult = _context.Table.ToArray();

            // Act

            // Assert
            Assert.Catch <InvalidOperationException>(() =>
                                                     _selector.Apply(_context.Table.AsQueryable(), _selectRequest).ToArray());
        }
        public static void checkOut()
        {
            string Another;

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("With a loud pop and a ploom of smoke Wizbolt hold out his hand.");
            Console.WriteLine("Sitting on top of his palm is your cupcake.");
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("Well that was fun! One " + Cupcake.Size + " " + Cupcake.Kind + " cupcake.");
            Console.WriteLine("On it, it has:");
            Console.WriteLine("(" + Cupcake.ChocolateSauce + ") ChocolateSauce");
            Console.WriteLine("(" + Cupcake.CaramelDrizzle + ") CaramelDrizzle");
            Console.WriteLine("(" + Cupcake.Sprinkles + ") Sprinkles");
            Console.WriteLine("(" + Cupcake.ChocolateChips + ") ChocolateChips");
            Console.WriteLine("(" + Cupcake.Coconut + ") Coconut");
            Console.WriteLine("Wana get another(Y/N)?");

            Another = Console.ReadLine();

            switch (Another.ToUpper())
            {
            case "Y":
            {
                Menu.menu();
                break;
            }
            }

            //if they get to here they dont want another
            Console.WriteLine("Well then, this is where you give me your money! $" + Cupcake.Total + " please!\n");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Press any key to pay the man.");
            Console.ReadKey();
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.Gray;
            Console.WriteLine("And with that, I must bid you adieu!\n");
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Wizbolt says pushing out the door and slamming it behind you");
            Console.WriteLine("You sand for a moment, a bit confused as to what just happened to you.");
            Console.WriteLine("You then shrug, taking a bight of cupcake and walk up the stairs.\n");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine("Press any key to end the game.");
            Console.ReadKey();
        }
        public void Test()
        {
            var one = new One()
              {
            Value1 = 1,
            Value2 = "2",
            Value3 = 3.3,
            Value4 = 4,
            Value5 = 5
              };

              var two = new Another();
              BeanUtils.CopyPropeties(one, two);

              Assert.AreEqual(1, two.Value1);
              Assert.AreEqual("2", two.Value2);
              Assert.AreEqual(3.3, two.Value3);
        }
Beispiel #8
0
    public void Test()
    {
      var one = new One()
      {
        Value1 = 1,
        Value2 = "2",
        Value3 = 3.3,
        Value4 = 4,
        Value5 = 5
      };

      var two = new Another();
      BeanUtils.CopyPropeties(one, two);

      Assert.AreEqual(1, two.Value1);
      Assert.AreEqual("2", two.Value2);
      Assert.AreEqual(3.3, two.Value3);
    }
Beispiel #9
0
        static void Main()
        {
            Student s1 = new Student {
                Name = "Maria", Surname = "Kravchenko", Age = 23
            };
            Student s2 = new Student {
                Name = "Konstantin", Surname = "Kirilenko", Age = 23
            };
            Student s3 = new Student {
                Name = "Lolita", Surname = "Mazurenko", Age = 23
            };
            Student s4 = new Student {
                Name = "Anna", Surname = "Godnaya", Age = 23
            };

            bool   N   = false;
            bool   KAK = false;
            char   chislo;
            string Chislo1;
            int    chislo1;

            Console.Clear();
            while (KAK == false)
            {
                Console.Clear();
                Console.WriteLine("Where are you study? \n 1.Belarus\n 2.Poland\n 3.Another country\n");
                Chislo1 = Console.ReadLine();
                int.TryParse(Chislo1, out chislo1);
                while (chislo1 < 1 || chislo1 > 3)
                {
                    Console.WriteLine("Choose the number from 1 to 3:");
                    Console.WriteLine("Where are you study? \n 1.Belarus\n 2.Poland\n 3.Another country\n");
                    Chislo1 = Console.ReadLine();
                    int.TryParse(Chislo1, out chislo1);
                }
                switch (chislo1)
                {
                case 1:
                    Console.Clear();
                    Belarus bel = new Belarus();
                    Console.Clear();
                    bel.stu();
                    while (N == false)
                    {
                        Console.WriteLine("\nChoose the number\n1.Show Infomation about student.\n2.Chage name.\n3.Change Surname.\n4.Change Nationality.\n" +
                                          "5.Change age.\n6.Change weight.\n7.Change university.\n8.Change speciality.\n9.Change the course.\na.Change height.\nq.Compare age with other sudent.\np.Popolnit schet.\nz.Zaplatit za uchebu.\n0. Exist\n");
                        chislo = Console.ReadKey().KeyChar;
                        Console.Clear();
                        switch (chislo)
                        {
                        case '1': bel.show2(); break;

                        case '2': bel.rename(ref imya1); break;

                        case '3': bel.resurname(); break;

                        case '4': bel.Renation(); break;

                        case '5': bel.Reage(); break;

                        case '6': bel.Reweight(); break;

                        case '7': bel.Reuniversity(); break;

                        case '8': bel.Respeciality(); break;

                        case '9': bel.Recourse(); break;

                        case 'a': bel.Reheight(); break;

                        case 'q':
                            Student[] people = new Student[] { s1, s2, s3, s4, bel };
                            Array.Sort(people);
                            Console.WriteLine("\n");
                            foreach (Student s in people)
                            {
                                Console.WriteLine($"{s.Name} - {s.Surname} - {s.Age}");
                            }
                            break;

                        case 'p': bel.Popol(); break;

                        case 'z': bel.Zaplatit(); break;


                        case '0': N = true; break;

                        default: break;
                        }
                    }
                    break;

                case 2:
                    Console.Clear();
                    Poland pol = new Poland();
                    Console.Clear();
                    pol.stu();
                    while (N == false)
                    {
                        Console.WriteLine("\nChoose the number\n1.Show Infomation about student.\n2.Chage name.\n3.Change Surname.\n4.Change Nationality.\n" +
                                          "5.Change age.\n6.Change weight.\n7.Change university.\n8.Chnge speciality.\n9.Change the course.\na.Change height.\nq.Compare age with other sudent.\np.Popolnit schet.\nz.Zaplatit za uchebu.\n0. Exist\n");
                        chislo = Console.ReadKey().KeyChar;
                        Console.Clear();
                        switch (chislo)
                        {
                        case '1': pol.show1(); break;

                        case '2': pol.rename(ref imya1); break;

                        case '3': pol.resurname(); break;

                        case '4': pol.Renation(); break;

                        case '5': pol.Reage(); break;

                        case '6': pol.Reweight(); break;

                        case '7': pol.Reuniversity(); break;

                        case '8': pol.Respeciality(); break;

                        case '9': pol.Recourse(); break;

                        case 'a': pol.Reheight(); break;

                        case 'q':
                            Student[] people = new Student[] { s1, s2, s3, s4, pol };
                            Array.Sort(people);
                            Console.WriteLine("\n");
                            foreach (Student s in people)
                            {
                                Console.WriteLine($"{s.Name} - {s.Surname} - {s.Age}");
                            }
                            break;

                        case 'p': pol.Popol(); break;

                        case 'z': pol.Zaplatit(); break;

                        case '0': N = true; break;

                        default: break;
                        }
                    }
                    break;

                case 3:
                    Console.Clear();
                    Another an = new Another();
                    Console.Clear();
                    an.stu();
                    while (N == false)
                    {
                        Console.WriteLine("\nChoose the number\n1.Show Infomation about student.\n2.Chage name.\n3.Change Surname.\n4.Change Nationality.\n" +
                                          "5.Change age.\n6.Change weight.\n7.Change university.\n8.Chnge speciality.\n9.Change the course.\na.Change height.\nq.Compare age with other sudent.\np.Popolnit schet.\nz.Zaplatit za uchebu.\n0. Exist\n");
                        chislo = Console.ReadKey().KeyChar;
                        Console.Clear();
                        switch (chislo)
                        {
                        case '1': an.show3(); break;

                        case '2': an.rename(ref imya1); break;

                        case '3': an.resurname(); break;

                        case '4': an.Renation(); break;

                        case '5': an.Reage(); break;

                        case '6': an.Reweight(); break;

                        case '7': an.Reuniversity(); break;

                        case '8': an.Respeciality(); break;

                        case '9': an.Recourse(); break;

                        case 'a': an.Reheight(); break;

                        case 'q':
                            Student[] people = new Student[] { s1, s2, s3, s4, an };
                            Array.Sort(people);
                            Console.WriteLine("\n");
                            foreach (Student s in people)
                            {
                                Console.WriteLine($"{s.Name} - {s.Surname} - {s.Age}");
                            }
                            break;

                        case 'p': an.Popol(); break;

                        case 'z': an.Zaplatit(); break;

                        case '0': N = true; break;

                        default: break;
                        }
                    }
                    break;

                default:
                    break;
                }
                var stude = new List <Student>
                {
                    new Belarus(),
                    new Poland(),
                    new Another()
                };
                foreach (var st in stude)
                {
                    st.stu();
                }
            }
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            bool   N   = false;
            bool   KAK = false;
            char   chislo;
            string Chislo1;
            int    chislo1;

            Console.Clear();
            while (KAK == false)
            {
                Console.Clear();
                Console.WriteLine("Where are you study? \n 1.Belarus\n 2.Poland\n 3.Another country\n");
                Chislo1 = Console.ReadLine();
                int.TryParse(Chislo1, out chislo1);
                while (chislo1 < 1 || chislo1 > 3)
                {
                    Console.WriteLine("Choose the number from 1 to 3:");
                    Console.WriteLine("Where are you study? \n 1.Belarus\n 2.Poland\n 3.Another country\n");
                    Chislo1 = Console.ReadLine();
                    int.TryParse(Chislo1, out chislo1);
                }
                switch (chislo1)
                {
                case 1:
                    Console.Clear();
                    Belarus bel = new Belarus();
                    Console.Clear();
                    bel.stu();
                    while (N == false)
                    {
                        Console.WriteLine("\nChoose the number\n1.Show Infomation abot student.\n2.Chage name.\n3.Change Surname.\n4.Change Nationality.\n" +
                                          "5.Change age.\n6.Change weight.\n7.Change university.\n8.Chnge speciality.\n9.Change the course.\na.Change height.\n0. Exist\n");
                        chislo = Console.ReadKey().KeyChar;
                        Console.Clear();
                        switch (chislo)
                        {
                        case '1': bel.show2(); break;

                        case '2': bel.rename(ref imya1); break;

                        case '3': bel.resurname(); break;

                        case '4': bel.Renation(); break;

                        case '5': bel.Reage(); break;

                        case '6': bel.Reweight(); break;

                        case '7': bel.Reuniversity(); break;

                        case '8': bel.Respeciality(); break;

                        case '9': bel.Recourse(); break;

                        case 'a': bel.Reheight(); break;

                        case '0': N = true; break;

                        default: break;
                        }
                    }
                    break;

                case 2:
                    Console.Clear();
                    Poland pol = new Poland();
                    Console.Clear();
                    pol.stu();
                    while (N == false)
                    {
                        Console.WriteLine("\nChoose the number\n1.Show Infomation abot student.\n2.Chage name.\n3.Change Surname.\n4.Change Nationality.\n" +
                                          "5.Change age.\n6.Change weight.\n7.Change university.\n8.Chnge speciality.\n9.Change the course.\na.Change height.\n0. Exist\n");
                        chislo = Console.ReadKey().KeyChar;
                        Console.Clear();
                        switch (chislo)
                        {
                        case '1': pol.show1(); break;

                        case '2': pol.rename(ref imya1); break;

                        case '3': pol.resurname(); break;

                        case '4': pol.Renation(); break;

                        case '5': pol.Reage(); break;

                        case '6': pol.Reweight(); break;

                        case '7': pol.Reuniversity(); break;

                        case '8': pol.Respeciality(); break;

                        case '9': pol.Recourse(); break;

                        case 'a': pol.Reheight(); break;

                        case '0': N = true; break;

                        default: break;
                        }
                    }
                    break;

                case 3:
                    Console.Clear();
                    Another an = new Another();
                    Console.Clear();
                    an.stu();
                    while (N == false)
                    {
                        Console.WriteLine("\nChoose the number\n1.Show Infomation abot student.\n2.Chage name.\n3.Change Surname.\n4.Change Nationality.\n" +
                                          "5.Change age.\n6.Change weight.\n7.Change university.\n8.Chnge speciality.\n9.Change the course.\na.Change height.\n0. Exist\n");
                        chislo = Console.ReadKey().KeyChar;
                        Console.Clear();
                        switch (chislo)
                        {
                        case '1': an.show3(); break;

                        case '2': an.rename(ref imya1); break;

                        case '3': an.resurname(); break;

                        case '4': an.Renation(); break;

                        case '5': an.Reage(); break;

                        case '6': an.Reweight(); break;

                        case '7': an.Reuniversity(); break;

                        case '8': an.Respeciality(); break;

                        case '9': an.Recourse(); break;

                        case 'a': an.Reheight(); break;

                        case '0': N = true; break;

                        default: break;
                        }
                    }
                    break;

                default:
                    break;
                }
                var stude = new List <Student>
                {
                    new Belarus(),
                    new Poland(),
                    new Another()
                };
                foreach (var st in stude)
                {
                    st.stu();
                }
            }
        }