コード例 #1
0
        public void Should_return_default_on_get_not_existing()
        {
            var el = new ExpandableList <long>();

            var actual = el[2];

            Assert.That(actual, Is.EqualTo(0));
        }
コード例 #2
0
        public void Should_return_default_created_by_delegate_on_get_not_existing()
        {
            var el = new ExpandableList <long>(() => 345L);

            var actual = el[2];

            Assert.That(actual, Is.EqualTo(345L));
        }
コード例 #3
0
        public void Sample()
        {
            var numbers = new ExpandableList();
            numbers.Add(1);
            numbers.Add(2);

            Expect(numbers.Elements, Is.EquivalentTo(new[] {1, 2}));
        }
コード例 #4
0
        public void Sample()
        {
            var numbers = new ExpandableList();

            numbers.Add(1);
            numbers.Add(2);

            Expect(numbers.Elements, Is.EquivalentTo(new[] { 1, 2 }));
        }
コード例 #5
0
        public void Should_create_item_on_get()
        {
            var el = new ExpandableList <ExpandableList <long> >(
                () => new ExpandableList <long>());

            el[3][1] = 12;

            Assert.That(el[3][1], Is.EqualTo(12));
        }
コード例 #6
0
        public void Should_increment_correctly()
        {
            var el = new ExpandableList <ExpandableList <long> >(
                () => new ExpandableList <long>());

            el[3][1]  = 12;
            el[3][1] += 8;

            Assert.That(el[3][1], Is.EqualTo(20));
        }
コード例 #7
0
        public static void Main()
        {
            string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString;

            IMusicRepository musicRepository = new EntityFrameworkMusicRepository(new DataContext(connectionString));
            //IMusicRepository musicRepository = new AdoNetMusicRepository(connectionString);
            var dataModel = new MusicListModel(musicRepository);
            var list      = new ExpandableList(dataModel);

            list.Run();
        }
コード例 #8
0
ファイル: ReportUtil.cs プロジェクト: elea30/codereports
        public static ExpandableList<ExpandableList<Cell>> GetCellMatrix(Report rep)
        {
            var result = new ExpandableList<ExpandableList<Cell>>
            {
                NewElement = (i) =>
                {
                    return new ExpandableList<Cell>
                    {
                        NewElement = (j) => { return new Cell(); }
                    };
                }
            };

            foreach (var cell in rep.Cells)
                result[cell.Row][cell.Column] = cell;
            return result;
        }
コード例 #9
0
ファイル: IdeaController.cs プロジェクト: Lietuva2/LT2
        public virtual ActionResult GetComments(string id, CommentViews?sort, ForAgainst?filter, string versionId)
        {
            if (Request.HttpMethod == "GET" || !Request.IsAjaxRequest())
            {
                return(RedirectToAction(MVC.Idea.Details(id, null, versionId)));
            }

            if (!sort.HasValue && !filter.HasValue)
            {
                CommentsFilter = null;
            }

            sort   = GetCommentSort(sort);
            filter = GetCommenFilter(filter);

            ExpandableList <CommentView> comments = null;

            if (sort == CommentViews.MostSupported)
            {
                comments = Service.GetCommentsMostSupported(id, 0, filter);
            }
            else if (sort == CommentViews.MostRecent)
            {
                comments = Service.GetCommentsMostRecent(id, 0, filter);
            }
            else if (sort == CommentViews.ByVersion)
            {
                comments = Service.GetCommentsByVersion(id, versionId, 0, filter);
            }

            var json =
                new
            {
                Content = RenderPartialViewToString(MVC.Comments.Views._CommentList, comments.List),
                comments.HasMoreElements,
                UpdatedHref = Url.Action(MVC.Idea.GetMoreComments(id, null, sort, filter, versionId))
            };

            return(Json(json));
        }
コード例 #10
0
ファイル: IdeaController.cs プロジェクト: Lietuva2/LT2
        public virtual ActionResult GetMoreComments(string id, int?pageIndex, CommentViews?sort, ForAgainst?filter, string versionId)
        {
            if (Request.HttpMethod == "GET" || !Request.IsAjaxRequest())
            {
                return(RedirectToAction(MVC.Idea.Details(id, null, versionId)));
            }

            if (!pageIndex.HasValue)
            {
                return(Json(null));
            }

            ExpandableList <CommentView> comments = null;

            if (!sort.HasValue || sort == CommentViews.MostSupported)
            {
                comments = Service.GetCommentsMostSupported(id, pageIndex.Value, filter);
            }
            else if (sort == CommentViews.MostRecent)
            {
                comments = Service.GetCommentsMostRecent(id, pageIndex.Value, filter);
            }
            else if (sort == CommentViews.ByVersion)
            {
                comments = Service.GetCommentsByVersion(id, versionId, pageIndex.Value, filter);
            }

            var json =
                new
            {
                Content = RenderPartialViewToString(MVC.Comments.Views._CommentList, comments.List),
                comments.HasMoreElements
            };

            return(Json(json));
        }
コード例 #11
0
ファイル: CommentService.cs プロジェクト: Lietuva2/LT2
        public ExpandableList <CommentView> GetCommentsMostRecent(ICommentable entity, int pageNumber, ForAgainst?posOrNeg = null, bool orderResultAsc = false)
        {
            var comments = new List <CommentView>();
            var query    = entity.Comments.AsEnumerable();

            if (posOrNeg.HasValue)
            {
                query = query.Where(c => c.PositiveOrNegative == posOrNeg);
            }

            foreach (var comment in query.OrderByDescending(c => c.Date).GetExpandablePage(pageNumber, CustomAppSettings.PageSizeComment))
            {
                comments.Add(GetCommentViewWithComments(entity, comment));
            }

            var result = new ExpandableList <CommentView>(comments, CustomAppSettings.PageSizeComment);

            if (orderResultAsc)
            {
                result.List = result.List.OrderBy(m => m.CommentDate).ToList();
            }

            return(result);
        }
コード例 #12
0
        public App()
        {
            InitializeComponent();

            MainPage = new ExpandableList();
        }