Beispiel #1
0
        /// <summary>
        /// 首先这里有一个给整型数组进行冒泡排序的方法,
        /// 那么在后面的发展中,有需要对另一种类型的数组进行冒泡排序,规则跟下面的方法一样。只是数据类型不一致。
        /// 那么这时候可以使用到泛型方法,把类型参数化。把方法的签名抽象出来,(方法的前面主要是方法名和参数列表)
        /// </summary>
        /// <param name="arr"></param>
        public void BubbleSort(int[] arr)
        {
            //这里gog当做animal去返回,发生了协变 子类向父类转换。
            GetSome <Gog>    SS  = new GetSome <Gog>(() => { return(new Gog()); });
            GetSome <Animal> gog = SS;

            //这里的类型参数只用于输入,发生逆变, 父类向子类转换。
            GetOne <Animal> s1 = new GetOne <Animal>(() => { return(""); });
            GetOne <Gog>    s2 = s1;

            string s      = "";
            int    length = arr.Length;

            for (int i = 0; i < length - 1; i++)
            {
                for (int j = 0; j < length - 1 - i; j++)
                {
                    if (arr[j] > arr[j + 1])
                    {
                        int temp = arr[j];
                        arr[j]     = arr[j + 1];
                        arr[j + 1] = temp;
                    }
                }
            }
        }
Beispiel #2
0
 public Task <IResult <TModel> > Handle(GetOne <TModel> request, CancellationToken cancellationToken)
 {
     return(Task.Run(() =>
     {
         return _uow.Execute(db => Result.Success(db.GetCollection <TModel>().FindById(request.Id)));
     }, cancellationToken));
 }
Beispiel #3
0
        private void CardGroupForm_Load(object sender, EventArgs e)
        {
            //位置跟随
            if (this.Player == Player.MainPlaceInfo.Player1)
            {
                Point point = this.Player.MainPlaceInfo.MainFightPlace.Location;
                point.X      -= this.Width;
                point.Y      += this.Player.InfoForm.Height;
                this.Location = point;
            }
            else
            {
                Point point = this.Player.MainPlaceInfo.MainFightPlace.Location;
                point.X      += this.Player.MainPlaceInfo.MainFightPlace.Width;
                point.Y      += this.Player.InfoForm.Height;
                this.Location = point;
            }

            this.Text = Player.Name;
            listBox1.Hide();
            GetOne.Hide();
            this.Random.Hide();

            Player.InfoForm.StartPosition = FormStartPosition.Manual;
            Player.InfoForm.Show();
            Player.ProcessSelectForm.Show();

            //卡组
            bs1.DataSource         = Player.CardGroup.cardList;
            listBox1.DataSource    = bs1;
            listBox1.DisplayMember = "Name";
            //手牌
            bs2.DataSource         = Player.HandCardController.handCard;
            listBox2.DataSource    = bs2;
            listBox2.DisplayMember = "Name";
            //墓地
            bs3.DataSource         = Player.Grave.graveCards;
            listBox3.DataSource    = bs3;
            listBox3.DisplayMember = "Name";
            //除外区
            bs4.DataSource         = Player.ExceptionPlace.ExceptionCards;
            listBox4.DataSource    = bs4;
            listBox4.DisplayMember = "Name";
        }
        public GetSingleResult Execute(GetOne search)
        {
            var book = context.Books.AsQueryable();

            var reponse = new GetSingleResult
            {
                Item = book.Select(x => new BookDto
                {
                    Id           = x.Id,
                    Title        = x.Title,
                    Price        = x.BookPublishers.Select(bp => bp.Price).FirstOrDefault(),
                    CategoryName = x.Category.Name,
                    Publishers   = x.BookPublishers.Select(bp => bp.Publisher.Name),
                    AuthorsNames = x.BookAuthors.Select(ba => ba.Author.FirstName),
                    Src          = x.Image.Src,
                    Alt          = x.Image.Alt
                }).Where(b => b.Id == search.Id).FirstOrDefault()
            };

            return(reponse);
        }
 public IActionResult Get([FromRoute] GetOne search,
                          [FromServices] IGetSingleProductQuery query)
 {
     return(Ok(executor.ExecuteQuery(query, search)));
 }