private void DeployDefinition(object modelHost, SPWeb web, SearchSettingsDefinition definition)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = web,
                ObjectType = typeof(SPWeb),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            ProcessObject(web, definition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = web,
                ObjectType = typeof(SPWeb),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            web.Update();
        }
 public static ModelNode AddSearchSettings(this ModelNode model, SearchSettingsDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }
 public static ModelNode AddSearchSettings(this ModelNode model, SearchSettingsDefinition definition)
 {
     return AddSearchSettings(model, definition, null);
 }
        private void DeployAtWebLevel(object modelHost, Web web, SearchSettingsDefinition definition)
        {
            var csomModelHost = modelHost.WithAssertAndCast<CSOMModelHostBase>("modelHost", value => value.RequireNotNull());

            var context = web.Context;

            context.Load(web);
            context.Load(web, w => w.AllProperties);

            context.ExecuteQueryWithTrace();

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = web,
                ObjectType = typeof(Web),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            var searchSettings = GetCurrentSearchConfigAtWebLevel(web);

            if (searchSettings != null)
            {
                if (definition.UseParentResultsPageUrl.HasValue)
                    searchSettings.Inherit = definition.UseParentResultsPageUrl.Value;

                if (!string.IsNullOrEmpty(definition.UseCustomResultsPageUrl))
                {
                    var url = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
                    {
                        Context = csomModelHost,
                        Value = definition.UseCustomResultsPageUrl
                    }).Value;

                    searchSettings.ResultsPageAddress = url;
                }

                SetCurrentSearchConfigAtWebLevel(csomModelHost, web, searchSettings);
            }

            if (!string.IsNullOrEmpty(definition.SearchCenterUrl))
            {
                SetSearchCenterUrlAtWebLevel(csomModelHost, web, definition.SearchCenterUrl);
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = web,
                ObjectType = typeof(Web),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            web.Update();
            context.ExecuteQueryWithTrace();
        }
 private void ProcessObject(SPWeb web, SearchSettingsDefinition definition)
 {
     // web.AllProperties["SRCH_ENH_FTR_URL_SITE"] = string.
 }
        private void DeployAtWebLevel(object modelHost, SPWeb web, SearchSettingsDefinition definition)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = web,
                ObjectType = typeof(SPWeb),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            if (!string.IsNullOrEmpty(definition.SearchCenterUrl))
            {
                SetSearchCenterUrlAtWebLevel(web, definition.SearchCenterUrl);
            }

            var searchSettings = GetCurrentSearchConfigAtWebLevel(web);

            if (searchSettings != null)
            {
                if (definition.UseParentResultsPageUrl.HasValue)
                    searchSettings.Inherit = definition.UseParentResultsPageUrl.Value;

                if (!string.IsNullOrEmpty(definition.UseCustomResultsPageUrl))
                {
                    var url = TokenReplacementService.ReplaceTokens(new TokenReplacementContext
                    {
                        Context = web,
                        Value = definition.UseCustomResultsPageUrl
                    }).Value;

                    searchSettings.ResultsPageAddress = url;
                }

                SetCurrentSearchConfigAtWebLevel(web, searchSettings);
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = web,
                ObjectType = typeof(SPWeb),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });

            web.Update();
        }