コード例 #1
0
        private void LoadItems([NotNull] XElement root)
        {
            Debug.ArgumentNotNull(root, nameof(root));

            Items.Clear();

            foreach (var element in root.Elements())
            {
                var name   = element.GetAttributeValue("name");
                var itemId = element.GetAttributeValue("id");
                var icon   = element.GetAttributeValue("icon");

                var itemUri = new ItemUri(DatabaseUri, new ItemId(new Guid(itemId)));

                var item = new LibraryItemDescriptor(items, itemUri, name, new Icon(DatabaseUri.Site, icon));

                Items.Add(item);
            }
        }
コード例 #2
0
        protected virtual void Load()
        {
            bulkUpdating++;
            try
            {
                items.Clear();

                var contents = AppHost.Files.ReadAllText(FileName);

                var root = contents.ToXElement();
                if (root == null)
                {
                    return;
                }

                var folderName = root.GetAttributeValue("name");
                if (!string.IsNullOrEmpty(folderName))
                {
                    Name = folderName;
                }

                foreach (var element in root.Elements())
                {
                    ItemUri itemUri;
                    if (!ItemUri.TryParse(element.GetAttributeValue("itemuri"), out itemUri))
                    {
                        continue;
                    }

                    var name = element.GetAttributeValue("name");
                    var icon = new Icon(element.GetAttributeValue("icon"));

                    var i = new LibraryItemDescriptor(items, itemUri, name, icon);

                    items.Add(i);
                }
            }
            finally
            {
                bulkUpdating--;
            }
        }