コード例 #1
0
 public async Task UpdateEditorAsync(UpdateEditorContext context)
 {
     await _drivers.InvokeAsync(
         driver => driver.UpdateEditorAsync(context, _modelUpdaterAccessor.ModelUpdater),
         Logger
         );
 }
コード例 #2
0
 public Task UpdateEditorAsync(UpdateEditorContext context, IModelUpdater modelUpdater)
 {
     return _drivers.InvokeAsync(async driver => {
         var result = await driver.UpdateEditorAsync(context, modelUpdater);
         if (result != null)
             result.Apply(context);
     }, Logger);
 }
コード例 #3
0
ファイル: TestContentDisplay.cs プロジェクト: wangan/Orchard2
        public override async Task UpdateEditorAsync(UpdateEditorContext context, IModelUpdater updater)
        {
            var testContentPart = context.Content.As<TestContentPartA>();

            if (testContentPart == null)
            {
                return;
            }

            if(await updater.TryUpdateModelAsync(testContentPart, ""))
            {
                context.Content.ContentItem.Weld(testContentPart);
            }

            return;
        }
コード例 #4
0
        public override async Task<DisplayResult> UpdateEditorAsync(UpdateEditorContext context, IModelUpdater updater)
        {
            var testContentPart = context.Content.As<TestContentPartA>();

            if (testContentPart == null)
            {
                return null;
            }

            if (await updater.TryUpdateModelAsync(testContentPart, ""))
            {
                if (testContentPart.Line.EndsWith(" "))
                {
                    updater.ModelState.AddModelError(nameof(testContentPart.Line), "Value cannot end with a space");
                }
                else
                {
                    context.Content.ContentItem.Weld(testContentPart);
                }
            }
            
            return Shape("TestContentPartA_Edit", testContentPart).Location("Content");
        }
コード例 #5
0
ファイル: ContentDisplay.cs プロジェクト: wangan/Orchard2
        public async Task<dynamic> BuildEditorAsync(IContent content, string groupId)
        {
            if (content == null || content.ContentItem == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(content.ContentItem.ContentType);

            JToken stereotype;
            if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype))
            {
                stereotype = "Content";
            }

            var actualShapeType = stereotype + "_Edit";

            dynamic itemShape = CreateContentShape(actualShapeType);
            itemShape.ContentItem = content.ContentItem;

            // adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
            ((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);

            var context = new UpdateEditorContext(itemShape, content, groupId, _shapeFactory);
            await BindPlacementAsync(context, null, stereotype.Value<string>());

            await _handlers.InvokeAsync(handler => handler.BuildEditorAsync(context), Logger);


            return context.Shape;
        }