Ejemplo n.º 1
0
            private static IEnumerator <object> IntYielder(count c, int start, int step)
            {
                int prev;

                for (; ;)
                {
                    prev = c._curInt;
                    try {
                        start = checked (start + step);
                    } catch (OverflowException) {
                        break;
                    }

                    c._curInt = start;
                    yield return(prev);
                }

                BigInteger startBig = (BigInteger)start + step;

                c._cur = startBig;
                yield return(prev);

                for (startBig += step; ; startBig += step)
                {
                    object prevObj = c._cur;
                    c._cur = startBig;
                    yield return(prevObj);
                }
            }
Ejemplo n.º 2
0
            public static count Get()
            {
                count count = typePool <count> .Pop() ?? new count();

                count.Count = 1;
                return(count);
            }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            List <string> fruits = new List <string> {
                "apple", "pear", "banana", "strawberry", "lemon"
            };

            transform transform = x => x.ToUpper();

            Console.WriteLine("Oefening 1");
            foreach (string fruit in fruits)
            {
                Console.WriteLine(transform(fruit));
            }

            Console.WriteLine("Oefening 2");

            count count = x => x.Length;

            foreach (string fruit in fruits)
            {
                Console.WriteLine($"{fruit} telt {count(fruit)} tekens");
            }
            Console.WriteLine("Oefening 3");
            compare compare = (x, y) => x.Length > y.Length;

            for (int i = 1; i < fruits.Count; i++)
            {
                Console.WriteLine($"{fruits[i-1]} contains more characters  than {fruits[i]} : {compare(fruits[i-1],fruits[i])}");
            }

            Console.ReadKey();
        }
Ejemplo n.º 4
0
 private static IEnumerator <BigInteger> BigIntYielder(count c, BigInteger start, BigInteger step)
 {
     for (start += step; ; start += step)
     {
         BigInteger prev = (BigInteger)c._cur;
         c._cur = start;
         yield return(prev);
     }
 }
Ejemplo n.º 5
0
 private static IEnumerator <object> ObjectYielder(PythonContext context, count c, object start, object step)
 {
     start = context.Operation(PythonOperationKind.Add, start, step);
     for (; ; start = context.Operation(PythonOperationKind.Add, start, step))
     {
         object prev = c._cur;
         c._cur = start;
         yield return(prev);
     }
 }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            count c = new count(countChars);

            Console.WriteLine("String 1: ");
            String a = Console.ReadLine();

            Console.WriteLine("String 2: ");
            String b = Console.ReadLine();

            Console.WriteLine(a + " " + b);
            Console.WriteLine(c(a, b));
        }
Ejemplo n.º 7
0
            private static IEnumerator <object> IntYielder(count c, int start, BigInteger step)
            {
                BigInteger startBig = (BigInteger)start + step;

                c._cur = startBig;
                yield return(start);

                for (startBig += step; ; startBig += step)
                {
                    object prevObj = c._cur;
                    c._cur = startBig;
                    yield return(prevObj);
                }
            }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            StudentData    sd       = new StudentData();
            List <Student> students = sd.GetFilteredStudents();

            foreach (Student student in students)
            {
                Console.WriteLine($"{student.FirstName} {student.LastName}");
            }
            Console.WriteLine();

            Console.WriteLine("Oefening 1");
            transform transform = x => x.ToUpper();

            foreach (string fruit in fruits)
            {
                Console.WriteLine(transform(fruit));
            }

            Console.WriteLine();
            Console.WriteLine("Oefening 2");
            count count = x => x.Length;

            foreach (string fruit in fruits)
            {
                Console.WriteLine($"{fruit} telt {count(fruit)} tekens");
            }

            Console.WriteLine();
            Console.WriteLine("Oefening 3");
            compare compare = (x, y) => x.Length > y.Length;

            for (int i = 1; i < fruits.Count; i++)
            {
                Console.WriteLine($"{fruits[i - 1]} contains more characters  than {fruits[i]} : {compare(fruits[i - 1], fruits[i])}");
            }

            Console.WriteLine();
            Console.WriteLine("Oefening 4");
            //checkAge checkAge = (x, y) => { if (x < y) return "not"; else return ""; };
            checkAge checkAge = (x, y) => (x < y)? "NOT": "";

            foreach (Student s in sd.GetAllStudents())
            {
                Console.WriteLine($"{s.FirstName} {s.LastName} is {checkAge(s.Age,21)} old enough.");
            }

            Console.ReadKey();
        }
Ejemplo n.º 9
0
        public HttpResponseMessage GetLeaveCount(string EID)
        {
            try
            {
                using (ebuilderEntities entities = new ebuilderEntities())
                {
                    var leavesApplied  = entities.leavs.Where(l => l.EID == EID && l.date.Year == DateTime.Now.Year);
                    var allLeavesCount = new List <count>();

                    //Get the accepted leaves only
                    var entity = (from l in leavesApplied join ap in entities.approvals on l.LID equals ap.LID where ap.status == "accepted" select l).ToList();

                    //get the leave types related to the employee's job category
                    var leaveTypes = (from e in entities.employees join lt in entities.leave_type on e.jobCategory equals lt.jobCategory where e.jobCategory == lt.jobCategory && e.EID == EID select lt).ToList();
                    foreach (var leaveType in leaveTypes)
                    {
                        count leaveCount = new count();
                        leaveCount.leaveCategory = leaveType.leaveCategory;
                        foreach (var leave in entity)
                        {
                            if (leave.leaveCategory == leaveType.leaveCategory)
                            {
                                if (leaveType.leaveCategory == "short leave" || leaveType.leaveCategory == "half day")
                                {
                                    if (leave.date.Month == DateTime.Now.Month)
                                    {
                                        leaveCount.takenCount++;
                                    }
                                }
                                leaveCount.takenCount++;
                            }
                        }

                        leaveCount.leftCount = leaveType.maxAllowed - leaveCount.takenCount;
                        allLeavesCount.Add(leaveCount);
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, allLeavesCount));
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Ejemplo n.º 10
0
        private void countRun()
        {
            //初始化
            Image    bg_image;
            Graphics my_graphics;
            Brush    my_brush;
            Font     my_font;

            bg_image    = RSVP7._0.Properties.Resources.bg_gray;
            my_graphics = Graphics.FromImage(bg_image);
            m_tmpgr     = my_graphics;
            my_brush    = new SolidBrush(Color.Black);
            my_font     = new Font("黑体", 150, FontStyle.Bold);

            count  ct  = new count(cdTime);
            clean  cln = new clean(clnNum);
            string str;

            //实验开始倒数
            for (int i = 5; i >= 1; i--)
            {
                str = i.ToString();
                this.Invoke(ct, new object[] { str, bg_image, my_graphics, my_brush, my_font });
                Thread.Sleep(1000);
                this.Invoke(cln, new object[] { my_graphics });
            }

            if (thr == null)
            {
                if (Config.m_auditory != 0)
                {
                    this.Invoke(ct, new object[] { "+", bg_image, my_graphics, my_brush, my_font });
                }
                thr = new Thread(new ThreadStart(thrRun));
                thr.Start();
            }
        }
Ejemplo n.º 11
0
 public static (IAsyncObserver <TSource>, IAsyncDisposable) Window <TSource>(IAsyncObserver <IAsyncObservable <TSource> > observer, IAsyncDisposable subscription, int count) => Window(observer, subscription, count, count);
Ejemplo n.º 12
0
 return(new BulletGroupInfo(count, orig.SpawnCount));
Ejemplo n.º 13
0
 SearchTypes.trending => await Client.TrendingAsync(count, NextGifs),
Ejemplo n.º 14
0
this.Semaphore = new SemaphoreSlim(count, count);
Ejemplo n.º 15
0
        public ActionResult Login(user user, string password, string remember)
        {
            try
            {
                user userDetail = db.user.Where(x => x.Mail == user.Mail && x.Password == user.Password).FirstOrDefault();
                // TODO: Add insert logic here
                if (userDetail != null)
                {
                    userDetail.Password = "******";
                }
                if (userDetail == null)
                {
                    TempData["AlertMessage"] = "User not found";
                    return(RedirectToAction("Index"));
                }
                if (userDetail.Status == 1)
                {
                    count count = db.count.Where(x => x.iduser == userDetail.idUsers).FirstOrDefault();
                    if (count == null)
                    {
                        count  newcount = new count();
                        string str      = "INSERT INTO `webshop`.`count` (`iduser`, `count`) VALUES ('" + userDetail.idUsers + "', '1');";
                        db.Database.ExecuteSqlCommand(str);
                    }
                    else
                    {
                        count.count1++;
                        string str = "UPDATE `webshop`.`count` SET `count` = '" + count.count1 + "' WHERE (`iduser` = '" + userDetail.idUsers + "');";
                        db.Database.ExecuteSqlCommand(str);
                    }
                    int          users       = db.user.ToList().Count - 1;
                    int          visitedbyme = db.count.Where(x => x.iduser == userDetail.idUsers).First().count1;
                    int          visit       = 0;
                    List <count> lvisit      = db.count.ToList();
                    foreach (var item in lvisit)
                    {
                        visit += item.count1;
                    }
                    DateTime now = DateTime.Now;

                    HttpCookie ck = new HttpCookie("counter");
                    ck.Expires.AddYears(30);
                    ck.Values.Add("visit", visit.ToString());
                    ck.Values.Add("visitedbyme", visitedbyme.ToString());
                    ck.Values.Add("users", users.ToString());
                    Response.Cookies.Add(ck);
                    TempData["AlertMessage"] = "Welcome " + user.Name;
                    Session["User"]          = userDetail;
                    Remember(remember);
                    return(Redirect("/User"));
                }
                else if (userDetail.Status == 999)
                {
                    Session["User"] = userDetail;
                    Remember(remember);
                    return(Redirect("/Admin"));
                }
                else
                {
                    TempData["AlertMessage"] = "The User Is Disabled. Wait until Admins Enable Your Account.";
                    return(RedirectToAction("Index"));
                }
            }
            catch
            {
                return(View());
            }
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            count numero = new count();
            morse morseC = new morse();
            caesar caesarC = new caesar();
             rsa rsa = new rsa();
            faza3 f3= new faza3();

                if (args[0] == "1")
                {
                     Environment.Exit(-1);
                }
                else if (args[1] == "2")
                {
                    if (args[2] == "1") { Console.WriteLine("numri i charactereve : " + numero.countCh(args[0])); }
                    else if (args[2] == "2") { Console.WriteLine("numri i rreshtave : " + numero.countLi(args[0])); }
                    else if (args[2] == "3") { Console.WriteLine("numri i fjaleve : " + numero.countW(args[0])); }
                    else if (args[2] == "4") { Console.WriteLine("numri i fjalive : " + numero.countWo(args[0])); }
                    else if (args[2] == "5") { Console.WriteLine("numri i zanoreve : " + numero.countZan(args[0])); }
                    else if (args[2] == "6") { Console.WriteLine("numri i bashtingelloreve : " + numero.countBash(args[0])); }
                    else if(args[2]=="7") {Console.WriteLine("numri i simboleve : " + numero.countSymb(args[0]));}
                    else { Console.WriteLine("Wrong input !!!"); }
                }
                else if (args[1] == "3")
                {
                    char[] ar = args[0].ToCharArray();
                    string emri = "", VP = "";
                    if (args[2] == "1")
                    {
                        for (int i = 0; i < ar.Length; i++)
                        {
                            emri = emri + morseC.morseEnco(ar[i]);//encode
                            if (ar[i] == ' ')
                            {

                            }
                            else { Console.Beep(); }

                            Console.Write(morseC.morseEnco(ar[i]));


                        }
                        Console.WriteLine("\n");
                    }
                    

                    else if (args[2] == "2")
                    {

                        for (int i = 0; i < ar.Length; i++)//decode
                        {
                            VP = VP + ar[i];

                            if (ar[i] == ' ')
                            {
                                emri = emri + morseC.morseDeco(VP);
                                VP = "";
                            }
                        }
                        Console.WriteLine(emri);
                    }
                    else { Console.WriteLine("Wrong input !!!"); }

                }
                else if (args[1] == "4")
                {
                    
                   
                    if (args[2] == "1") {
                        int k = Convert.ToInt32(args[3]);
                        Console.WriteLine("ciphertext : " + caesarC.caesarCipherEnco(args[0], k)); }
                    else if (args[2] == "2") {
                        int k = Convert.ToInt32(args[3]);
                        Console.WriteLine("plaintext : " + caesarC.caesarCipherDeco(args[0], k)); }
                    else if(args[2]=="3") {caesarC.bruteForce(args[0]);}
                    else { Console.WriteLine("Wrong input !!!"); }

                }
                 else if (args[0] == "create-user")
            {
                rsa.createUser(args[1]);
            }
            else if (args[0] == "delete-user")
            {
                rsa.deleteUser(args[1]);
            }
            else if (args[0] == "import-key")
            {
                rsa.importKey(args[1], args[2]);
            }
            else if (args[0] == "export-key")
            {
                rsa.exportKey(args[1], args[2]);
            }
            else if (args[0] == "write-text")
            {
                rsa.writeText(args[1], args[2],args[3],args[4]);
            }
             else if (args[0] == "read-text")
            {
                rsa.readText(args[1],args[2]);
            }
            else if (args[0] == "login")
            {
                f3.Login(args[1]);
            }
            else if (args[0] == "status")
            {
                Console.WriteLine(f3.status(args[1]));
            }
                else
                {
                    Console.WriteLine("Wrong input !!!");
                }
            
            Console.ReadKey();
        }
 /// <summary>
 /// Sends copy of buffer non-blocking with <see cref="SocketFlags.None"/>
 /// </summary>
 /// <returns>Returns false if send fails, else returns true with number of sent bytes</returns>
 protected (bool, int) SendNonBlocking(byte[] buffer, int offset, int count) => SendNonBlocking(buffer, offset, count, SocketFlags.None);
Ejemplo n.º 18
0
            private static IEnumerator<object> IntYielder(count c, int start, int step) {
                int prev;
                for (; ; ) {
                    prev = c._curInt;
                    try {
                        start = checked(start + step);
                    } catch (OverflowException) {
                        break;
                    }

                    c._curInt = start;
                    yield return prev;
                }

                BigInteger startBig = (BigInteger)start + step;
                c._cur = startBig;
                yield return prev;

                for (startBig += step; ; startBig += step) {
                    object prevObj = c._cur;
                    c._cur = startBig;
                    yield return prevObj;
                }
            }
Ejemplo n.º 19
0
 get => new Quantity(count: _quantityCount, unit:  _quantityUnit);
Ejemplo n.º 20
0
 var(count, items) = cmd.GetWhere <T> (predicate: null);
 set => Set(ref count, value);
Ejemplo n.º 22
0
 get => new Quantity(count: _servingSizeCount, unit:  _servingSizeUnit);
Ejemplo n.º 23
0
 var(count, s1, s2, s3, s4) = this.GetCounts(x.Key.AssignedToFullName);
Ejemplo n.º 24
0
 /// <summary>Gets the string for the specified 7Bit ASCII bytes.</summary>
 /// <param name="bytes">Bytes to decode.</param>
 /// <param name="start">Startindex at the array to decode.</param>
 /// <param name="count">Length in bytes to decode.</param>
 /// <param name="termination">if set to <c>true</c> [obey termination].</param>
 /// <returns>The string.</returns>
 /// <exception cref="ArgumentNullException">bytes.</exception>
 /// <exception cref="InvalidDataException">Byte '{0}' at index '{1}' is not a valid ASCII character!.</exception>
 public static string GetString(byte[] bytes, int start, int count, bool termination = false) => new(GetChars(bytes, start, count, termination));
Ejemplo n.º 25
0
            private static IEnumerator<object> IntYielder(count c, int start, BigInteger step) {
                BigInteger startBig = (BigInteger)start + step;
                c._cur = startBig;
                yield return start;

                for (startBig += step; ; startBig += step) {
                    object prevObj = c._cur;
                    c._cur = startBig;
                    yield return prevObj;
                }
            }
Ejemplo n.º 26
0
 GenerateGroupData(count, format, streamWriter);
Ejemplo n.º 27
0
 private static IEnumerator<BigInteger> BigIntYielder(count c, BigInteger start, BigInteger step) {
     for (start += step; ; start += step) {
         BigInteger prev = (BigInteger)c._cur;
         c._cur = start;
         yield return prev;
     }
 }
Ejemplo n.º 28
0
 var(preparation, measure, count, samples) = _args;
Ejemplo n.º 29
0
 private static IEnumerator<object> ObjectYielder(PythonContext context, count c, object start, object step) {
     start = context.Operation(PythonOperationKind.Add, start, step);
     for (; ; start = context.Operation(PythonOperationKind.Add, start, step)) {
         object prev = c._cur;
         c._cur = start;
         yield return prev;
     }
 }
Ejemplo n.º 30
0
 SearchTypes.getGifs => await Client.GetGifsAsync(count, NextGifs, Ids),
Ejemplo n.º 31
0
 Paginator = new Paginator(count: await countTask, pageNum: PageNum, link: "/OwnPosts?pageNum=1", topicId: null);
Ejemplo n.º 32
0
 select(count, bag);
Ejemplo n.º 33
0
 Paginator = new Paginator(count: topicList.Count(), pageNum: PageNum, link: "/NewPosts?pageNum=1", topicId: null);