private void MapConfig(SPWebConfigModification config, WebConfigModificationDefinition definition) { config.Path = definition.Path; config.Name = definition.Name; config.Sequence = definition.Sequence; config.Owner = definition.Owner; config.Type = (SPWebConfigModification.SPWebConfigModificationType)Enum.Parse(typeof(SPWebConfigModification.SPWebConfigModificationType), definition.Type); config.Value = definition.Value; }
private void DeployDefinition(WebApplicationModelHost modelHost, SPWebApplication webApp, WebConfigModificationDefinition definition) { var existingWebConfig = GetCurrentSPWebConfigModification(webApp, definition); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = existingWebConfig, ObjectType = typeof(SPWebConfigModification), ObjectDefinition = definition, ModelHost = modelHost }); if (existingWebConfig != null) webApp.WebConfigModifications.Remove(existingWebConfig); existingWebConfig = new SPWebConfigModification(); MapConfig(existingWebConfig, definition); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = existingWebConfig, ObjectType = typeof(SPWebConfigModification), ObjectDefinition = definition, ModelHost = modelHost }); webApp.WebConfigModifications.Add(existingWebConfig); webApp.Update(); //webApp.Farm.Services.GetValue<SPWebService>().ApplyWebConfigModifications(); webApp.WebService.ApplyWebConfigModifications(); }
public static ModelNode AddWebConfigModification(this ModelNode model, WebConfigModificationDefinition definition, Action<ModelNode> action) { return model.AddDefinitionNode(definition, action); }
public static ModelNode AddWebConfigModification(this ModelNode model, WebConfigModificationDefinition definition) { return AddWebConfigModification(model, definition, null); }
protected SPWebConfigModification GetCurrentSPWebConfigModification(SPWebApplication webApp, WebConfigModificationDefinition definition) { return webApp.WebConfigModifications.FirstOrDefault(c => c.Owner == definition.Owner); }