Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 24 2018 16:41

    leekelleher on develop

    Migration to UMCO - Updated th… (compare)

  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:40
    leekelleher edited #234
  • Jan 24 2018 16:22
    leekelleher edited #234
  • Jan 24 2018 16:20
    leekelleher edited #234
  • Jan 24 2018 16:03
    leekelleher labeled #234
  • Jan 24 2018 16:03
    leekelleher assigned #234
  • Jan 24 2018 16:03
    leekelleher opened #234
  • Jan 24 2018 15:39
    leekelleher unassigned #195
  • Jan 24 2018 15:39
    leekelleher unassigned #188
  • Jan 24 2018 15:39
    leekelleher unassigned #177
  • Jan 24 2018 15:39
    leekelleher unassigned #176
  • Jan 24 2018 15:39
    leekelleher unassigned #138
  • Jan 24 2018 15:39
    leekelleher unassigned #111
  • Jan 24 2018 15:39
    leekelleher unassigned #67
  • Jan 24 2018 15:39
    leekelleher unassigned #61
  • Jan 24 2018 15:39
    leekelleher unassigned #59
  • Jan 24 2018 15:39
    leekelleher unassigned #53
  • Jan 24 2018 15:39
    leekelleher unassigned #49
Norbert Haberl
@nhaberl
Any plans for Ditto v1.0
James Jackson-South
@JimBobSquarePants
Yeah of course. Need to have achat about that actually.
Barry Fogarty
@BarryFogarty
Are there any docs or resources available about the Ditto cache? The OOB implementation seems quite restrictive - you don't seem to be able to cache 2 separate properties by Content ID for example. Maybe I'm using it wrong though.. It'd be good to be able to chain the CacheBy rules (Property Name AND Content ID for example). I'm hoping to write my own custom cache key builder but not sure where to start.
Gareth Wright
@garpunkal
I have to say, Ditto is awesome! I've used it on 3 projects now and it's literally a pleasure to use! Would love to see this integrated into the core! Any chance of that happening?
Gareth Wright
@garpunkal

What would be the best approach for accessing the IPublishedContent in your mapped POCO... For instance:

I have a "Link" POCO and I want to check if that link IsAncestorOrSelf or the current page.
Would it be safe to do the following?

[CurrentContentAs]
public virtual IPublishedContent PublishedContent { get; set; }

and then use the extension method for IsAncestorOrSelf or would there be a different approach that you'd recommend?

Lee Kelleher
@leekelleher
@garpunkal Sorry we missed your questions, haven't been on Gitter for a while...
re: Ditto in Umbraco core ... nope, never gonna happen.
Gareth Wright
@garpunkal
@leekelleher no problem, I'll still use regardless! :)
Lee Kelleher
@leekelleher
@garpunkal With accessing the IPublishedContent within your POCO... we do check if the POCO has a constructor with 1 parameter of IPublishedContent
so Ditto will pass that in, and your POCO can keep a local/private reference of it
Gareth Wright
@garpunkal
ah cool
Lee Kelleher
@leekelleher
I was trying to find a reference in our unit-tests to show you... but my github-foo is failing me ;-)
Gareth Wright
@garpunkal
haha, it's fine, I've got it working! I just didn't know about the constructor param... cheers!
James Jackson-South
@JimBobSquarePants
@leekelleher I think we should try and get #217 merged and push 0.11.0 out. It's been a while since we did a release.
Lee Kelleher
@leekelleher
@JimBobSquarePants Thanks for the prompt, v0.11 has been long overdue! I merged in #217 & #218 yesterday. I'm in the process of moving house this week (lots of packing right now), and taken time off work, so I can look at doing a 0.11 release next week. :+1:
James Jackson-South
@JimBobSquarePants
@leekelleher Great! Hope your house move goes well ! :+1:
James Jackson-South
@JimBobSquarePants
I do wonder about version numbers though. Maybe version 1.0 is finally due. it has been a few years :smile: :shipit:
Lee Kelleher
@leekelleher
@JimBobSquarePants The rough plan was to do a 0.11, gets the docs sorted and call it a v1.0.
@JimBobSquarePants Oh, congrats with the pregnancy news! Exciting times ahead! :-D
James Jackson-South
@JimBobSquarePants

@leekelleher Thanks! Yeah, we need to get those docs sorted. Been working on something the last 24 hours I wanted to show you sometime... Another mapping approach, convention based, would love your input.

https://twitter.com/James_M_South/status/890594763442765824

Lee Kelleher
@leekelleher
Ooo interesting! Of course, raises obvious questions about overlapping with Ditto and/or other Umbraco mappers ... but I'm all for innovation & exploring ideas! :-D
So would this keep the mapping separate from the POCO?
Lee Kelleher
@leekelleher
but yeah, totally happy to give input on it :+1:
Jamie Pollock
@jamiepollock
Random thought, this is unrelated to @JimBobSquarePants' new way workflow always wondered how a Fluent mapper would work out. Between this, Ditto & ModelsBuilder the bases are pretty covered.
James Jackson-South
@JimBobSquarePants
@leekelleher Thanks! appreciate it. I wanted to experiment with something different as over time I've grown less comfortable with attribute decoration and wanted to keep the POCO's as such. I'll upload some code today.
Collyn Philleo
@cphilleo
@JimBobSquarePants I too prefer to keep mappings separate from POCOs. A couple years ago I create a mapper that looks pretty similar to yours that we use internally at my agency. The documentation is sorely lacking, but I've put it up on GitHub . I based it on NHibernate/Fluent.NHibernate. It does a few cool things and has a pseudo lazy loading mechanism. (It's really on-demand I guess, but I'd love to go back and do it using Rosyln to create dynamic proxies or something similar). Anyway, take a look and give any feedback if you like, you might find something useful in there. https://github.com/rhythmagency/rhythm.populate
Lee Kelleher
@leekelleher
@mattbrailsford @JimBobSquarePants Just a heads up that I'm prep'ing for the v0.11 release. I've written up the release notes, etc.
Lee Kelleher
@leekelleher
Matt Brailsford
@mattbrailsford
🎉
Matt Brailsford
@mattbrailsford
@JimBobSquarePants I must admit, I'm starting to think the same a little about the attributes (though my dislike has grown more so coming from UI-O-Matic)
interested to see where you go with your mapping strategy
Lee Kelleher
@leekelleher
re: attributes - yup, I've had similar thoughts, especially when some of my "POCOs" get too far decorated.
@mattbrailsford Did you have an example of using AutoMapper to map IPublishedContent to POCO? (maybe from your CG17 talk?)
I'm struggling to find a nice example of AutoMapper usage to compare & contrast with UmbMapper's API (and Zone's "Umbraco Mapper" too)
Matt Brailsford
@mattbrailsford
using System;
using System.Linq;
using System.Web;
using AutoMapper;
using Codecabin.App.Extensions;
using Codecabin.App.ValueConveters;
using Codecabin.App.ViewModels;
using Skybrud.Social.Twitter.Objects;
using Umbraco.Web.PublishedContentModels;

namespace Codecabin.App
{
    internal class AutoMapperConfig
    {
        public static void RegisterMappings()
        {
            // Activity
            Mapper.CreateMap<Social, SocialViewModel>()
                .ForMember(x => x.Statuses, s => s.Ignore());

            Mapper.CreateMap<TwitterStatusMessage, StatusViewModel>()
                .ForMember(x => x.Avatar, s => s.MapFrom(x => x.User.ProfileImageUrlHttps))
                .ForMember(x => x.Name, s => s.MapFrom(x => x.User.Name))
                .ForMember(x => x.ScreenName, s => s.MapFrom(x => x.User.ScreenName))
                .ForMember(x => x.Html, s => s.MapFrom(x => x.LinkifiedText()))
                .ForMember(x => x.CreateDate, s => s.MapFrom(x => x.CreatedAt));

            // Attendees
            Mapper.CreateMap<Attendees, AttendeesViewModel>()
                .ForMember(x => x.Attendees, s => s.MapFrom(x => x.Children.OfType<Attendee>()));

            Mapper.CreateMap<Attendee, AttendeeViewModel>()
                .ForMember(x => x.Avatar, s => s.MapFrom(x => HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + x.Avatar + "?preset=avatar"));

            // Schedule
            Mapper.CreateMap<Schedule, ScheduleViewModel>()
                .ForMember(x => x.Days, s => s.MapFrom(x => x.Children.OfType<Day>()));

            Mapper.CreateMap<Day, DayViewModel>()
                .ForMember(x => x.Activities, s => s.MapFrom(x => x.Children.OfType<Activity>()));

            Mapper.CreateMap<Activity, ActivityViewModel>();

            // Info
            Mapper.CreateMap<Info, InfoViewModel>()
                .ForMember(x => x.Data, s => s.MapFrom(x => x));

            Mapper.CreateMap<Info, InfoDataViewModel>();

            Mapper.CreateMap<LatLng, LatLngViewModel>();
        }
    }
}
This was from the codecabin app just mapping some models builder models to view models
ForMember => MapFrom gets a bit verbose, so @JimBobSquarePants solution is a bit cleaner in that respect
I can't say any of this is necessarily best practice though, just what I got working
Matt Brailsford
@mattbrailsford
I just shared this with @leekelleher and thought it might be interesting to others here https://www.youtube.com/watch?v=AQGk8WnMpAY
James Jackson-South
@JimBobSquarePants
@leekelleher When did we add passing an instance to map to to the API? That makes things.... Difficult re proxying. We end up replacing the instance that gets passed.
Oh also re #223 You can drop the HtmlString converter. As soon as you use IHtmlString as your property type GetPropertyValue will already map it.
Matt Brailsford
@mattbrailsford
Hasn't the API always supported mapping to an existing object instance?
James Jackson-South
@JimBobSquarePants
Dunno... Never spotted it before. Essentially though we can't proxy a passed instance only a new one.
Lee Kelleher
@leekelleher
@JimBobSquarePants re: HtmlString, sure thing :+1:
with passing an instance in... it's been there a pretty long time
James Jackson-South
@JimBobSquarePants
I got it all working anyway. It just won't attempt to lazy map an existing instance
Phong Bui
@loveunCG
hello
Norbert Haberl
@nhaberl
Guys, is Ditto still the mapper to use ? Or better to use umbMapper or UmbracoMapper ?
Lee Kelleher
@leekelleher

Hi @nhaberl - ultimately the choice is yours, like with soft drinks, there's plenty of choice... Pepsi, Coke, 7-Up :smile:
We're still supporting Ditto and it still has consistent NuGet downloads, around 44/day - so not crazy high demand, but enough to know people are still using it.

Personally I'm using ModelsBuilder more these days. Mostly because I don't need overly complex view-models. It's great to have Ditto in my utility belt, just in case though. :smile:

Norbert Haberl
@nhaberl
I know I know ... thanks
Just wanted to confirm that Ditto is alive :)
Lee Kelleher
@leekelleher
No worries :smile: Ditto is alive. :+1: