Skip to content
This repository has been archived by the owner on Dec 13, 2021. It is now read-only.

Added code for UmbracoProperties attribute #83

Merged
merged 3 commits into from Jun 15, 2015

Conversation

mattbrailsford
Copy link
Collaborator

This adds a new [UmbracoProperties] attribute which can be applied at class level to make it easier to express all properties in the target model should look for Umbraco properties with a specific prefix. For example, you may have a model of

[UmbracoProperties(Prefix = "site")]
public class Site
{
    public string Name { get; set; }
    public string Description{ get; set; }
}

And in this instance, Ditto will look for "siteName" and "siteDescription" Umbraco properties (with fall-backs to "Name" / "Description" if not found)

@mattbrailsford
Copy link
Collaborator Author

If everyone is happy with this, we could also look at adding an [UmbracoDictionaryPrefix] attribute for the dictionary resolver (and maybe more).

@mattbrailsford mattbrailsford changed the title Added code for UmbracoPropertyPrefix attribute Added code for UmbracoProperties attribute Jun 11, 2015
@leekelleher leekelleher added rfc Request for Comment feature labels Jun 14, 2015
@leekelleher leekelleher modified the milestone: 0.8.0 Jun 14, 2015
@mattbrailsford mattbrailsford merged commit d97118e into develop Jun 15, 2015
@mattbrailsford mattbrailsford deleted the feature/umbraco-property-prefix branch June 15, 2015 19:35
@JimBobSquarePants
Copy link

Why would you not name your properties in the Umbraco back office to match your POCO properties?

Wouldn't you also want to do this in reverse? try looking for a property called Description then look for one called siteDescription.

@mattbrailsford
Copy link
Collaborator Author

If you explicitly set a prefix, then the prefixed should take precedence.

In the example I give, I create a site object to hold site settings so I can encapsulate site setting . In that instance, you wouldn't want model.site.siteName, you'd just want model.site.name, hence the attribute .

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature rfc Request for Comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants