Esempio n. 1
0
        /// <summary>
        /// final step in setting up database
        /// </summary>
        private void MapActivatedFeaturesToDefinitions()
        {
            if (ActivatedFeatures != null && ActivatedFeatures.Any())
            {
                var distinctActivatedFeatureIds = ActivatedFeatures.Select(af => af.Id).Distinct();

                foreach (Guid featureId in distinctActivatedFeatureIds)
                {
                    var activatedFeatureGroup = ActivatedFeatures.Where(af => af.Id == featureId);

                    var featureDef = FeatureDefinitions.FirstOrDefault(fd => fd.Id == featureId);

                    if (featureDef != null)
                    {
                        // add activated features to feature definition
                        featureDef.ActivatedFeatures.AddRange(activatedFeatureGroup);
                    }
                    else
                    {
                        // fyi - if we get here, we have most likely a group of faulty features ...

                        // create feature definition and add features
                        var newFeatureDef = FeatureDefinition.GetFeatureDefinition(activatedFeatureGroup);
                        FeatureDefinitions.Add(newFeatureDef);
                    }
                }
            }
        }
Esempio n. 2
0
        public void AddActivatedFeature(SPFeature feature)
        {
            if (feature == null)
            {
                return;
            }

            try
            {
                var activatedFeature = ActivatedFeature.GetActivatedFeature(feature);

                // update activated features
                this.ActivatedFeatures.Add(activatedFeature);


                // update featureDefinition (and its activated instances)
                var featureDef = this.FeatureDefinitions.FirstOrDefault(fd => fd.Id == activatedFeature.Id);

                if (featureDef != null)
                {
                    // add activated feature to feature definition
                    featureDef.ActivatedFeatures.Add(activatedFeature);
                }
                else
                {
                    // fyi - if we get here, we have most likely a group of faulty features ...

                    // create feature definition and add features
                    var newFeatureDef = FeatureDefinition.GetFeatureDefinition(activatedFeature);
                    this.FeatureDefinitions.Add(newFeatureDef);
                    Log.Warning("Unexpected - Feature Definition of activated Feature was not available - please Reload");
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error when trying to add new feature to InMemorySharePointDb", ex);
            }
        }
Esempio n. 3
0
        private List <FeatureDefinition> LoadAllFeatureDefinitions()
        {
            var spDefs = FarmRead.GetFeatureDefinitionCollection();

            return(FeatureDefinition.GetFeatureDefinition(spDefs));
        }