-
Notifications
You must be signed in to change notification settings - Fork 33
Add PropertyValueType attribute to help models builder #49 #51
Conversation
|
Guess this means single item mode won't work properly then as our resolver can resolve multiple value types. |
|
@zpqrtbnk Can you offer any advice on how we could handle multiple value types? e.g. our ValueConverter could return either an |
|
I imagine two property value converters would be needed. However the "IsConverter" method has no context of value so it could not be done at run time. I suppose it opens the discussion into if a single property editor should be returning two different types though. Its easy in code to .FirstOrDefault() if you know there is only going to be one. but that's a breaking change now. |
|
Yea. Guess it just sucks as these are new rules that weren't a requirement
previously.
Yes we could just return enumerable, but would make the code a bit uglier.
Don't think it'll be possible to have converters for the same PE though.
|
|
@mattbrailsford it may be possible just looking at the converter actually. the single return works on min/max item pre-values so splitting the converter in two should be possible. I have 30 mins if you want me to look at another pull request? |
|
Who am I to stop you :)
|
|
@cwjackso By all means, please do 😎 |
…n items are set to 1. Also added 3 static extensions to PublishedPropertyType to stay DRY
|
Ok, that works nicely! I've pulled some logic out into static extensions but thought that would be cleaner than extending the converter? Thanks |
|
Have you tested it in non-models builder manner? ie, from within a normal view can you still do Model.GetPropertyValue< IEnumerable< IPublishedContent>>("alias") and Model.GetPropertyValue< IPublishedContent>("alias") |
|
@mattbrailsford I think they should be okay, as (Sorry if I'm teaching you to suck eggs 😊) |
|
@cwjackso Good work, we'll review as soon as we can. |
|
It's cool, I'm just throwing things out there as they come to mind, not really with any backing :) |
|
Nice work @cwjackso though on such a fast fix |
|
Like a fool I only tested the model building and hadn't tested the retrieval at all. I wasn't returning the converted value in either converter! The last commit is now tested for retrieval via both strong typed model and .GetPrpertyValue(). As @leekelleher says they are essentially the same thing though. Thanks |
|
Never hurts to double check :) Nice work fella 👏 |
Add PropertyValueType attribute to help models builder #49
No description provided.