示例#1
0
        private void DeployPrefix(SPWebApplication webApp, PrefixDefinition prefixDefinition)
        {
            var prefixes = webApp.Prefixes;
            var existingPrefix = GetPrefix(webApp, prefixDefinition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = existingPrefix,
                ObjectType = typeof(SPPrefix),
                ObjectDefinition = prefixDefinition,
                ModelHost = webApp
            });

            if (existingPrefix == null)
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new prefix");

                var prefixType = (SPPrefixType)Enum.Parse(typeof(SPPrefixType), prefixDefinition.PrefixType, true);
                existingPrefix = webApp.Prefixes.Add(prefixDefinition.Path, prefixType);
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing prefix");
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = existingPrefix,
                ObjectType = typeof(SPPrefix),
                ObjectDefinition = prefixDefinition,
                ModelHost = webApp
            });

        }
示例#2
0
 public static ModelNode AddPrefix(this ModelNode model, PrefixDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }
示例#3
0
 protected SPPrefix GetPrefix(SPWebApplication webApp, PrefixDefinition prefixDefinition)
 {
     var prefixes = webApp.Prefixes;
     return prefixes.FirstOrDefault(p => p.Name.ToUpper() == prefixDefinition.Path.ToUpper());
 }
示例#4
0
 public static ModelNode AddPrefix(this ModelNode model, PrefixDefinition definition)
 {
     return AddPrefix(model, definition, null);
 }