private void ProcessFieldValue(object modelHost, SPListItem listItem, ListItemFieldValuesDefinition fieldValue)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = listItem,
                ObjectType = typeof(SPListItem),
                ObjectDefinition = fieldValue,
                ModelHost = modelHost
            });

            foreach (var value in fieldValue.Values)
            {
                if (value.FieldId.HasGuidValue())
                {
                    TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Processing field value with ID: [{0}] and value: [{1}]",
                       new object[]
                    {
                        value.FieldId,
                        value.Value
                    });

                    listItem[value.FieldId.Value] = value.Value;
                }
                else if (!string.IsNullOrEmpty(value.FieldName))
                {
                    TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall, "Processing field value with Name: [{0}] and value: [{1}]",
                       new object[]
                    {
                        value.FieldName,
                        value.Value
                    });

                    listItem[value.FieldName] = value.Value;
                }
                else
                {
                    throw new SPMeta2Exception("Either FieldId or FieldName must be provided.");
                }
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = listItem,
                ObjectType = typeof(SPListItem),
                ObjectDefinition = fieldValue,
                ModelHost = modelHost
            });
        }
        private void ProcessFieldValues(ListItemModelHost modelHost, ListItem listItem, ListItemFieldValuesDefinition fieldValues)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = listItem,
                ObjectType = typeof(ListItem),
                ObjectDefinition = fieldValues,
                ModelHost = modelHost
            });

            foreach (var fieldValue in fieldValues.Values)
            {
                if (!string.IsNullOrEmpty(fieldValue.FieldName))
                {
                    TraceService.VerboseFormat((int)LogEventId.ModelProvisionCoreCall,
                        "Processing field value with Name: [{0}] and value: [{1}]",
                        new object[]
                        {
                            fieldValue.FieldName,
                            fieldValue.Value
                        });

                    listItem[fieldValue.FieldName] = fieldValue.Value;
                }
            }

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = listItem,
                ObjectType = typeof(ListItem),
                ObjectDefinition = fieldValues,
                ModelHost = modelHost
            });
        }
 public static ModelNode AddListItemFieldValues(this ModelNode model, ListItemFieldValuesDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }
 public static ModelNode AddListItemFieldValues(this ModelNode model, ListItemFieldValuesDefinition definition)
 {
     return AddListItemFieldValues(model, definition, null);
 }