示例#1
0
        public static Item ParseItem(Item item, XmlNode itemnode)
        {
            if (item == null)
            {
                item = new Item();
            }

            item.Name = itemnode.GetAttributeValue <string>("name");
            if (string.IsNullOrEmpty(item.Name))
            {
                item.Name = itemnode.InnerText;
            }

            item.Id          = itemnode.GetAttributeValue <Guid>("id");
            item.TemplateId  = GetTemplateId(itemnode);
            item.SortOrder   = itemnode.GetAttributeValue <int>("sortorder");
            item.SectionId   = itemnode.GetAttributeValue <Guid>("sectionid");
            item.TemplateKey = itemnode.GetAttributeValue <string>("template");
            item.HasChildren = itemnode.GetAttributeValue <bool>("haschildren");
            item.Node        = itemnode;
            item.ClassName   = item.Name;



            var itemIcon = itemnode.GetAttributeValue <string>("icon");

            if (!string.IsNullOrEmpty(itemIcon))
            {
                item.IconUrl = new Uri($"{AppSettings.Instance().SitecoreUrl}{itemIcon}", UriKind.Absolute);
            }
            else
            {
                var content = itemnode.SelectSingleNode(@".//field[@key='__icon']/content");
                if (content != null)
                {
                    item.IconUrl = new Uri($"{AppSettings.Instance().SitecoreUrl}/temp/IconCache/{content.InnerText}", UriKind.Absolute);
                }
            }
            if (item.TemplateKey == "template")
            {
                item.Fields = LinqToSitecoreFactory.GetFields(item.Id);
            }

            if (itemnode.ChildNodes.Count > 0)
            {
                item.Children = new ObservableCollection <Item>(itemnode.ChildNodes.Cast <XmlNode>()
                                                                .Select(x => x.GetItemXml()).Where(x => x != null).Select(x => x.ToItem()).ToList());
            }

            return(item);
        }
示例#2
0
 public void TestConnection()
 {
     var item = LinqToSitecoreFactory.IsValidConnection();
 }
示例#3
0
 public void GetItemsFromServiceTest()
 {
     var id   = new Guid("{6B229418-DB30-4875-A721-6D0AAD0D8DE2}");
     var item = LinqToSitecoreFactory.GetChildren(id);
 }