コード例 #1
0
 private void ProcessProperty(PropertyModelHost host, PropertyDefinition property)
 {
     if (host.CurrentListItem != null)
         ProcessListItemProperty(host.CurrentListItem, property);
     else if (host.CurrentList != null)
         ProcessListProperty(host.CurrentList, property);
     else if (host.CurrentWeb != null)
         ProcessWebProperty(host.CurrentWeb, property);
 }
コード例 #2
0
        public override ModelNode ReverseSingleHost(object reverseHost, ReverseOptions options)
        {
            var item = (reverseHost as PropertyReverseHost).HostPropertyName;
            var itemValue = (reverseHost as PropertyReverseHost).HostPropertyValue;

            var def = new PropertyDefinition();

            def.Key = item;
            def.Value = itemValue;

            def.Overwrite = true;

            return new PropertyModelNode
            {
                Options = { RequireSelfProcessing = true },
                Value = def
            };
        }
コード例 #3
0
        protected virtual void DeployProperty(object modelHost, PropertyValues properties, PropertyDefinition property)
        {
            var currentValue = properties.FieldValues.ContainsKey(property.Key) ? properties[property.Key] : null;

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

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

                properties[property.Key] = property.Value;

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioned,
                    Object = property.Value,
                    ObjectType = typeof(object),
                    ObjectDefinition = property,
                    ModelHost = modelHost
                });
            }
            else
            {
                TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing property");

                if (property.Overwrite)
                {
                    TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Overwrite = true. Overwriting property.");

                    properties[property.Key] = property.Value;

                    InvokeOnModelEvent(this, new ModelEventArgs
                    {
                        CurrentModelNode = null,
                        Model = null,
                        EventType = ModelEventType.OnProvisioned,
                        Object = property.Value,
                        ObjectType = typeof(object),
                        ObjectDefinition = property,
                        ModelHost = modelHost
                    });
                }
                else
                {
                    TraceService.Verbose((int)LogEventId.ModelProvisionCoreCall, "Overwrite = false. Skipping property.");

                    InvokeOnModelEvent(this, new ModelEventArgs
                    {
                        CurrentModelNode = null,
                        Model = null,
                        EventType = ModelEventType.OnProvisioned,
                        Object = currentValue,
                        ObjectType = typeof(object),
                        ObjectDefinition = property,
                        ModelHost = modelHost
                    });
                }
            }
        }
コード例 #4
0
        public void Deploy_WebProperty()
        {
            // Step 1, define security groups
            var siteType = new PropertyDefinition
            {
                Key = "_site_type",
                Value = "spmeta2 demo"
            };

            var tick = new PropertyDefinition
            {
                Key = "_site_tick",
                Value = Environment.TickCount,
                Overwrite = true
            };

            // Step 2, define web model and artifact relationships - add security groups t the web 
            var model = SPMeta2Model
                             .NewWebModel(web =>
                             {
                                 web
                                     .AddDefinitionNode(siteType)
                                     .AddDefinitionNode(tick);
                             });

            // Step 3, deploy model
            DeployWebModel(model);
        }
コード例 #5
0
        protected virtual void DeployProperty(object modelHost, PropertyValues properties, PropertyDefinition propertyDefinition)
        {
            var currentValue = properties.FieldValues.ContainsKey(propertyDefinition.Key) ? properties[propertyDefinition.Key] : null;

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

            if (currentValue == null)
            {
                properties[propertyDefinition.Key] = propertyDefinition.Value;

                InvokeOnModelEvent(this, new ModelEventArgs
                {
                    CurrentModelNode = null,
                    Model = null,
                    EventType = ModelEventType.OnProvisioned,
                    Object = propertyDefinition.Value,
                    ObjectType = typeof(object),
                    ObjectDefinition = propertyDefinition,
                    ModelHost = modelHost
                });
            }
            else
            {
                if (propertyDefinition.Overwrite)
                {
                    properties[propertyDefinition.Key] = propertyDefinition.Value;

                    InvokeOnModelEvent(this, new ModelEventArgs
                    {
                        CurrentModelNode = null,
                        Model = null,
                        EventType = ModelEventType.OnProvisioned,
                        Object = propertyDefinition.Value,
                        ObjectType = typeof(object),
                        ObjectDefinition = propertyDefinition,
                        ModelHost = modelHost
                    });
                }
                else
                {
                    InvokeOnModelEvent(this, new ModelEventArgs
                    {
                        CurrentModelNode = null,
                        Model = null,
                        EventType = ModelEventType.OnProvisioned,
                        Object = propertyDefinition.Value,
                        ObjectType = typeof(object),
                        ObjectDefinition = propertyDefinition,
                        ModelHost = modelHost
                    });
                }
            }
        }
コード例 #6
0
 public static ModelNode AddProperty(this ModelNode model, PropertyDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }
コード例 #7
0
 public static ModelNode AddProperty(this ModelNode model, PropertyDefinition definition)
 {
     return AddProperty(model, definition, null);
 }