我有这样的课
public class BonusImageHandler
{ private static IStorageProvider _storageProvider;
private static Type storageProviderType;
private static readonly object _lock = new object();
private static IStorageProvider StorageProvider
{
get
{
lock (_lock)
{
if (_storageProvider == null)
{
lock (_lock)
{
_storageProvider = (IStorageProvider)Activator.CreateInstance(storageProviderType);
}
}
}
return _storageProvider;
}
}
public BonusImageHandler(string providerTypeName)
{
storageProviderType = Type.GetType(providerTypeName);
}
public void ProcessRequest(HttpContext context)
{
//do some thing here
}
private static string ParseInputs(string baseUrl, string imageType)
{
//do other things
}
}
构造函数不是静态的,因为它将字符串作为参数,并且私有静态 IStorageProvider StorageProvider 属性是静态的。组长告诉我这样不行,为什么??我该如何测试它?如何将 httpContext 传递给 ProcessRequest 函数。对于这个愚蠢的问题,我很抱歉,但我仍然是初学者。