116 lines
3.0 KiB
C#
116 lines
3.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.IO;
|
|
using System.Reflection;
|
|
using System.Reflection.Emit;
|
|
using System.Runtime.Serialization.Formatters.Binary;
|
|
|
|
namespace System.ComponentModel.Design
|
|
{
|
|
// Token: 0x0200004F RID: 79
|
|
internal class RuntimeLicenseContext : LicenseContext
|
|
{
|
|
// Token: 0x06000330 RID: 816 RVA: 0x00009B74 File Offset: 0x00007D74
|
|
private void LoadKeys()
|
|
{
|
|
if (this.keys != null)
|
|
{
|
|
return;
|
|
}
|
|
this.keys = new Hashtable();
|
|
Assembly entryAssembly = Assembly.GetEntryAssembly();
|
|
if (entryAssembly != null)
|
|
{
|
|
this.LoadAssemblyLicenses(this.keys, entryAssembly);
|
|
}
|
|
else
|
|
{
|
|
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
|
|
{
|
|
this.LoadAssemblyLicenses(this.keys, assembly);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000331 RID: 817 RVA: 0x00009BE8 File Offset: 0x00007DE8
|
|
private void LoadAssemblyLicenses(Hashtable targetkeys, Assembly asm)
|
|
{
|
|
if (asm is AssemblyBuilder)
|
|
{
|
|
return;
|
|
}
|
|
string fileName = Path.GetFileName(asm.Location);
|
|
string text = fileName + ".licenses";
|
|
try
|
|
{
|
|
foreach (string text2 in asm.GetManifestResourceNames())
|
|
{
|
|
if (!(text2 != text))
|
|
{
|
|
using (Stream manifestResourceStream = asm.GetManifestResourceStream(text2))
|
|
{
|
|
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
|
object[] array = binaryFormatter.Deserialize(manifestResourceStream) as object[];
|
|
if (string.Compare((string)array[0], fileName, true) == 0)
|
|
{
|
|
Hashtable hashtable = (Hashtable)array[1];
|
|
foreach (object obj in hashtable)
|
|
{
|
|
DictionaryEntry dictionaryEntry = (DictionaryEntry)obj;
|
|
targetkeys.Add(dictionaryEntry.Key, dictionaryEntry.Value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (InvalidCastException)
|
|
{
|
|
}
|
|
}
|
|
|
|
// Token: 0x06000332 RID: 818 RVA: 0x00009D50 File Offset: 0x00007F50
|
|
public override string GetSavedLicenseKey(Type type, Assembly resourceAssembly)
|
|
{
|
|
if (type == null)
|
|
{
|
|
throw new ArgumentNullException("type");
|
|
}
|
|
if (resourceAssembly != null)
|
|
{
|
|
if (this.extraassemblies == null)
|
|
{
|
|
this.extraassemblies = new Hashtable();
|
|
}
|
|
Hashtable hashtable = this.extraassemblies[resourceAssembly.FullName] as Hashtable;
|
|
if (hashtable == null)
|
|
{
|
|
hashtable = new Hashtable();
|
|
this.LoadAssemblyLicenses(hashtable, resourceAssembly);
|
|
this.extraassemblies[resourceAssembly.FullName] = hashtable;
|
|
}
|
|
return (string)hashtable[type.AssemblyQualifiedName];
|
|
}
|
|
this.LoadKeys();
|
|
return (string)this.keys[type.AssemblyQualifiedName];
|
|
}
|
|
|
|
// Token: 0x06000333 RID: 819 RVA: 0x00009DF8 File Offset: 0x00007FF8
|
|
public override void SetSavedLicenseKey(Type type, string key)
|
|
{
|
|
if (type == null)
|
|
{
|
|
throw new ArgumentNullException("type");
|
|
}
|
|
this.LoadKeys();
|
|
this.keys[type.AssemblyQualifiedName] = key;
|
|
}
|
|
|
|
// Token: 0x040000D3 RID: 211
|
|
private Hashtable extraassemblies;
|
|
|
|
// Token: 0x040000D4 RID: 212
|
|
private Hashtable keys;
|
|
}
|
|
}
|