Esempio n. 1
0
 public DynamicNode(DynamicBackingItem n)
 {
     if (n != null)
         this.n = n;
     else
         throw new ArgumentNullException("n", "A node must be provided to make a dynamic instance");
 }
Esempio n. 2
0
        public PropertyResult GetProperty(string alias, bool recursive, out bool propertyExists)
        {
            if (!recursive)
            {
                return(GetProperty(alias, out propertyExists));
            }
            if (IsNull())
            {
                propertyExists = false;
                return(null);
            }
            DynamicBackingItem context = this;
            PropertyResult     prop    = this.GetProperty(alias, out propertyExists);

            while (prop == null || string.IsNullOrEmpty(prop.Value))
            {
                context = context.Parent;
                if (context == null)
                {
                    break;
                }
                prop = context.GetProperty(alias, out propertyExists);
            }
            if (prop != null)
            {
                return(prop);
            }
            return(null);
        }
Esempio n. 3
0
 public DynamicNode(string NodeId)
 {
     int DynamicBackingItemId = 0;
     if (int.TryParse(NodeId, out DynamicBackingItemId))
     {
         this.n = new DynamicBackingItem(DynamicBackingItemId);
         return;
     }
     throw new ArgumentException("Cannot instantiate a DynamicNode without an id");
 }
Esempio n. 4
0
        public override void SetMembers(MacroModel macro, INode node)
        {
            if (macro == null)
            {
                throw new ArgumentNullException("macro");
            }
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            var backingItem = new DynamicBackingItem(node);
            var dynamicNode = new DynamicNode(backingItem);

            CurrentModel = dynamicNode;
            base.SetMembers(macro, node);
        }
        internal static DynamicNodeList ConvertSearchResultToDynamicNode(Examine.ISearchResults results)
        {
            var list = new DynamicNodeList();
            var xd = new XmlDocument();

            foreach (var result in results.OrderByDescending(x => x.Score))
            {
                var item = new DynamicBackingItem(result.Id);
            	if (item.Id == 0) continue;
            	var node = (NodeFactory.Node)item.content;
            	var examineResultXml = Umbraco.Core.XmlHelper.AddTextNode(xd, "examineScore", result.Score.ToString());
            	node.Properties.Add(new NodeFactory.Property(examineResultXml));

            	list.Add(new DynamicNode(item));
            }
            return list;
        }
        internal static DynamicNodeList ConvertSearchResultToDynamicNode(Examine.ISearchResults results)
        {
            var list = new DynamicNodeList();
            var xd   = new XmlDocument();

            foreach (var result in results.OrderByDescending(x => x.Score))
            {
                var item = new DynamicBackingItem(result.Id);
                if (item.Id == 0)
                {
                    continue;
                }
                var node             = (NodeFactory.Node)item.content;
                var examineResultXml = Umbraco.Core.XmlHelper.AddTextNode(xd, "examineScore", result.Score.ToString());
                node.Properties.Add(new NodeFactory.Property(examineResultXml));

                list.Add(new DynamicNode(item));
            }
            return(list);
        }
Esempio n. 7
0
 public DynamicNode(INode Node)
 {
     this.n = new DynamicBackingItem(Node);
 }
Esempio n. 8
0
 public DynamicNode(int NodeId, DynamicBackingItemType ItemType)
 {
     this.n = new DynamicBackingItem(NodeId, ItemType);
 }
Esempio n. 9
0
 public DynamicNode(int NodeId)
 {
     this.n = new DynamicBackingItem(NodeId);
 }
Esempio n. 10
0
        private List<string> GetAncestorOrSelfNodeTypeAlias(DynamicBackingItem node)
        {
            List<string> list = new List<string>();
            if (node != null)
            {
                if (node.Type == DynamicBackingItemType.Content)
                {
                    //find the doctype node, so we can walk it's parent's tree- not the working.parent content tree
                    CMSNode working = ContentType.GetByAlias(node.NodeTypeAlias);
                    while (working != null)
                    {
						//NOTE: I'm not sure if anyone has ever tested this but if you get working.Parent it will return a CMSNode and
						// it will never be castable to a 'ContentType' object
						// pretty sure the only reason why this method works for the one place that it is used is that it returns
						// the current node's alias which is all that is actually requried, this is just added overhead for no 
						// reason

                        if ((working as ContentType) != null)
                        {
                            list.Add((working as ContentType).Alias);
                        }
                        try
                        {
                            working = working.Parent;
                        }
                        catch (ArgumentException)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    return null;
                }
            }
            return list;
        }
Esempio n. 11
0
 public DynamicMedia(DynamicBackingItem item) : base(item) { }
Esempio n. 12
0
 public DynamicMedia(DynamicBackingItem item) : base(item)
 {
 }