本文整理汇总了C#中IUpdateModel类的典型用法代码示例。如果您正苦于以下问题:C# IUpdateModel类的具体用法?C# IUpdateModel怎么用?C# IUpdateModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IUpdateModel类属于命名空间,在下文中一共展示了IUpdateModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateTypeEditorAsync
public Task<dynamic> UpdateTypeEditorAsync(ContentTypeDefinition contentTypeDefinition, IUpdateModel updater, string groupId)
{
if (contentTypeDefinition == null)
{
throw new ArgumentNullException(nameof(contentTypeDefinition));
}
dynamic contentTypeDefinitionShape = CreateContentShape("ContentTypeDefinition_Edit");
contentTypeDefinitionShape.ContentTypeDefinition = contentTypeDefinition;
_contentDefinitionManager.AlterTypeDefinition(contentTypeDefinition.Name, typeBuilder =>
{
var typeContext = new UpdateTypeEditorContext(
typeBuilder,
contentTypeDefinitionShape,
groupId,
_shapeFactory,
_layoutAccessor.GetLayout(),
updater
);
BindPlacementAsync(typeContext).Wait();
_handlers.InvokeAsync(handler => handler.UpdateTypeEditorAsync(contentTypeDefinition, typeContext), Logger).Wait();
});
return Task.FromResult<dynamic>(contentTypeDefinitionShape);
}
示例2: UpdateSettings
public dynamic UpdateSettings(IUpdateModel updater)
{
var settings = _contentManager.Get<SeoGlobalSettingsPart>(GetGlobalSettings().ContentItem.Id, VersionOptions.DraftRequired);
var editor = _contentManager.UpdateEditor(settings, updater);
_contentManager.Publish(settings.ContentItem);
return editor;
}
示例3: FilterAsync
public async Task FilterAsync(IQuery<ContentItem> query, ListContentsViewModel model, PagerParameters pagerParameters, IUpdateModel updateModel)
{
var viewModel = new ListPartContentAdminFilterModel();
if(await updateModel.TryUpdateModelAsync(viewModel, ""))
{
// Show list content items
if (viewModel.ShowListContentTypes)
{
var listableTypes = _contentDefinitionManager
.ListTypeDefinitions()
.Where(x =>
x.Parts.Any(p =>
p.PartDefinition.Name == nameof(ListPart)))
.Select(x => x.Name);
query.With<ContentItemIndex>(x => x.ContentType.IsIn(listableTypes));
}
// Show contained elements for the specified list
else if(viewModel.ListContentItemId != 0)
{
query.With<ContainedPartIndex>(x => x.ListContentItemId == viewModel.ListContentItemId);
}
}
}
示例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: Display
public override IDisplayResult Display(ContentItem contentItem, IUpdateModel updater)
{
var testContentPart = contentItem.As<TestContentPartA>();
if (testContentPart == null)
{
return null;
}
return Combine(
// A new shape is created and the properties of the object are bound to it when rendered
Shape("TestContentPartA", testContentPart).Location("Detail", "Content"),
// New shape, no initialization, custom location
Shape("LowerDoll").Location("Detail", "Footer"),
// New shape
Shape("TestContentPartA",
ctx => ctx.New.TestContentPartA().Creating(_creating++),
shape =>
{
shape.Processing = _processing++;
return Task.CompletedTask;
})
.Location("Detail", "Content")
.Cache("lowerdoll2", cache => cache.During(TimeSpan.FromSeconds(5))),
// A strongly typed shape model is used and initialized when rendered
Shape<TestContentPartAShape>(shape => { shape.Line = "Strongly typed shape"; return Task.CompletedTask; })
.Location("Detail", "Content:2"),
// Cached shape
Shape("LowerDoll")
.Location("Detail", "/Footer")
.Cache("lowerdoll", cache => cache.During(TimeSpan.FromSeconds(5)))
);
}
示例6: 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);
}
示例7: 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);
}
示例8: UpdateEditor
public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupInfoId) {
var contentKey = "ContentUpdate:" + content.Id.ToString();
_profiler.StepStart(contentKey, String.Format("Content Update: {0}", content.Id));
var result = _innerContentDisplay.UpdateEditor(content, updater, groupInfoId);
_profiler.StepStop(contentKey);
return result;
}
示例9: UpdateEditor
public dynamic UpdateEditor(IContent content, IUpdateModel updater, string groupId = "") {
var shape = _origami.ContentShape(content, "", true);
var builder = _origami.ContentBuilder(content).WithMode("Editor").WithUpdater(updater, "");
if (!String.IsNullOrWhiteSpace(groupId)) builder.WithGroup(groupId);
_origami.Build(builder, shape);
return shape;
}
示例10: 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);
}
示例11: UpdateEditorContext
public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable, string path)
: base(model, content, groupInfoId, shapeFactory) {
ShapeTable = shapeTable;
Updater = updater;
Path = path;
}
示例12: 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());
}
示例13: 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);
}
示例14: 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);
}
示例15: 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);
}