public void ShouldNotDeploy_CSOM_ListItemFieldValue_WithFieldId()
        {
            var hasException = false;

            var def = new ListItemFieldValueDefinition
            {
                FieldId = BuiltInFieldId.Title,
                Value = Rnd.String()
            };

            try
            {
                var handler = new SPMeta2.CSOM.ModelHandlers.ListItemFieldValueModelHandler();

                handler.DeployModel(null, def);
            }
            catch (Exception ex)
            {
                Assert.IsTrue(ex.GetType() == typeof(SPMeta2NotSupportedException));
                Assert.IsTrue(ex.Message.Contains("ListItemFieldValueDefinition.FieldId"));

                hasException = true;
            }

            Assert.IsTrue(hasException);
        }
        private void ProcessFieldValue(ListItemFieldValueModelHost modelHost, ListItem listItem, ListItemFieldValueDefinition fieldValue)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = listItem,
                ObjectType = typeof(ListItem),
                ObjectDefinition = fieldValue,
                ModelHost = modelHost
            });

            if (!string.IsNullOrEmpty(fieldValue.FieldName))
            {
                listItem[fieldValue.FieldName] = fieldValue.Value;
            }

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

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

                listItem[fieldValue.FieldId.Value] = fieldValue.Value;
            }
            else 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;
            }
            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 ProcessFieldValue(ListItemModelHost modelHost, ListItem listItem, ListItemFieldValueDefinition fieldValue)
        {
            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = listItem,
                ObjectType = typeof(ListItem),
                ObjectDefinition = fieldValue,
                ModelHost = modelHost
            });

            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 = fieldValue,
                ModelHost = modelHost
            });
        }
 public static ModelNode AddListItemFieldValue(this ModelNode model, ListItemFieldValueDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }
 public static ModelNode AddListItemFieldValue(this ModelNode model, ListItemFieldValueDefinition definition)
 {
     return AddListItemFieldValue(model, definition, null);
 }
 private void ValidateFieldValue(SPListItem host, SPListItem list, ListItemFieldValueDefinition fieldValueModel)
 {
     // TODO
 }
 private void ValidateFieldValue(Microsoft.SharePoint.Client.ListItem listItem, ListItemFieldValueDefinition fieldValue)
 {
     // TODO
 }