public virtual void ConvertToDataItem(SPItemEventProperties eventProperties, SPGENItemEventPropertiesType collectionType, SPGENRepositoryDataItem dataItem, bool useListItemValueIfNotFound, out IDictionary<string, object> valuesFromEventProperties) { valuesFromEventProperties = new Dictionary<string, object>(); SPItemEventDataCollection collection = collectionType == SPGENItemEventPropertiesType.AfterProperties ? eventProperties.AfterProperties : eventProperties.BeforeProperties; dataItem.ListItem = eventProperties.ListItem; string[] fieldNamesInProperties = null; if (useListItemValueIfNotFound) { fieldNamesInProperties = collection.OfType<DictionaryEntry>().Select(de => de.Key as string).ToArray(); } foreach (string fieldName in dataItem.FieldNames) { object value = null; if (useListItemValueIfNotFound) { if (fieldNamesInProperties.Contains(fieldName, StringComparer.Ordinal)) { value = collection[fieldName]; valuesFromEventProperties.Add(fieldName, value); } else { value = eventProperties.ListItem[fieldName]; } } else { value = collection[fieldName]; valuesFromEventProperties.Add(fieldName, value); } dataItem.FieldValues[fieldName] = value; } }
public virtual void ConvertToDataItem(SPItemEventProperties eventProperties, SPGENItemEventPropertiesType collectionType, SPGENRepositoryDataItem dataItem) { throw new NotSupportedException(); }
public virtual void UpdateEventProperties(SPGENRepositoryDataItem item, SPItemEventProperties eventProperties, SPGENItemEventPropertiesType collectionType) { SPItemEventDataCollection collection = collectionType == SPGENItemEventPropertiesType.AfterProperties ? eventProperties.AfterProperties : eventProperties.BeforeProperties; foreach (string fieldName in item.FieldNames) { if (collection[fieldName] == null) { collection.ChangedProperties.Add(fieldName, item.FieldValues[fieldName]); } else { collection[fieldName] = item.FieldValues[fieldName]; } } }