本文整理汇总了C#中IUpdateModel.TryUpdateModel方法的典型用法代码示例。如果您正苦于以下问题:C# IUpdateModel.TryUpdateModel方法的具体用法?C# IUpdateModel.TryUpdateModel怎么用?C# IUpdateModel.TryUpdateModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IUpdateModel
的用法示例。
在下文中一共展示了IUpdateModel.TryUpdateModel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypePartEditorUpdate
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
if (builder.Name != typeof (TermPart).Name) yield break;
var settings = new ExtraTermPartSettings();
updateModel.TryUpdateModel(settings, typeof (ExtraTermPartSettings).Name, null, null);
builder.WithSetting("ExtraTermPartSettings.OnlyDirectChildren", settings.OnlyDirectChildren.ToString());
}
示例2: PartFieldEditorUpdate
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
{
if (!builder.FieldType.Equals(typeof(MoneyField).Name)) yield break;
var model = new MoneyFieldSettings();
if (updateModel.TryUpdateModel(model, typeof(MoneyFieldSettings).Name, null, null))
{
if (string.IsNullOrEmpty(model.DefaultCurrency))
{
builder.WithSetting("MoneyFieldSettings.DefaultCurrency", Currency.FromCurrentCulture().Iso3LetterCode);
}
else
{
Currency parsedCurrency;
if (Currency.TryParse(model.DefaultCurrency, out parsedCurrency))
{
builder.WithSetting("MoneyFieldSettings.DefaultCurrency", model.DefaultCurrency);
}
else
{
updateModel.AddModelError("InvalidCurrencyIsoCode", T("MoneyField - Invalid currency iso code was given."));
}
}
builder.WithSetting("MoneyFieldSettings.IsCurrencyReadOnly", model.IsCurrencyReadOnly.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("MoneyFieldSettings.Hint", model.Hint);
builder.WithSetting("MoneyFieldSettings.Required", model.Required.ToString(CultureInfo.InvariantCulture));
}
yield return DefinitionTemplate(model);
}
示例3: PartEditorUpdate
public override IEnumerable<TemplateViewModel> PartEditorUpdate(ContentPartDefinitionBuilder builder, IUpdateModel updateModel)
{
var model = new ContentPartSettings();
updateModel.TryUpdateModel(model, "ContentPartSettings", null, null);
builder.Attachable(model.Attachable);
yield return DefinitionTemplate(model);
}
示例4: TypePartEditorUpdate
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel)
{
if (builder.Name != "RelatedContentPart") yield break;
var viewModel = new PropertyFieldsViewModel();
updateModel.TryUpdateModel(viewModel, "PropertyFieldsViewModel", null, null);
var settings = new RelatedContentRelationshipSettings();
foreach (var relationshipFieldsModel in viewModel.Fields)
{
settings.DisplayName += String.Format("<field>{0}</field>", relationshipFieldsModel.DisplayName);
settings.RelatedContentFields += String.Format("<field>{0}</field>", relationshipFieldsModel.RelatedContentFields);
settings.RelatedcontentType += String.Format("<field>{0}</field>", relationshipFieldsModel.RelatedcontentType);
}
builder.WithSetting("RelatedContentRelationshipSettings.RelatedcontentType",
settings.RelatedcontentType);
builder.WithSetting("RelatedContentRelationshipSettings.RelatedContentFields",
settings.RelatedContentFields);
builder.WithSetting("RelatedContentRelationshipSettings.DisplayName",
settings.DisplayName);
var model = GetModel(settings);
yield return DefinitionTemplate(model);
}
示例5: PartFieldEditorUpdate
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
if (builder.FieldType != "ReferenceField") {
yield break;
}
var model = new ReferenceFieldSettings();
if (updateModel.TryUpdateModel(model, "ReferenceFieldSettings", null, null)) {
UpdateSettings(model, builder, "ReferenceFieldSettings");
if (model.QueryId <= 0) {
model.QueryId = CreateQuery(model.ContentTypeName.ToString(CultureInfo.InvariantCulture));
}
if (model.RelationshipId <= 0) {
var httpContext = _httpContextAccessor.Current();
var routeValues = httpContext.Request.RequestContext.RouteData.Values;
var entityName = routeValues["id"].ToString();
model.RelationshipId = _relationshipService.CreateOneToManyRelationship(builder.Name, model.RelationshipName, model.ContentTypeName, entityName);
}
if (model.QueryId <= 0 || model.RelationshipId <= 0) {
updateModel.AddModelError("QueryOrRelation", T("Invalid Query or Relationship Id"));
yield break;
}
UpdateSettings(model, builder, "ReferenceFieldSettings");
builder.WithSetting("ReferenceFieldSettings.DisplayAsLink", model.DisplayAsLink.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("ReferenceFieldSettings.ContentTypeName", model.ContentTypeName.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("ReferenceFieldSettings.RelationshipName", model.RelationshipName.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("ReferenceFieldSettings.RelationshipId", model.RelationshipId.ToString(CultureInfo.InvariantCulture));
builder.WithSetting("ReferenceFieldSettings.QueryId", model.QueryId.ToString(CultureInfo.InvariantCulture));
}
yield return DefinitionTemplate(model);
}
示例6: TypeEditorUpdate
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
var model = new SecurableContentItemsSettingsViewModel();
updateModel.TryUpdateModel(model, "SecurableContentItemsSettingsViewModel", null, null);
builder.WithSetting("ContentPermissionsTypeSettings.SecurableContentItems", model.SecurableContentItems.ToString());
yield return DefinitionTemplate(model);
}
示例7: TypeEditorUpdate
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
var model = new ContentTypeSettings();
updateModel.TryUpdateModel(model, "ContentTypeSettings", null, null);
builder.Creatable(model.Creatable);
builder.Draftable(model.Draftable);
yield return DefinitionTemplate(model);
}
示例8: TypeEditorUpdate
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel)
{
var model = new AssociativyTaxonomiesAdapterTypeSettings();
updateModel.TryUpdateModel(model, "AssociativyTaxonomiesAdapterTypeSettings", null, null);
builder.WithSetting("AssociativyTaxonomiesAdapterTypeSettings.GraphNamesSerialized", model.GraphNamesSerialized);
yield return DefinitionTemplate(model);
}
示例9: PartFieldEditorUpdate
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
var model = new DateTimeFieldSettings();
if(updateModel.TryUpdateModel(model, "DateTimeFieldSettings", null, null)) {
builder.WithSetting("DateTimeFieldSettings.Display", model.Display.ToString());
}
yield return DefinitionTemplate(model);
}
示例10: TypeEditorUpdate
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
var model = new ExperimentalSettings();
updateModel.TryUpdateModel(model, "ExperimentalSettings", null, null);
builder
.WithSetting("ExperimentalSettings.ShowDebugLinks", model.ShowDebugLinks ? true.ToString() : null);
yield return DefinitionTemplate(model);
}
示例11: PartFieldEditorUpdate
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel) {
var model = new FieldIndexing();
updateModel.TryUpdateModel(model, "FieldIndexing", null, null);
builder.WithSetting("FieldIndexing.Included", model.Included ? true.ToString() : null);
CreateIndexingTasks();
yield return DefinitionTemplate(model);
}
示例12: TypeEditorUpdate
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel) {
var model = new TypeIndexing();
updateModel.TryUpdateModel(model, "TypeIndexing", null, null);
builder.WithSetting("TypeIndexing.Indexes", model.Indexes);
CreateIndexingTasks();
yield return DefinitionTemplate(model);
}
示例13: PartFieldEditorUpdate
public override IEnumerable<TemplateViewModel> PartFieldEditorUpdate(ContentPartFieldDefinitionBuilder builder, IUpdateModel updateModel)
{
var model = new HtmlFieldSettings();
if (updateModel.TryUpdateModel(model, "HtmlFieldSettings", null, null)) {
builder.WithSetting("HtmlFieldSettings.FlavorDefault", model.FlavorDefault);
}
yield return DefinitionTemplate(model);
}
示例14: TypePartEditorUpdate
public override IEnumerable<TemplateViewModel> TypePartEditorUpdate(ContentTypePartDefinitionBuilder builder, IUpdateModel updateModel) {
if (builder.Name != typeof(AuthorablePart).Name) yield break;
var model = new AuthorablePartSettings();
updateModel.TryUpdateModel(model, typeof (AuthorablePartSettings).Name, null, null);
builder.WithSetting(string.Format("{0}.{1}", typeof(AuthorablePartSettings).Name, model.AutomaticallyAssignEditorToAuthors.GetType().Name), model.AutomaticallyAssignEditorToAuthors.ToString());
yield return DefinitionTemplate(model);
}
示例15: TypeEditorUpdate
public override IEnumerable<TemplateViewModel> TypeEditorUpdate(ContentTypeDefinitionBuilder builder, IUpdateModel updateModel)
{
var model = new DynamicTypeSettingsViewModel();
updateModel.TryUpdateModel(model, "DynamicTypeSettingsViewModel", null, null);
builder.WithSetting("DynamicTypeSettings.IsDeployed", model.IsDeployed.ToString());
yield return DefinitionTemplate(model);
}