Exemplo 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");
 }
Exemplo 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);
        }
Exemplo 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");
 }
Exemplo 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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 7
0
 public DynamicNode(INode Node)
 {
     this.n = new DynamicBackingItem(Node);
 }
Exemplo n.º 8
0
 public DynamicNode(int NodeId, DynamicBackingItemType ItemType)
 {
     this.n = new DynamicBackingItem(NodeId, ItemType);
 }
Exemplo n.º 9
0
 public DynamicNode(int NodeId)
 {
     this.n = new DynamicBackingItem(NodeId);
 }
Exemplo 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;
        }
Exemplo n.º 11
0
 public DynamicMedia(DynamicBackingItem item) : base(item) { }
Exemplo n.º 12
0
 public DynamicMedia(DynamicBackingItem item) : base(item)
 {
 }