using System;
using System.IO;
namespace System.ComponentModel
{
/// Provides an implementation of a . The provider works in a similar fashion to the Microsoft .NET Framework standard licensing model.
// Token: 0x0200009B RID: 155
public class LicFileLicenseProvider : LicenseProvider
{
/// Returns a license for the instance of the component, if one is available.
/// A valid . If this method cannot find a valid or a valid parameter, it returns null.
/// A that specifies where you can use the licensed object.
/// A that represents the component requesting the .
/// An object that requests the .
/// true if a should be thrown when a component cannot be granted a license; otherwise, false.
///
///
///
// Token: 0x06000523 RID: 1315 RVA: 0x0000DB90 File Offset: 0x0000BD90
public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
{
try
{
if (context == null || context.UsageMode != LicenseUsageMode.Designtime)
{
return null;
}
string text = Path.GetDirectoryName(type.Assembly.Location);
text = Path.Combine(text, type.FullName + ".LIC");
if (!File.Exists(text))
{
return null;
}
StreamReader streamReader = new StreamReader(text);
string text2 = streamReader.ReadLine();
streamReader.Close();
if (this.IsKeyValid(text2, type))
{
return new LicFileLicense(text2);
}
}
catch
{
if (allowExceptions)
{
throw;
}
}
return null;
}
/// Returns a key for the specified type.
/// A confirmation that the parameter is licensed.
/// The object type to return the key.
// Token: 0x06000524 RID: 1316 RVA: 0x0000DC50 File Offset: 0x0000BE50
protected virtual string GetKey(Type type)
{
return type.FullName + " is a licensed component.";
}
/// Determines whether the key that the method retrieves is valid for the specified type.
/// true if the key is a valid for the specified type; otherwise, false.
/// The to check.
/// A that represents the component requesting the .
// Token: 0x06000525 RID: 1317 RVA: 0x0000DC64 File Offset: 0x0000BE64
protected virtual bool IsKeyValid(string key, Type type)
{
return key != null && key.Equals(this.GetKey(type));
}
}
}