public override bool TryGetMember(GetMemberBinder binder, out object result)
        {
            result = null;

            string name = binder.Name;


            if (_item.Fields[name] != null)
            {
                result = GetField(name, _item);
                return(true);
            }

            SitecoreInfoType infoType;

            if (Enum.TryParse <SitecoreInfoType>(name, out infoType))
            {
                result = SitecoreInfoHandler.GetItemInfo(infoType, _item, null);
                return(true);
            }



            switch (name)
            {
            case "Parent":
                result = CreateNew(_item.Parent);
                break;

            case "Children":
                result = new DynamicCollection <DynamicItem>(_item.Children.Select(x => CreateNew(x)).ToArray());
                break;
            }
            if (result != null)
            {
                return(true);
            }

            throw new NotSupportedException("No field of Sitecore info matches the name {0} for item {1}".Formatted(name, _item.Paths.FullPath));
        }
Beispiel #2
0
 public void Setup()
 {
     _db      = global::Sitecore.Configuration.Factory.GetDatabase("master");
     _item    = _db.GetItem(new ID(new Guid("{D22C2A23-DF8A-4EC1-AD52-AE15FE63F937}")));
     _handler = new SitecoreInfoHandler();
 }