private void ProcessFeature( object modelHost, SPFeatureCollection features, FeatureDefinition featureModel) { var currentFeature = features.FirstOrDefault(f => f.DefinitionId == featureModel.Id); var featureActivated = currentFeature != null; InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = currentFeature, ObjectType = typeof(SPFeature), ObjectDefinition = featureModel, ModelHost = modelHost }); if (!featureActivated) { if (featureModel.Enable) { var f = features.Add(featureModel.Id, featureModel.ForceActivate); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = f, ObjectType = typeof(SPFeature), ObjectDefinition = featureModel, ModelHost = modelHost }); } else { InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = currentFeature, ObjectType = typeof(SPFeature), ObjectDefinition = featureModel, ModelHost = modelHost }); } } else { if (featureModel.Enable && featureModel.ForceActivate) { var f = features.Add(featureModel.Id, featureModel.ForceActivate); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = f, ObjectType = typeof(SPFeature), ObjectDefinition = featureModel, ModelHost = modelHost }); } else if (!featureModel.Enable) { features.Remove(featureModel.Id, featureModel.ForceActivate); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = null, ObjectType = typeof(SPFeature), ObjectDefinition = featureModel, ModelHost = modelHost }); } else { InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = currentFeature, ObjectType = typeof(SPFeature), ObjectDefinition = featureModel, ModelHost = modelHost }); } } }
protected SPFeature GetFeature(SPFeatureCollection features, FeatureDefinition featureModel) { return features.FirstOrDefault(f => f.DefinitionId == featureModel.Id); }
protected SPFeature GetFeature(SPFeatureCollection features, FeatureDefinition featureModel) { return(features.FirstOrDefault(f => f.DefinitionId == featureModel.Id)); }