We have an Umbraco 7.11.1 site with nuPickers 1.7.0.
My goal is to get nuPickers to cooperate with ModelsBuilder really nicely. Right now, all of the nuPicker properties on my ModelsBuilder models are of type nuPickers.Picker. I want them to have the type of the enum that my nuPicker is using as a data source. I have a nuPickers: Enum RadioButton Picker and want the ModelsBuilder model to have a property like this:
///<summary>
/// Left/Right Orientation
///</summary>
[ImplementPropertyType("leftRightOrientation")]
public nuPickers.Picker LeftRightOrientation
{
get { return this.GetPropertyValue<nuPickers.Picker>("leftRightOrientation"); }
}
Unfortunately, there isn't a way to easily get the enum value I want from that nuPickers.Picker. What would be yamazing is if there was a way for me to get ModelsBuilder to generate the property like this. I'm guessing changes would need to be made to the PropertyValueConverter of nuPickers?
///<summary>
/// Left/Right Orientation
///</summary>
[ImplementPropertyType("leftRightOrientation")]
public Models.DatatypePrevalues.LeftRightOrientation LeftRightOrientation
{
get { return this.GetPropertyValue<Models.DatatypePrevalues.LeftRightOrientation>("leftRightOrientation"); }
}
You don't need to create a custom property value converter. You can change the model generation. (https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Control-Generation)
What you need to do is create a partial class with the same name as the generated model in the same folder where the models are generated by Models builder.
In this class you can than define a property like this :
[ImplementPropertyType("leftRightOrientation")]
public Models.DatatypePrevalues.LeftRightOrientation LeftRightOrientation
{
get {
var enumValue = this.GetPropertyValue<nuPickers.Picker>("leftRightOrientation");
return enumValue.AsEnums<Models.DatatypePrevalues.LeftRightOrientation>();
}
}
After that generate your models again. ModelsBuilder will now not generate this property anymore, but will use your own implemantation for this nuPicker based property.
nuPickers with ModelsBuilder
We have an Umbraco 7.11.1 site with nuPickers 1.7.0.
My goal is to get nuPickers to cooperate with ModelsBuilder really nicely. Right now, all of the nuPicker properties on my ModelsBuilder models are of type
nuPickers.Picker
. I want them to have the type of the enum that my nuPicker is using as a data source. I have anuPickers: Enum RadioButton Picker
and want the ModelsBuilder model to have a property like this:Unfortunately, there isn't a way to easily get the enum value I want from that
nuPickers.Picker
. What would be yamazing is if there was a way for me to get ModelsBuilder to generate the property like this. I'm guessing changes would need to be made to the PropertyValueConverter of nuPickers?Any ideas about how that could be accomplished?
Hi Mark,
You don't need to create a custom property value converter. You can change the model generation. (https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Control-Generation)
What you need to do is create a partial class with the same name as the generated model in the same folder where the models are generated by Models builder.
In this class you can than define a property like this :
After that generate your models again. ModelsBuilder will now not generate this property anymore, but will use your own implemantation for this nuPicker based property.
Dave
Worked great! Thanks
is working on a reply...