Beispiel #1
0
 private void LoadData(AccessControlModel control, bool isHeaderVisible, int itemCount)
 {
     AddRange(
         Enumerable.Range(isHeaderVisible ? 1 : 0, itemCount).Select(
             i => new ItemDataModel(ToIndex(i, isHeaderVisible), control.Control.ItemData[i]?.ToString())
             )
         );
 }
Beispiel #2
0
        public ItemDataCollectionModel(AccessControlModel control)
        {
            var isHeaderVisible = control.TryGetDynamicPropertyValue <bool>("ColumnHeads");
            var hasItemCount    = control.TryGetDynamicPropertyValue("ListCount", out int itemCount);

            if (hasItemCount)
            {
                LoadData(control, isHeaderVisible, itemCount);
            }
            else
            {
                LoadFallbackData(control, isHeaderVisible);
            }
        }
Beispiel #3
0
        public SelectedItemDataCollectionModel(AccessControlModel control)
        {
            var isHeaderVisible = control.TryGetDynamicPropertyValue <bool>("ColumnHeads");

            AddRange(
                Enumerable
                .Range(0, control.Control.ItemsSelected.Count)
                .Select(i =>
            {
                var itemIndex = control.Control.ItemsSelected[i];
                var itemValue = control.Control.ItemData[itemIndex]?.ToString();
                return(new ItemDataModel(isHeaderVisible ? itemIndex - 1 : itemIndex, itemValue));
            })
                );
        }
Beispiel #4
0
        private void LoadFallbackData(AccessControlModel control, bool isHeaderVisible)
        {
            var i = 0;

            while (true)
            {
                var item = control.Control.ItemData[i]?.ToString();
                if (item == "{}" || string.IsNullOrEmpty(item))
                {
                    break;
                }
                if (i > 0 || !isHeaderVisible)
                {
                    Add(new ItemDataModel(ToIndex(i, isHeaderVisible), item));
                }

                ++i;
                if (i > 10000)
                {
                    throw new Exception($"Error finding last data item for control {control.Name}");
                }
            }
        }