Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Reference functionality #272

Open
3 tasks
DiegoFaFe opened this issue Jun 20, 2024 · 3 comments
Open
3 tasks

Extend Reference functionality #272

DiegoFaFe opened this issue Jun 20, 2024 · 3 comments

Comments

@DiegoFaFe
Copy link
Contributor

DiegoFaFe commented Jun 20, 2024

Motivation

Using the sdk I've noticed some code that we end up repeating pretty often around References, like having to create a new reference to request a language variant of a content item that I already have, or checking agaisnt Guid.Empty when I want to filter if the items are in the default language/workflow...

Proposed solution

  • Add a static Default method to Reference class (will return a Reference instance with Guid.Empty id and default codename)
  • Implement IEquatable to Reference class
  • Add Implicit conversor from sdk models (ContentItemModel, LanguageVariantModel...) to Reference

Additional context

@DiegoFaFe
Copy link
Contributor Author

DiegoFaFe commented Jun 20, 2024

@pokornyd I can prepare a PR with any of the 3 proposed changes if they are approved. Just let me know which ones you see value in

@pokornyd
Copy link
Member

hello Diego, pardon the late reply. I'll check with wider team which of your proposed solutions is preferred and get back to you soon, thanks for your patience.

@pokornyd
Copy link
Member

I'd say the best approach is indeed to have a static method to create a default reference, e.g.:

    /// <summary>
    /// Creates the reference by empty guid (for entities with default ID).
    /// </summary>
    public static Reference ByDefaultId() => new() { Id = Guid.Empty };

I'm not sure a similar implementation for default codename is necessary. IDs are immutable, whereas codenames can be modified. all default entities come with an empty ID if I'm not mistaken, so I think above method should be sufficient.

do you have a use case for default codename as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants