This project is read-only.

[Development] shareHelper.EditorTemplate

Topics: General
May 17, 2013 at 8:56 AM

I create my first driver and I notice I need to override the Editor(Models.PoiPart part, dynamic shapeHelper), the page proposes to use as function dynamic shapeHelper.EditorTemplate.
It's a dynamic method, how can I know I need to use this existing method without to read the help page?
     return ContentShape("Parts_Map_Edit",
                () => shapeHelper.EditorTemplate(
                    TemplateName: "Parts/Map",
                    Model: part,
                    Prefix: Prefix));
best regards,
May 17, 2013 at 1:40 PM
You can't, that's the downside of dynamic :-). When in doubt, you can also take a look at built-in modules how to use APIs.
May 17, 2013 at 2:16 PM
Hum :(
Not a good news, but I will work with this assumption.
May 23, 2013 at 1:24 PM

I search a solution to customize the render from a page with many item.
So I read the documentation provided on
, this one two
And try to understand the code :
        public ContentShapeResult ContentShape(string shapeType, Func<dynamic, dynamic> factory) {
            return ContentShapeImplementation(shapeType, ctx => factory(CreateShape(ctx, shapeType)));
I'm not sure I understand really how it uses Func<dynamic, dynamic> factory when I look "ctx => factory(CreateShape(ctx, shapeType))"
A func is a delegate with one parameter dynamic and a result parameter dynamic too.
So my assumption is ctx is the current instance, I pass the current instance + shapeType to the method CreateShape, this one return a dynamic object.
And a call to this method is done ContentShapeResult ContentShapeImplementation(string shapeType, Func<BuildShapeContext, object> shapeBuilder)

OK nice, but... it''s not clear how your mind decides to develop like that, it's really difficult to follow. There is a big walking stairs to overpass.
I would like to understand how I can evolve my knowledge and developer spirit to go in this way.
Do you have any documentation or something to share? because when you pass a fun<dynamic> + object dynamic, it's really hard to follow.
May 23, 2013 at 2:26 PM
That delegate is a shape factory. We use it instead of directly wrapping the shape into a result because this way if the shape is not displayed (because e.g. it's hidden from Placement), the delegate is not run either. So put any costly computation into the delegate that produces values that you only need in your shape.

See the Training Demo module's relevant sample.
May 24, 2013 at 7:36 AM
Thank you, I take a look and it sounds good :)