Example #1
0
        /// <summary>
        /// Gets all features for the specified tenant.
        /// </summary>
        /// <param name="tenant">The name of the tenant which modules will be get.</param>
        /// <returns>An array of objects representing the modules.</returns>
        public OrchardFeature[] GetFeatures(string tenant)
        {
            var extensionManager = this.Resolve <IExtensionManager>(tenant);
            var featureManager   = this.Resolve <IFeatureManager>(tenant);
            IEnumerable <FeatureDescriptor>   featureDescriptors = extensionManager.AvailableFeatures();
            IEnumerable <ExtensionDescriptor> extensions         = extensionManager.AvailableExtensions().ToArray();
            IEnumerable <FeatureDescriptor>   enabledFeatures    = featureManager.GetEnabledFeatures().ToArray();

            var features = new List <OrchardFeature>();

            foreach (FeatureDescriptor featureDescriptor in featureDescriptors)
            {
                OrchardFeature feature = MapDescriptorToOrchardFeature(featureDescriptor);

                ExtensionDescriptor extension = extensions.FirstOrDefault(e => e.Name == feature.Name);
                if (extension != null)
                {
                    feature.Module  = MapDescriptorToOrchardModule(extension);
                    feature.Enabled = enabledFeatures.Any(f => f.Name == feature.Name);
                }

                features.Add(feature);
            }

            foreach (OrchardFeature orchardFeature in features)
            {
                orchardFeature.TenantName = tenant;
            }

            return(features.ToArray());
        }
Example #2
0
        /// <summary>
        /// Provides a record-by-record processing functionality for the cmdlet.
        /// </summary>
        protected override void ProcessRecord()
        {
            string tenantName = null;

            if ((this.ParameterSetName != "FeatureObject") && string.IsNullOrEmpty(this.Tenant))
            {
                // Get feature for current tenant if tenant name not specified
                OrchardTenant tenant = this.GetCurrentTenant();
                tenantName = tenant != null ? tenant.Name : "Default";
            }

            if (!string.IsNullOrEmpty(this.Tenant))
            {
                tenantName = this.Tenant;
            }

            OrchardFeature feature = null;

            if (this.ParameterSetName == "Default")
            {
                feature = this.GetOrchardFeature(tenantName, this.Name);
                if (feature == null)
                {
                    this.WriteError(
                        new ArgumentException("Failed to find feature with name '" + this.Name + "'."),
                        "FailedToFindFeature",
                        ErrorCategory.InvalidArgument);
                }
            }
            else if (this.ParameterSetName == "FeatureObject")
            {
                feature    = this.Feature;
                tenantName = this.Feature.TenantName;
            }

            if (feature != null)
            {
                if (this.ShouldProcess("Feature: " + feature.Id + ", Tenant: " + tenantName, "Enable Feature"))
                {
                    this.modulesAgent.EnableFeature(tenantName, feature.Id, !this.WithoutDependencies.ToBool());
                }
            }
        }
Example #3
0
 public FeatureNode(IPowerShellVfs vfs, OrchardFeature feature)
     : base(vfs, feature.Name, feature)
 {
 }