- using System;
- namespace Company.Product
- {
- /// <summary>
- /// Provides information concerning the availability and status of a license.
- /// </summary>
- public class License
- {
- /// <summary>
- /// Denotes that this license never expires.
- /// </summary>
- public static readonly DateTime NeverExpires = DateTime.MaxValue;
- private string msName;
- private DateTime mpExpirationDate;
- public License( string sName, DateTime pExpirationDate )
- {
- msName = sName;
- mpExpirationDate = pExpirationDate;
- }
- /// <summary>
- /// The name of the license.
- /// </summary>
- public string Name
- {
- get
- {
- return( msName );
- }
- }
- /// <summary>
- /// Denotes that a license has expired.
- /// </summary>
- public bool HasExpired
- {
- get
- {
- return( System.DateTime.Now > mpExpirationDate );
- }
- }
- /// <summary>
- /// Specifies that date that this license expires.
- /// </summary>
- public DateTime ExpirationDate
- {
- get
- {
- return( mpExpirationDate );
- }
- }
- public override string ToString()
- {
- return( msName );
- }
- /// <summary>
- /// Specifies that a particular license has expired.
- /// </summary>
- public class LicenseExpiredException : Exception
- {
- /// <summary>
- /// The license that has expired.
- /// </summary>
- public License License;
- public LicenseExpiredException( License pLicense ) : base( "The license necessary for this function or application has expired. Please contact your sales representative for more information." )
- {
- License = pLicense;
- }
- }
- /// <summary>
- /// Specifies that a particular license is invalid or damaged.
- /// </summary>
- public class LicenseInvalidException : Exception
- {
- /// <summary>
- /// The license that is invalid.
- /// </summary>
- public License License;
- public LicenseInvalidException( License pLicense ) : base( "The license necessary for this function or application is invalid. Please contact your sales representative for more information." )
- {
- License = pLicense;
- }
- }
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/201220121088.html
来源: http://www.codesnippet.cn/detail/201220121088.html