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);
     }
 }
 ModelDriverResult IModelDriver.BuildEditor(ModelEditorShapeContext context)
 {
     if (context.Model is T)
     {
         return(Editor((T)context.Model, context.New, context));
     }
     return(null);
 }
 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
     });
 }
 public override void Apply(ModelEditorShapeContext context)
 {
     context.ChainedResults.Add(new ModelChainContext()
     {
         Model = _model,
         Root = _shape,
         ShapeType = _shapeType,
         DisplayType = _displayType,
         Prefix = _prefix
     });
 }
 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);
        }
        /// <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
        }
 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);
 }
 protected abstract ModelDriverResult Update(T model, dynamic shapeHelper, IUpdateModel updater, ModelEditorShapeContext context);
 public virtual void Apply(ModelEditorShapeContext context) { }
 public override void Apply(ModelEditorShapeContext context) {
     ApplyImplementation(context, context.DisplayType);
 }
 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))));
 }