本文整理汇总了C#中IPage.GetAllowedMetaDataDefinitions方法的典型用法代码示例。如果您正苦于以下问题:C# IPage.GetAllowedMetaDataDefinitions方法的具体用法?C# IPage.GetAllowedMetaDataDefinitions怎么用?C# IPage.GetAllowedMetaDataDefinitions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPage
的用法示例。
在下文中一共展示了IPage.GetAllowedMetaDataDefinitions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareAddUpdateMetaData
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;
}