protected virtual string GetLicenseDirectory(LicenseContext context, Type type)
{
string result = null;
// try to use the type resolver service if available
//
if (context != null)
{
ITypeResolutionService resolver = (ITypeResolutionService)context.GetService(typeof(ITypeResolutionService));
if (resolver != null)
result = resolver.GetPathOfAssembly(type.Assembly.GetName());
}
if (result == null)
{
// use the code base if possible - because this works properly under ASP.NET
// where as the Module.FullyQualifiedName points to a temporary file
//
result = type.Assembly.CodeBase;
if (result.StartsWith(@"file:///"))
{
result = result.Replace(@"file:///", "");
}
else
{
result = type.Module.FullyQualifiedName;
}
}
return Path.GetDirectoryName(result);
}