Esempio n. 1
0
        /// <summary>
        /// Get a feature definition based on an activated feature, even from a faulty one
        /// </summary>
        /// <param name="feature">an activated Feature</param>
        /// <returns>A FeatureDefinition with current feature already added</returns>
        /// <remarks>
        /// ActivatedFeature is better than SPFeature, because it already handled the faulty feature issues
        /// </remarks>
        public static FeatureDefinition GetFeatureDefinition(ActivatedFeature feature)
        {
            if (feature == null)
            {
                throw new ArgumentNullException("Parameter 'feature'");
            }

            var fd = new FeatureDefinition()
            {
                Id         = feature.Id,
                Name       = feature.Name,
                Scope      = feature.Scope,
                Faulty     = feature.Faulty,
                Definition = feature.Definition
            };

            fd.ActivatedFeatures.Add(feature);

            return(fd);
        }
Esempio n. 2
0
        public static FeatureDefinition GetFeatureDefinition(SPFeatureDefinition definition,
                                                             IEnumerable <ActivatedFeature> activatedFeatures = null)
        {
            if (definition == null)
            {
                throw new ArgumentNullException("Parameter definition must not be null!");
            }

            var fd = new FeatureDefinition()
            {
                Definition = definition,
                Id         = definition.Id,
                Name       = definition.DisplayName,
                Scope      = definition.Scope,
                Faulty     = false
            };

            if (activatedFeatures != null)
            {
                fd.ActivatedFeatures.AddRange(activatedFeatures);
            }

            return(fd);
        }