コード例 #1
0
 public void BuildEditorShape(object model, dynamic root, Orchard.ContentManagement.IUpdateModel updater, string prefix, string displayType, string stereotype, ModelShapeContext parentContext = null)
 {
     var context = new ModelEditorShapeContext(model, root, Shape, prefix, displayType, updater, parentContext);
     BindPlacement(context, displayType, stereotype);
     foreach (var driver in Drivers)
     {
         ModelDriverResult result = null;
         if (updater != null)
         {
             result = driver.UpdateEditor(context);
         }
         else {
             result = driver.BuildEditor(context);
         }
         // Null check, there must be a performance advantage to not instancing loads of empty ModelDriverResults
         if (result != null)
         {
             result.Apply(context);
         }
     }
     // Chain sub results?
     // They are applied to the same base object (as opposed to rendering an entirely new shape with its own zones)
     foreach (var chain in context.ChainedResults)
     {
         BuildEditorShape(chain.Model, chain.Root ?? root, updater, chain.Prefix, chain.DisplayType ?? displayType, stereotype, context);
         // Fire an event so parent shape can perform work after the update
         chain.OnCompleted(context);
     }
     // Invoke Updated event now all drivers have been executed
     if (updater != null)
     {
         context.InvokeUpdated();
     }
     // Done
 }
コード例 #2
0
 public override void Apply(ModelEditorShapeContext context)
 {
     foreach (var result in _results)
     {
         result.Apply(context);
     }
 }
コード例 #3
0
 ModelDriverResult IModelDriver.BuildEditor(ModelEditorShapeContext context)
 {
     if (context.Model is T)
     {
         return(Editor((T)context.Model, context.New, context));
     }
     return(null);
 }
コード例 #4
0
 ModelDriverResult IModelDriver.UpdateEditor(ModelEditorShapeContext context)
 {
     if (context.Model is T)
     {
         return(Update((T)context.Model, context.New, context.Updater, context));
     }
     return(null);
 }
コード例 #5
0
 public override void Apply(ModelEditorShapeContext context)
 {
     context.ChainedResults.Add(new ModelChainContext()
     {
         Model       = _model,
         Root        = _shape,
         ShapeType   = _shapeType,
         DisplayType = _displayType,
         Prefix      = _prefix
     });
 }
コード例 #6
0
 public override void Apply(ModelEditorShapeContext context)
 {
     context.ChainedResults.Add(new ModelChainContext()
     {
         Model = _model,
         Root = _shape,
         ShapeType = _shapeType,
         DisplayType = _displayType,
         Prefix = _prefix
     });
 }
コード例 #7
0
 public override void Apply(ModelEditorShapeContext context)
 {
     var chain = new ModelChainContext()
     {
         Model = _model,
         Prefix = _prefix
     };
     if (_onCompleted != null)
     {
         chain.Completed += _onCompleted;
     }
     context.ChainedResults.Add(chain);
 }
コード例 #8
0
        public override void Apply(ModelEditorShapeContext context)
        {
            var chain = new ModelChainContext()
            {
                Model  = _model,
                Prefix = _prefix
            };

            if (_onCompleted != null)
            {
                chain.Completed += _onCompleted;
            }
            context.ChainedResults.Add(chain);
        }
コード例 #9
0
        /// <summary>
        /// Build prefix for template, using parent prefix if available
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public String FullPrefix(ModelEditorShapeContext context, string fieldName = null)
        {
            var prefix = Prefix;

            if (!String.IsNullOrWhiteSpace(context.Prefix))
            {
                prefix = context.Prefix + "." + prefix;
            }
            if (!String.IsNullOrWhiteSpace(fieldName))
            {
                prefix = prefix + "." + fieldName;
            }
            return(prefix);
        }
コード例 #10
0
        public void BuildEditorShape(object model, dynamic root, Orchard.ContentManagement.IUpdateModel updater, string prefix, string displayType, string stereotype, ModelShapeContext parentContext = null)
        {
            var context = new ModelEditorShapeContext(model, root, Shape, prefix, displayType, updater, parentContext);

            BindPlacement(context, displayType, stereotype);
            foreach (var driver in Drivers)
            {
                ModelDriverResult result = null;
                if (updater != null)
                {
                    result = driver.UpdateEditor(context);
                }
                else
                {
                    result = driver.BuildEditor(context);
                }
                // Null check, there must be a performance advantage to not instancing loads of empty ModelDriverResults
                if (result != null)
                {
                    result.Apply(context);
                }
            }
            // Chain sub results?
            // They are applied to the same base object (as opposed to rendering an entirely new shape with its own zones)
            foreach (var chain in context.ChainedResults)
            {
                BuildEditorShape(chain.Model, chain.Root ?? root, updater, chain.Prefix, chain.DisplayType ?? displayType, stereotype, context);
                // Fire an event so parent shape can perform work after the update
                chain.OnCompleted(context);
            }
            // Invoke Updated event now all drivers have been executed
            if (updater != null)
            {
                context.InvokeUpdated();
            }
            // Done
        }
コード例 #11
0
 protected abstract ModelDriverResult Editor(T model, dynamic shapeHelper, ModelEditorShapeContext context);
コード例 #12
0
 public virtual void Apply(ModelEditorShapeContext context)
 {
 }
コード例 #13
0
 public override void Apply(ModelEditorShapeContext context)
 {
     ApplyImplementation(context, context.DisplayType);
 }
コード例 #14
0
 protected abstract ModelDriverResult Update(T model, dynamic shapeHelper, IUpdateModel updater, ModelEditorShapeContext context);
コード例 #15
0
 public virtual void Apply(ModelEditorShapeContext context) { }
コード例 #16
0
 public override void Apply(ModelEditorShapeContext context) {
     ApplyImplementation(context, context.DisplayType);
 }
コード例 #17
0
 public ModelDriverResult EditorShape(string shapeType, object model, ModelEditorShapeContext context)
 {
     return(ContentShapeImplementation(shapeType, FullPrefix(context), (ctx) => context.New.EditorTemplate(TemplateName: shapeType.Replace('_', '.'), Model: model, Prefix: FullPrefix(context))));
 }