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
Barry Fogarty
@BarryFogarty
I tried uninstalling the value converters but the result is the same, list items are instantiated but null. The raw value from my picker is now a CSV of node IDs. I think I'll just take another approach, thanks for having a look though
Lee Kelleher
@leekelleher
@dannylee_c_twitter Did you ever get any further with your XPathQuery processor? I've got to a point where I could use something like it. :smiley:
Dan Curtis
@dannylee_c_twitter
hey @leekelleher - sorry I didn't get any notifications from your message
here's the code:
public class XPathAttribute : DittoProcessorAttribute
    {
        private readonly string[] _currentItemIdentifiers = { ".", "$current" };
        private readonly string[] _currentSiteIdentifiers = { "$site" };
        private readonly string[] _currentPageIdentifiers = { "$currentPage" };

        private string _xPath;

        public XPathAttribute(string xPath)
        {
            _xPath = xPath;
        }

        public override object ProcessValue()
        {
            var umbracoContext = UmbracoContext.Current;
            foreach (var currentItemIdentifier in _currentItemIdentifiers)
            {
                if (_xPath.StartsWith(currentItemIdentifier))
                    _xPath = $"id({Context.Content.Id})" + _xPath.Remove(0, currentItemIdentifier.Length).EnsureStartsWith("/");
            }

            foreach (var currentPageIdentifier in _currentPageIdentifiers)
            {
                if (_xPath.StartsWith(currentPageIdentifier))
                    _xPath = $"id({umbracoContext.PageId})" + _xPath.Remove(0, currentPageIdentifier.Length).EnsureStartsWith("/");
            }

            foreach (var currentSiteIdentifier in _currentSiteIdentifiers)
            {
                if (_xPath.StartsWith(currentSiteIdentifier))
                    _xPath = $"id({Context.Content.Id})/ancestor-or-self::*[@level = 1]" + _xPath.Remove(0, currentSiteIdentifier.Length).EnsureStartsWith("/");
            }

            if (Context.PropertyDescriptor.PropertyType.IsEnumerableType())
            {
                var genericTypeDefinition =
                    Context.PropertyDescriptor.PropertyType.GetGenericArguments().FirstOrDefault();
                return umbracoContext.ContentCache.GetByXPath(_xPath).As(genericTypeDefinition);
            }

            return umbracoContext.ContentCache.GetSingleByXPath(_xPath).As(Context.PropertyDescriptor.PropertyType);
        }
    }
Still needs some Ditto project tests, as I'm using integration tests to test it my side
Lee Kelleher
@leekelleher
@dannylee_c_twitter Hey, sorry for the delay in replying - only just seen your message. Thanks so much for sharing. Would you be cool if we took this and work on it further - either for Ditto (or the Ditto Labs repo)?
Dan Curtis
@dannylee_c_twitter
yeah go for it, keep me updated!
Barry Fogarty
@BarryFogarty
QQ - Is there a way to call a core ditto processor from a custom one. I want to create a 'DictionaryFallbackProcessor' which essentially needs to call UmbracoDictionary(key) if the value passed in is null or empty. I'm currently just using UmbracoHelper.GetDictionaryValue(key) but was interest generally whether a pattern like this was possible.
Matt Brailsford
@mattbrailsford
Inherit it then override the ProcessValue method wrapping it in a null check
That's essentially what we do with AltUmbracoProperty processor, wrapping the regular UmbracoProperty processor
Barry Fogarty
@BarryFogarty
To answer my own question, I've seen how the Ditto MultiProcessor attribute does it here https://github.com/leekelleher/umbraco-ditto/blob/ac17fea47c3d2be3cbca63c10f373cb5312ab2a6/src/Our.Umbraco.Ditto/ComponentModel/Attributes/DittoMultiProcessorAttribute.cs - but in my use case its a lot simpler to just call my Dictionary helper directly.
Lee Cook
@leethomascook_twitter
Hi All, I managed to get integration tests working with ditto, by making two small visibility changes to the core. ( umbraco/Umbraco-CMS#1710 ) Thoughts? Good /bad idea?
Marko
@mkjovanov
Hey guys, I would like to add Ditto ModelFactory to my project so I don't have to do cast 'As' poco properties in .cshtml views. Can I achieve this with the "Ditto ModelFactory" package? http://nugetmusthaves.com/Package/Our.Umbraco.Ditto.ModelFactory and does anybody happen to have any examples?
Lee Kelleher
@leekelleher
@mkjovanov Don't use the DittoModelFactory - it was an experiment that didn't work out (I should kill off that NuGet package). Our recommendation is to use DittoViewdirective on your views/partials. If you need an example, check out this github repo: https://github.com/lars-erik/DittoDemoModelsBuilderified/blob/master/Dittoified/Views/umbTextPage.cshtml
@leethomascook_twitter I'm not sure how the Umbraco core amends impact Ditto.
(Just checking are you using DittoModelFactory? hoping you say no :wink:)
jayfive
@jayfive
Hi, I'm new to ditto. Just giving it a trial now. What I can't figure out is how to map multi node tree pickers. It looks like the usage has changed a bit from version to version. I'm currently working with v0.10. Can you point me in the right direction on how to get this working?
Marko
@mkjovanov
@leekelleher thanks Lee, I will take a look at the examples. Cheers!
James Jackson-South
@JimBobSquarePants
@jayfive The simplest way I find is to decorate the class that represents your picked object with [DittoPicker] then use the propert as IEnumberable<YourPickedClass> in the calling class.
jayfive
@jayfive
Thanks @JimBobSquarePants, although DittoPicker doesn't seem to exist anymore. I checked the upgrade logs and can see it's been replaced with UmbracoPicker. This looks like it's done the job. I can now get on with replacing GlassMapper with Ditto :)
James Jackson-South
@JimBobSquarePants
Yeah sorry, forgot the name had changed :smile:
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