-
Notifications
You must be signed in to change notification settings - Fork 14
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
Automatic deserialize JSON to IContent implementations #12
Conversation
Changing the return type from |
I'm wondering if it is necessary to change the return type. For the strongly typed models don't we inherit from |
The reason for changing it to |
Okay, but this also assumes that you are using strongly typed models right? Otherwise it wouldn't really be usable or at a minimum it would force you to cast it to Maybe an alternative could be to have GetRoot, GetAnscestors, etc. take a list of types in a method overload, so you essentially tell that you want the root items of types x and y in the returned list of |
Something like:
I realize there might be some overload clash here, but just an example. Method name could also be something like GetAncestorsTyped, GetAncestorsAsTypes. |
5837b3d
to
9870153
Compare
Instead of creating overloads I've gone with the requirement of inheriting from |
{ | ||
public interface IHeadlessConfiguration | ||
{ | ||
string ProjectAlias { get; } | ||
ITypeList<IContent> ContentModelTypes { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be a breaking change, so maybe consider adding another interface to add the ITypeList<IContent> ContentModelTypes
and leave IHeadlessConfiguration
untouched.
For the implementation and the public class we could then choose to only expose the one you implemented in HeadlessConfiguration
.
We'd of course need to check on ContentModelTypes, so we can pass an empty list, but think that would be okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, and since ContentDelivery
is internal we should be able to change the constructor so we can change the interface that is passed in.
I think this will work fine. Having to inherit from One thing that we will need to ensure before this is released is that it still works with Xamarin (UWP, Xamarin.Android, Xamarin.iOS). There are some limitations around reflection, so just want to ensure that we don't inadvertently break compatibility. |
Regarding UWP and Xamarin we should be good, as far as I can see it's Relection.Emit and Reflection over private members that isn't allowed (see https://docs.microsoft.com/en-us/dotnet/framework/net-native/reflection-and-net-native and https://docs.microsoft.com/en-us/xamarin/ios/internals/limitations) |
1a96e04
to
84db6cc
Compare
This is ready for review now. I've added a new interface The (content/media) type alias that is used to lookup the model types based on the class name, this can be overwritten by adding one of the following attributes to the model, |
This looks great, seems to be working as intended from what I've seen so far! 👍 Is there any possibility to allow "casting" to If it was possible to call something like the following, that'd be very helpful! var filters = new List<ContentFilterProperties>() {
new ContentFilterProperties("property", "value", ContentFilterMatch.Contains))
};
var contentFilter = new ContentFilter("thing", filters.ToArray());
var items = (PagedContent<Thing>) await _contentDelivery.Content.Filter(contentFilter); |
The above mentioned was somewhat resolved by #19 as you can now do both |
84db6cc
to
ba0f652
Compare
I've rebased and updated the code. I've opened a new PR with a Xamarin Forms demo #31 we can use to test that the library is still working with Xamarin |
This is still a WIP
Added automatic deserialization into custom models as described in #11 (comment)
Right now it works for Document Types but needs to be implemented for Element and Media Types.