Beispiel #1
0
        /// <summary>
        /// Gets the name of the Orchard tenant which the VFS node belongs to.
        /// </summary>
        /// <param name="node">The orchard VFS node instance.</param>
        /// <returns>
        /// The name of the Orchard tenant which the VFS node belongs to or <c>null</c> if the node does not belong to
        /// any Orchard tenant.
        /// </returns>
        public static string GetCurrentTenantName(this VfsNode node)
        {
            while (node != null)
            {
                var tenantNode = node as TenantNode;
                if (tenantNode != null)
                {
                    return(((OrchardTenant)tenantNode.Item).Name);
                }

                node = node.Parent;
            }

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the Orchard tenant from which the cmdlet was invoked.
        /// </summary>
        /// <param name="cmdlet">The cmdlet instance.</param>
        /// <returns>
        /// The <see cref="OrchardTenant"/> object which represents the current tenant or <c>null</c> if the cmdlet was
        /// invoked from a path which is not under any Orchard tenant.
        /// </returns>
        public static OrchardTenant GetCurrentTenant(this OrchardCmdlet cmdlet)
        {
            if (cmdlet == null)
            {
                throw new ArgumentNullException("cmdlet");
            }

            VfsNode currentNode = cmdlet.CurrentNode;

            while (currentNode != null)
            {
                var tenantNode = currentNode as TenantNode;
                if (tenantNode != null)
                {
                    return(tenantNode.Item as OrchardTenant);
                }

                currentNode = currentNode.Parent;
            }

            return(null);
        }
Beispiel #3
0
 public void Add(string name, VfsNode child) => _Children[name] = child;