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

Interface for Anime item and Manga item #4

Closed
flashkid10 opened this issue Dec 27, 2018 · 2 comments
Closed

Interface for Anime item and Manga item #4

flashkid10 opened this issue Dec 27, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@flashkid10
Copy link

flashkid10 commented Dec 27, 2018

Is there a way to for you to add an Interface for the Anime item and Manga item so I can treat them as the same item to help with accessing internal propertys.

So instead of doing something like this;
public long ID { get { if (AnimeItem!= null) return AnimeItem.MalId; else return MangaItem.MalId; } }

I can reference the ID though a interface (or a series of interfaces) , like this

public interface MalItemInteracter
    {
        long MalId { get; }
        string Title { get; }
        string Studios { get; }
        string Type { get; }
        string Author { get; }
        string Genres { get; }
        float? Score { get; }
    }

MalItemInteracter MII = (AnimeItem or MangaItem) as MalItemInteracter();
public long ID { get { MalItemInteracter.MalId; } }
@Ervie
Copy link
Owner

Ervie commented Dec 27, 2018

Hello,

I assume that you mean main classes, which you receive from GetAnime() nad GetManga() methods.

The idea is not bad, but I think it would need a little adjustements. The models are a bit different - for example, the Manga model does not contain property Studios, and the Anime model has Author property. Both are also prone to changes due to modification done by MAL and Jikan author. You can make a lot of interfaces with common properties, and the may be incompatible on next REST API update.

What I find justified, is to create interface for items with MalId (IMalEntityWithId?), representing entities which has their own separate page on MAL (so it would be Anime, Manga, Characters, People, Genres, Magazines and Producers; would be also users if the MalId was placed on the profile). I think it would satisfy your needs. I have to update library version on 1st or 2nd January due to changes in REST API endpoint, so I guess it can be enclosed on next release.

The best solution, in fact, would be cloning this repository (or forking and then cloning), adding it to your main project, creating an interface of your need and making Anime and Manga classes implement this interface. You would have complete control over interfaces and common properties.

@Ervie Ervie self-assigned this Dec 27, 2018
@Ervie Ervie added the enhancement New feature or request label Dec 27, 2018
@Ervie
Copy link
Owner

Ervie commented Jan 1, 2019

Hi,

In new version (1.2) both Manga and Anime (and few other classes) share IMalEntity interface which allow you to reference to items by MalId. Documentation should be updated in the near future.

@Ervie Ervie closed this as completed Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants