Esempio n. 1
0
        protected override void OnCommitAdd(ItemStore store, IEnumerable <string> items, int index = -1)
        {
            var groups =
                from item in ParseNames(items)
                where !store.Contains(item)
                let isCamelCase = char.IsLower(item.FirstOrDefault())
                                  group item by isCamelCase into g
                                  select new { isCamelCase = g.Key, items = g };

            var divider =
                store.TakeWhile(item => !char.IsUpper(item.FirstOrDefault())).Select((item, i) => i + 1).LastOrDefault();

            foreach (var group in groups)
            {
                if (group.isCamelCase)
                {
                    var position = (index == -1 || index > divider) ? divider : index;
                    base.OnCommitAdd(store, group.items, position);
                }
                else
                {
                    var position = (index == -1) ? -1 : index + divider;
                    base.OnCommitAdd(store, group.items, position);
                }
            }
        }