I have a dictionary of class types that looks like this:
private static Dictionary<int, Type> GetArrayOfClassInstances()
{
var availability = new LeisureLinkBaseProduct.Availability();
var baseRate = new LeisureLinkBaseProduct.BaseRate();
var stayRestrictions = new LeisureLinkBaseProduct.StayRestrictions();
var checkInInformation = new LeisureLinkBaseProduct.CheckInInformation();
var specials = new LeisureLinkBaseProduct.Specials();
var taxes = new LeisureLinkBaseProduct.Taxes();
var fees = new LeisureLinkBaseProduct.Fees();
var classDictionary = new Dictionary<int, Type>();
classDictionary.Add(1, availability.GetType());
classDictionary.Add(2, baseRate.GetType());
classDictionary.Add(3, stayRestrictions.GetType());
classDictionary.Add(4, checkInInformation.GetType());
classDictionary.Add(5, specials.GetType());
classDictionary.Add(6, taxes.GetType());
classDictionary.Add(7, fees.GetType());
return classDictionary;
}
And I want to pass it into this generic method that looks like this:
var classes = GetArrayOfClassInstances();
foreach (var instance in classes)
{
var request = RequestBuilder.BuildAdditionalDataRequest(link.href);
var response = Api<instance.value>(request.Endpoint);
}
but I get the intellisense error "instance is a variable but is used like a type" how do I pass this class type into the generic then? Is this possible? Thanks!