mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-19 01:31:17 -10:00
Removed unneded TODOs. * ComponentResourceManager.cs: Implemented ApplyResources. * EventDescriptorCollection.cs: Implemented several missing methods. * LicFileLicenseProvider.cs: Implemented. * MemberDescriptor.cs: Implemented some missing methods. Handle correctly the creation of the Attribute list. * TypeConverter.cs: Use null as default value for attribute array parameter. svn path=/trunk/mcs/; revision=25229
85 lines
1.6 KiB
C#
85 lines
1.6 KiB
C#
//
|
|
// System.ComponentModel.LicFileLicenseProvider.cs
|
|
//
|
|
// Authors:
|
|
// Martin Willemoes Hansen ([email protected])
|
|
// Andreas Nahr ([email protected])
|
|
// Lluis Sanchez Gual ([email protected])
|
|
//
|
|
// (C) 2003 Martin Willemoes Hansen
|
|
// (C) 2003 Andreas Nahr
|
|
//
|
|
|
|
using System.IO;
|
|
|
|
namespace System.ComponentModel
|
|
{
|
|
public class LicFileLicenseProvider : LicenseProvider
|
|
{
|
|
|
|
public LicFileLicenseProvider()
|
|
{
|
|
}
|
|
|
|
public override License GetLicense (LicenseContext context,
|
|
Type type,
|
|
object instance,
|
|
bool allowExceptions)
|
|
{
|
|
try
|
|
{
|
|
if (context == null || context.UsageMode != LicenseUsageMode.Designtime)
|
|
return null;
|
|
|
|
string path = Path.GetDirectoryName (type.Assembly.Location);
|
|
path = Path.Combine (path, type.FullName + ".LIC");
|
|
|
|
if (!File.Exists (path)) return null;
|
|
|
|
StreamReader sr = new StreamReader (path);
|
|
string key = sr.ReadLine ();
|
|
sr.Close ();
|
|
|
|
if (IsKeyValid (key, type))
|
|
return new LicFileLicense (key);
|
|
}
|
|
catch
|
|
{
|
|
if (allowExceptions) throw;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
protected virtual string GetKey (Type type)
|
|
{
|
|
return (type.FullName + " is a licensed component.");
|
|
}
|
|
|
|
protected virtual bool IsKeyValid (string key, Type type)
|
|
{
|
|
if (key == null)
|
|
return false;
|
|
return key.Equals (GetKey (type));
|
|
}
|
|
}
|
|
|
|
internal class LicFileLicense: License
|
|
{
|
|
string _key;
|
|
|
|
public LicFileLicense (string key)
|
|
{
|
|
_key = key;
|
|
}
|
|
|
|
public override string LicenseKey
|
|
{
|
|
get { return _key; }
|
|
}
|
|
|
|
public override void Dispose ()
|
|
{
|
|
}
|
|
}
|
|
}
|