Beispiel #1
0
        public RepositoryGroupBinding(CustomListBoxItemsCollection items, RepositoryGroup group)
        {
            Verify.Argument.IsNotNull(items, nameof(items));
            Verify.Argument.IsNotNull(group, nameof(group));

            _items               = items;
            _group               = group;
            _groupsMapping       = new Dictionary <RepositoryGroup, RepositoryGroupListItem>();
            _repositoriesMapping = new Dictionary <RepositoryLink, RepositoryListItem>();

            foreach (var subGroup in group.Groups)
            {
                var item = new RepositoryGroupListItem(subGroup);
                _groupsMapping.Add(subGroup, item);
                items.Add(item);
            }
            foreach (var repository in group.Respositories)
            {
                var item = new RepositoryListItem(repository);
                _repositoriesMapping.Add(repository, item);
                items.Add(item);
            }

            group.Groups.Changed        += OnGroupsChanged;
            group.Respositories.Changed += OnRepositoriesChanged;
        }
        public IGroupItem AddGroup(RepositoryGroup group)
        {
            var node = CreateNode(RepositoryItemType.Group);

            node.Text      = group.Name;
            node.TagObject = new GroupItemMetadata(group);
            return(AddNode(node) as IGroupItem);
        }
 public GroupItemMetadata(RepositoryGroup group)
 {
     if (@group == null)
     {
         throw new ArgumentNullException("group");
     }
     Group = group;
 }
Beispiel #4
0
        public void ConstructorTest()
        {
            RepositoryGroup _itemToTest = new RepositoryGroup();

            Assert.ThrowsException <NotImplementedException>(() => _itemToTest.Add("Key", null));
            Assert.ThrowsException <NotImplementedException>(() => _itemToTest.Add(new KeyValuePair <string, object>("Key", null)));
            Assert.ThrowsException <NotImplementedException>(() => _itemToTest.Clear());
            Assert.ThrowsException <NotImplementedException>(() => _itemToTest.Remove("Random name"));
            Assert.IsNotNull(_itemToTest.GetEnumerator());
            Assert.IsNotNull(_itemToTest.Keys);
            Assert.AreEqual <int>(0, _itemToTest.Count);
        }
Beispiel #5
0
        public void GetConsumerBindingJsonSerializationTest()
        {
            RepositoryGroup _itemToTest      = new RepositoryGroup();
            string          processValueName = "processValueName";
            Action <String> updater          = _itemToTest.AddProperty <string>(processValueName);

            Assert.IsNotNull(updater);
            Assert.AreEqual <int>(1, _itemToTest.Count);
            Assert.AreEqual <string>(default(string), (string)_itemToTest[processValueName]);
            updater("New value");
            Assert.AreEqual <string>("New value", (string)_itemToTest[processValueName]);
            string dto = _itemToTest.ToString();

            Debug.Write(dto);
            Assert.AreEqual <int>(32, dto.Length);
            Assert.AreEqual <string>("{\"processValueName\":\"New value\"}", dto);
        }
            public override object GroupNameFromItem(object item, int level, System.Globalization.CultureInfo culture)
            {
                var             repo = item as IRemoteRepositoryModel;
                var             name = repo.Owner;
                RepositoryGroup group;

                if (!owner.groups.TryGetValue(name, out group))
                {
                    group = new RepositoryGroup(name, owner.groups.Count == 0);

                    if (owner.groups.Count == 1)
                    {
                        owner.groups.Values.First().IsExpanded = false;
                    }
                    owner.groups.Add(name, group);
                }

                return(group);
            }
Beispiel #7
0
            public override object GroupNameFromItem(object item, int level, System.Globalization.CultureInfo culture)
            {
                var repo = item as IRepositoryModel;

                Debug.Assert(repo.Owner != null, "Repository owner cannot be null, did something get changed in the RepositoryModel ctor?");
                var             name = repo.Owner.Login;
                RepositoryGroup group;

                if (!owner.groups.TryGetValue(name, out group))
                {
                    group = new RepositoryGroup(name, owner.groups.Count == 0);

                    if (owner.groups.Count == 1)
                    {
                        owner.groups.Values.First().IsExpanded = false;
                    }
                    owner.groups.Add(name, group);
                }

                return(group);
            }
        public AddEditWindow()
        {
            this.Closing += Window_Closing;
            this.Loaded  += Window_Loaded;

            InitializeComponent();
            DataContext = this;

            OKCommand = new DelegateCommand(
                () =>
            {
                DialogResult = true;
            },
                (p) => true,
                () => AddMode ? "Добавить" : "Сохранить");
            CancelCommand = new DelegateCommand(
                () =>
            {
                DialogResult = false;
            },
                "Отменить");
            ChangeItemTypeCommand = new DelegateCommand(
                (e) =>
            {
                if (e == null)
                {
                    return;
                }
                string type = e.ToString();
                if (type == "item")
                {
                    Item = new RepositoryItem();
                }
                else
                {
                    Item = new RepositoryGroup();
                }
            });
        }
 public RepositoryGroup WriteGroup(RepositoryGroup repositoryGroup)
 {
     return(_fileConfigManager.WriteData(repositoryGroup, repositoryGroup.GroupName, ConfigPaths.RepositoryGroups));
 }