public object GetService(Type serviceType) { var context = new ChatContext(); if (serviceType == typeof(PostsController)) { var repository = new DbPostsRepository(context); return new PostsController(repository); } else if (serviceType == typeof(UsersController)) { var repository = new DbUsersRepository(context); return new UsersController(repository); } else if (serviceType == typeof(ChatRoomsController)) { var repository = new DbChatRoomsRepository(context); return new ChatRoomsController(repository); } else { return null; } }
public object GetService(Type serviceType) { var context = new ChatContext(); if (serviceType == typeof(PostsController)) { var repository = new DbPostsRepository(context); return(new PostsController(repository)); } else if (serviceType == typeof(UsersController)) { var repository = new DbUsersRepository(context); return(new UsersController(repository)); } else if (serviceType == typeof(ChatRoomsController)) { var repository = new DbChatRoomsRepository(context); return(new ChatRoomsController(repository)); } else { return(null); } }