Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have below classes and interface implementation

public interface IPageRepository<T> : IRepository
 {
        IList<T> GetPage(Criteria criteria, out int totalRows);
 }

C#
public interface ICategoryRepository : IPageRepository<Category>
    {
 // rest of the methods
}

C#
public class CategoryRepository : BaseDap, ICategoryRepository
{
   // method implementations
}

C#
public class RepositoryFactory
{
        private static readonly Dictionary<Type, Type> container = new Dictionary<Type, Type>();

        static RepositoryFactory()
        {
	     container.Add<ICategoryRepository, CategoryRepository>();  
		// Getting error here:
		//The non-generic method 'Dictionary<Type, Type>.Add(Type, Type)' 
                //   cannot be used with type arguments
        }
}


What I have tried:

I have followed similar pattern in other project and it works there. What am I missing here?
Posted
Updated 11-Oct-18 22:43pm

1 solution

Add is a method that takes two type params

container.Add(typeof(ICategoryRepository), typeof(CategoryRepository));
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900