using System;
using System.Reflection;
using System.Resources;
using System.Diagnostics;
namespace AnticipatingMinds.PlatformServices.Licensing{
/// <summary>
/// Summary description for LicensingException.
/// </summary>
[System.Serializable()]
public class LicensingException : ApplicationException
{
public LicensingException(string messageId,params object[] messageArguments):this(null,messageId,messageArguments)
{
}
public LicensingException(Exception innerException,string messageId,params object[] messageArguments):base(GetExceptionMessage(messageId,messageArguments),innerException)
{
}
private static string GetExceptionMessage(string exceptionMessageId,params object[] messageArguments)
{
if(exceptionsResourceManager == null)
exceptionsResourceManager = new ResourceManager("AnticipatingMinds.PlatformServices.Licensing.ExceptionMessages",Assembly.GetExecutingAssembly());
string fetchedString = String.Format(exceptionsResourceManager.GetString(exceptionMessageId),messageArguments);
//Check that fetchedString is not null
Debug.Assert(fetchedString != null,string.Format("String resource '{0} was not found",exceptionMessageId));
if(fetchedString == null)
fetchedString = exceptionMessageId;
return fetchedString;
}
private static ResourceManager exceptionsResourceManager = null;
}
[System.Serializable()]
public class LicenseFormatException : LicensingException
{
public LicenseFormatException(string message):base("LicenseFormatException",message)
{
}
}
[System.Serializable()]
public class LicenseIsNotFoundException : LicensingException
{
public LicenseIsNotFoundException():base("LicenseIsNotFoundException")
{
this.license = license;
}
public License License
{
get
{
return license;
}
}
private License license;
}
[System.Serializable()]
public class LicenseSignatureMismatchException : LicensingException
{
public LicenseSignatureMismatchException(License license):base("LicenseSignatureMismatchException",license != null ? license.LicenseId:string.Empty)
{
this.license = license;
}
public License License
{
get
{
return license;
}
}
private License license;
}
[System.Serializable()]
public class LicenseProductIdMismatchException : LicensingException
{
public LicenseProductIdMismatchException(License license):base("LicenseProductIdMismatchException",license != null ? license.LicenseId:string.Empty)
{
this.license = license;
}
public License License
{
get
{
return license;
}
}
private License license;
}
[System.Serializable()]
public class LicenseProductVersionMismatchException : LicensingException
{
public LicenseProductVersionMismatchException(License license):base("LicenseProductVersionMismatchException",license != null ? license.LicenseId:string.Empty)
{
this.license = license;
}
public License License
{
get
{
return license;
}
}
private License license;
}
[System.Serializable()]
public class LicenseExpiredException : LicensingException
{
public LicenseExpiredException():this(null){}
public LicenseExpiredException(License license):base("LicenseExpiredException",license != null ? license.LicenseId:string.Empty)
{
this.license = license;
}
public License License
{
get
{
return license;
}
}
private License license;
}
}
|