Ejemplo n.º 1
0
        public void TestListDataExceptions()
        {
            var listDef = new ListDef("test").ChangeProperties(new[]
            {
                new AnnotationDef("text", AnnotationDef.AnnotationTargetSet.EMPTY, AnnotationDef.AnnotationType.text, null),
                new AnnotationDef("number", AnnotationDef.AnnotationTargetSet.EMPTY, AnnotationDef.AnnotationType.number, null),
                new AnnotationDef("true_false", AnnotationDef.AnnotationTargetSet.EMPTY, AnnotationDef.AnnotationType.true_false, null)
            });
            var columns = new ColumnData[]
            {
                new ColumnData.Strings(new[] { "one", "two", "three", "four" }),
                new ColumnData.Doubles(new double?[] { 1, 2, 3, 4 }),
                new ColumnData.Booleans(new[] { true, false, true, false }),
            };
            var listData = new ListData(listDef, columns);

            Assert.IsNotNull(listData.ChangeListDef(listDef.ChangeIdProperty("text"), null));
            Assert.IsNotNull(listData.ChangeListDef(listDef.ChangeIdProperty("number"), null));
            EnsureDetailException <ListExceptionDetail>(() => listData.ChangeListDef(listDef.ChangeIdProperty("true_false"), null));
            VerifySerialization(listData);
        }
Ejemplo n.º 2
0
        public ListData GetListDef()
        {
            var listDef = new ListDef(tbxListName.Text);

            listDef = listDef.ChangeProperties(_listProperties.Select(prop => prop.AnnotationDef));
            listDef = listDef.ChangeIdProperty(comboIdProperty.SelectedItem as string);
            listDef = listDef.ChangeDisplayProperty(comboDisplayProperty.SelectedItem as string);
            if (_listDefOriginal == null || _listDefOriginal.RowCount == 0)
            {
                return(new ListData(listDef));
            }
            var columNameMap = _listProperties.Where(prop => !string.IsNullOrEmpty(prop.OriginalName))
                               .ToDictionary(prop => prop.Name, prop => prop.OriginalName);

            return(_listDefOriginal.ChangeListDef(listDef, columNameMap));
        }