コード例 #1
0
        public void GetSetValue()
        {
            var          mapper       = new CategoriesMapper();
            IMapCategory construction = mapper.Construct <MainItem>();
            MainItem     main         = new MainItem();

            main.IsGood        = true;
            main.Total         = 2;
            main.SubCat.Weight = 4;
            DataTree tree = new DataTree(main, construction);

            Assert.AreEqual(true, tree.Leafs[1].Value);
            Assert.AreEqual(2, tree.Leafs[0].Value);
            Assert.AreEqual(4, tree.Branches[0].Leafs[0].Value);

            tree.Leafs[1].Value = false;
            Assert.AreEqual(false, tree.Leafs[1].Value);
            Assert.AreEqual(false, main.IsGood);

            tree.Leafs[0].Value = 88;
            Assert.AreEqual(88, tree.Leafs[0].Value);
            Assert.AreEqual(88, main.Total);

            tree.Branches[0].Leafs[0].Value = 7;
            Assert.AreEqual(7, tree.Branches[0].Leafs[0].Value);
            Assert.AreEqual(7, main.SubCat.Weight);
        }
コード例 #2
0
        public MainWindowViewModel()
        {
            MainItem mainItem = new MainItem();

            mainItem.ItemName = "Master Node";
            mainItem.type     = NodeTypes.master;
            //mainItem.Children.Add(new DummyNode());
            Nodes.Add(mainItem);
        }
コード例 #3
0
        public void ResolveInstance()
        {
            var          mapper       = new CategoriesMapper();
            IMapCategory construction = mapper.Construct <MainItem>();
            MainItem     main         = new MainItem();

            Assert.AreEqual(main, construction.ResolveInstance(main));
            Assert.AreEqual(main.SubCat, construction.Categories.First().ResolveInstance(main));
        }
コード例 #4
0
ファイル: ItemInPlay.cs プロジェクト: kashpir/Draught
 public Paths Moves()
 {
     if (TakingExists())
     {
         return(Takings());
     }
     if (MainItem.Colour() == ColourNames.White)
     {
         return(SimpleMovesForWhite());
     }
     return(SimpleMovesForBlack());
 }
コード例 #5
0
 public MainItemViewModel(string title)
 {
     Item = new MainItem(title);
     base.AddRange(new List <DetailsItemViewModel> {
         new DetailsItemViewModel("bla", "bla1"),
         new DetailsItemViewModel("bla", "bla2"),
         new DetailsItemViewModel("bla", "bla3"),
         new DetailsItemViewModel("bla", "bla4"),
         new DetailsItemViewModel("bla", "bla5"),
         new DetailsItemViewModel("bla", "bla6")
     });
 }
コード例 #6
0
        public void Create()
        {
            var          mapper       = new CategoriesMapper();
            IMapCategory construction = mapper.Construct <MainItem>();
            MainItem     main         = new MainItem();
            DataTree     tree         = new DataTree(main, construction);

            Assert.AreEqual(main, tree.Instance);
            Assert.AreEqual(construction.Categories.Count(), tree.Branches.Count);
            Assert.AreEqual(main.SubCat, tree.Branches[0].Instance);
            Assert.AreEqual(construction.Fields.Count(), tree.Leafs.Count);
            Assert.AreEqual(construction.AllChildFields.Count(), tree.AllLeafs.Count());
        }
コード例 #7
0
        public void SetValue()
        {
            var          mapper       = new CategoriesMapper();
            IMapCategory construction = mapper.Construct <MainItem>();
            MainItem     main         = new MainItem();

            construction["IsGood"].First().SetValue(main, true);
            construction["Weight"].First().SetValue(main.SubCat, 10);
            construction["Total"].First().SetValue(main, 20);
            Assert.AreEqual(true, main.IsGood);
            Assert.AreEqual(20, main.Total);
            Assert.AreEqual(10, main.SubCat.Weight);
        }
コード例 #8
0
        public void GetValue()
        {
            var          mapper       = new CategoriesMapper();
            IMapCategory construction = mapper.Construct <MainItem>();
            MainItem     main         = new MainItem();

            main.IsGood        = true;
            main.Total         = 2;
            main.SubCat.Weight = 4;
            Assert.AreEqual(true, construction["IsGood"].First().GetValue <bool>(main));
            Assert.AreEqual(4, construction["Weight"].First().GetValue <int>(main.SubCat));
            Assert.AreEqual(2, construction["Total"].First().GetValue <int>(main));
        }
コード例 #9
0
        MainItem GetItem()
        {
            MainItem item = new MainItem();

            item.name_cn = tbox_name_cn.Text; if (item.name_cn == null || item.name_cn.Trim() == "")
            {
                return(null);
            }
            item.name_en      = tbox_name_en.Text;
            item.name_other   = tbox_name_other.Text;
            item.release_date = tbox_release_date.Text;
            item.version      = tbox_version.Text;

            var torrentPath = tbox_torrent.Text;

            if (torrentPath != null && torrentPath.Trim() != "")
            {
                item.torrent = readBytesFromFile(torrentPath);
            }

            var iconPath = tbox_icon_name.Text;

            if (iconPath == null || iconPath.Trim() == "")
            {
                return(null);
            }
            item.icon     = readBytesFromFile(iconPath);
            item.homepage = tbox_homepage.Text;

            if (tbox_rank.Text != null && tbox_rank.Text.Trim() != "")
            {
                item.rank = int.Parse(tbox_rank.Text);
            }

            item.baiduyun      = tbox_baiduyun.Text;
            item.category      = cbox_category.SelectedItem.ToString();
            item.company       = tbox_company.Text;
            item.desc          = tbox_desc.Text;
            item.language      = cbox_language.SelectedItem.ToString();
            item.license       = cbox_license.SelectedItem.ToString();
            item.magnet        = tbox_magnet.Text;
            item.size          = tbox_size.Text;
            item.star_marks    = int.Parse(cbox_star_marks.SelectedItem.ToString());
            item.update_time   = tbox_update_time.Text;
            item.url           = tbox_url.Text;
            item.snapshot_urls = tbox_snapshots.Text;

            return(item);
        }
コード例 #10
0
        private void AddingNewItem(string name, string number, int quantity, string date, string numberAct, string notes)
        {
            _executorCommands.AddEvent = AddEventHandler;
            var newItem = new MainItem()
            {
                DateItem   = date,
                ItemNumber = number,
                NameItem   = name,
                Quantity   = quantity,
                Notes      = notes,
                NumberAct  = numberAct
            };
            var command = new AddCommand <MainItem>(_executorCommands, newItem);

            command.Execute();
        }
コード例 #11
0
        public void TestCollection()
        {
            var          mapper       = new CategoriesMapper();
            IMapCategory construction = mapper.Construct <MainItem>();
            MainItem     main         = new MainItem();
            DataTree     tree         = new DataTree(main, construction);

            Assert.AreEqual(0, tree.Branches[1].Leafs.Count);
            main.Data["Test"] = 4;
            tree = new DataTree(main, construction);
            Assert.AreEqual(1, tree.Branches[1].Leafs.Count);

            Assert.AreEqual(4, tree.Branches[1].Leafs[0].Value);
            Assert.AreEqual("Test", tree.Branches[1].Leafs[0].Name);
            Assert.AreEqual("Test", tree.Branches[1].Leafs[0].Description);
        }
コード例 #12
0
        public async Task <IActionResult> GetItemWithId(int id)
        {
            var content = await _context.Content.Where(i => i.ID == id).Include(c => c.Category.Contents).FirstOrDefaultAsync();

            MainItem mobileView = new MainItem
            {
                Content = new MockContent {
                    ID               = content.ID,
                    CategoryID       = content.CategoryID,
                    ContentTitle     = content.ContentTitle,
                    DateEdited       = content.DateEdited,
                    DatePublished    = content.DatePublished,
                    ImageUrl         = $"https://www.uturuabianews.com/{content.ImageUrl}",
                    LongDescription  = content.LongDescription,
                    NoOfComments     = content.NoOfComments,
                    NoOfLikes        = content.NoOfLikes,
                    NoOfViews        = content.NoOfViews,
                    ShortDescription = content.ShortDescription,
                    VideoUrl         = content.VideoUrl
                }
            };

            mobileView.Contents = new List <MockContent>();
            foreach (var item in content.Category.Contents)
            {
                var mockContent = new MockContent
                {
                    ID               = item.ID,
                    CategoryID       = item.CategoryID,
                    ContentTitle     = item.ContentTitle,
                    DateEdited       = item.DateEdited,
                    DatePublished    = item.DatePublished,
                    ImageUrl         = $"https://www.uturuabianews.com/{item.ImageUrl}",
                    LongDescription  = item.LongDescription,
                    NoOfComments     = item.NoOfComments,
                    NoOfLikes        = item.NoOfLikes,
                    NoOfViews        = item.NoOfViews,
                    ShortDescription = item.ShortDescription,
                    VideoUrl         = item.VideoUrl
                };
                mobileView.Contents.Add(mockContent);
            }
            return(Json(mobileView));
        }
コード例 #13
0
        public void DictionaryValue()
        {
            Dictionary <string, double> map = new Dictionary <string, double>();

            map["IsGood"] = 0.1;
            map["Weight"] = 3;
            var          mapper       = new CategoriesMapper();
            IMapCategory construction = mapper.Construct <MainItem>();
            MainItem     main         = new MainItem();

            main.IsGood        = true;
            main.Total         = 2;
            main.SubCat.Weight = 4;
            DataTree tree = new DataTree(main, construction, new DictionaryDataItemFactory(map));

            Assert.AreEqual(0.1, Math.Round((double)tree.Leafs[1].Value, 2));
            Assert.AreEqual(0, tree.Leafs[0].Value);
            Assert.AreEqual(3, tree.Branches[0].Leafs[0].Value);
        }
コード例 #14
0
ファイル: MainForm.cs プロジェクト: tempbottle/webbox
        MainItem GetItem()
        {
            MainItem item = new MainItem();

            item.name_cn = tbox_name_cn.Text; if (item.name_cn == null || item.name_cn.Trim() == "") return null;
            item.name_en = tbox_name_en.Text;
            item.name_other = tbox_name_other.Text;
            item.release_date = tbox_release_date.Text;
            item.version = tbox_version.Text;

            var torrentPath = tbox_torrent.Text;
            if(torrentPath!=null &&torrentPath.Trim()!="")
            {
                item.torrent = readBytesFromFile(torrentPath);
            }

            var iconPath = tbox_icon_name.Text;
            if (iconPath == null || iconPath.Trim() == "") return null;
            item.icon = readBytesFromFile(iconPath);
            item.homepage = tbox_homepage.Text;

            if(tbox_rank.Text!=null &&tbox_rank.Text.Trim()!="")
            {
                item.rank = int.Parse(tbox_rank.Text);
            }

            item.baiduyun = tbox_baiduyun.Text;
            item.category = cbox_category.SelectedItem.ToString();
            item.company = tbox_company.Text;
            item.desc = tbox_desc.Text;
            item.language = cbox_language.SelectedItem.ToString();
            item.license = cbox_license.SelectedItem.ToString();
            item.magnet = tbox_magnet.Text;
            item.size = tbox_size.Text;
            item.star_marks = int.Parse(cbox_star_marks.SelectedItem.ToString());
            item.update_time = tbox_update_time.Text;
            item.url = tbox_url.Text;
            item.snapshot_urls = tbox_snapshots.Text;

            return item;
        }
コード例 #15
0
 public MainItemViewModel(MainItem mainItem, IServiceProvider serviceProvider)
     : base(mainItem, serviceProvider)
 {
     _mainItem = mainItem;
 }