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

Add a method signature to ICodeFirstTypeProvider #101

Closed
JanLenoch opened this issue Feb 7, 2018 · 3 comments
Closed

Add a method signature to ICodeFirstTypeProvider #101

JanLenoch opened this issue Feb 7, 2018 · 3 comments
Labels
enhancement good first issue groomed The issue has been groomed and should be in a good shape. help wanted up-for-grabs
Milestone

Comments

@JanLenoch
Copy link

JanLenoch commented Feb 7, 2018

Motivation

The Delivery API allows filtering of content items by their type. The SDK allows for specifying strong types that reflect content types of those items. The developer may request strongly typed items via

var response = await DeliveryClient.GetItemsAsync<Article>(
    new EqualsFilter("system.type", "article"),
);

To remove the burden of specifying the type twice (see above), we've implemented a ContentTypeExtractor class that uses reflection to automatically add the EqualsFilter in the background.

To get around using reflection, we could make our code generators also generate a dictionary inside of an ICodeFirstTypeProvider class that would return a codename for a particular System.Type.

Howto

To make the above possible, add a GetCodename method to the ICodeFirstTypeProvider interface that accepts System.Type as a parameter.

Then, we could implement kontent-ai/model-generator-net#61 .

@JanLenoch JanLenoch modified the milestone: Prioritization May 22, 2018
@JanLenoch JanLenoch added the groomed The issue has been groomed and should be in a good shape. label Aug 10, 2018
@JanLenoch JanLenoch changed the title Add support for bi-directional resolving in ICodeFirstTypeProvider Add a method signature to ICodeFirstTypeProvider Aug 10, 2018
@Neytus Neytus self-assigned this Aug 23, 2018
@petrsvihlik petrsvihlik added this to the 5.1.0 milestone Aug 23, 2018
@petrsvihlik
Copy link
Contributor

done in #121

@mcbeev
Copy link

mcbeev commented Sep 23, 2018

@JanLenoch and @petrsvihlik I updated to the latest 6.0.0 release, and need to now implement the new GetCodename method, but I wanted to know if I have it correct. Stubbing it in looks like this:

image

Now, I'm guessing that the code of that method wants the reverse of GetType to happen in GetCodename (convert the Type to a string representation)? But doesn't this seem like a lot of duplication? Or is the code gen tool updated to automatically do this for me now ?

Any guidance is appreciated.
Brian

@petrsvihlik
Copy link
Contributor

Hey @mcbeev , yeah it's updated. See https://github.com/Kentico/delivery-sdk-net/releases/tag/6.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement good first issue groomed The issue has been groomed and should be in a good shape. help wanted up-for-grabs
Projects
None yet
Development

No branches or pull requests

4 participants