I have several collections that all look the same but operate on different types of collection items, like this:
[CollectionDataContract(ItemName = "Culture")]
public sealed class Cultures : List<LangCult>
{
}
The important piece of code here is the CollectionDataContract attribute which allows us to serialize this collection into an XML file with DataContractSerializer. The entire collection is serialized into one XML file named as the name of the type of collection class, for instance Cultures.xml
I would like to come up with a repository, precisely with an interface for a repository, that would work on all of the possible collections, for instance public class Slugs : List<string>.
I tried something like this, but I don’t know whether it’s the best option:
public interface ICollectionsRepository<T> where T : IEnumerable
Your thoughts?
Please do not respond with instructions on how to serialize because that is not the issue here and I have it working.
Maybe I should’ve said I wanted an interface for generic collection with generic items where items have a common base class. This is how I solved it and hopefully someone one day finds it useful.