private bool PrepareAddUpdateMetaData(IPage selectedPage, IDictionary <string, IData> dataToAdd, IDictionary <string, IData> dataToUpdate) { var isValid = ValidateBindings(); IEnumerable <IPageMetaDataDefinition> pageMetaDataDefinitions = selectedPage.GetAllowedMetaDataDefinitions().Evaluate(); foreach (var pageMetaDataDefinition in pageMetaDataDefinitions) { var dataTypeDescriptor = DynamicTypeManager.GetDataTypeDescriptor(pageMetaDataDefinition.MetaDataTypeId); var metaDataType = TypeManager.GetType(dataTypeDescriptor.TypeManagerTypeName); var helper = CreateDataTypeDescriptorFormsHelper(pageMetaDataDefinition, dataTypeDescriptor); var metaData = selectedPage.GetMetaData(pageMetaDataDefinition.Name, metaDataType); if (metaData == null) { var newData = DataFacade.BuildNew(metaDataType); PageMetaDataFacade.AssignMetaDataSpecificValues(newData, pageMetaDataDefinition.Name, selectedPage); var localizedData = newData as ILocalizedControlled; if (localizedData != null) { localizedData.SourceCultureName = UserSettings.ActiveLocaleCultureInfo.Name; } if (!BindAndValidate(helper, newData)) { isValid = false; } dataToAdd.Add(helper.BindingNamesPrefix, newData); } else { if (!BindAndValidate(helper, metaData)) { isValid = false; } dataToUpdate.Add(helper.BindingNamesPrefix, metaData); } } var pageValidationResults = ValidationFacade.Validate(selectedPage); if (!pageValidationResults.IsValid) { isValid = false; } foreach (var kvp in dataToAdd.Concat(dataToUpdate)) { var validationResults = ValidationFacade.Validate(kvp.Value); if (!validationResults.IsValid) { isValid = false; foreach (var result in validationResults) { ShowFieldMessage(DataTypeDescriptorFormsHelper.GetBindingName(kvp.Key, result.Key), result.Message); } } } return(isValid); }