internal CILAssemblyImpl( CILReflectionContextImpl ctx, Int32 anID, System.Reflection.Assembly ass ) : base(ctx, anID, CILElementKind.Assembly, () => new CustomAttributeDataEventArgs(ctx, ass)) { ArgumentValidator.ValidateNotNull("Assembly", ass); InitFields( ref this.name, ref this.modules, ref this.forwardedTypes, ref this.mainModule, () => { var result = CILAssemblyName.Parse(ass.FullName); var args = new AssemblyNameEventArgs(ass); ctx.LaunchAssemblyNameLoadEvent(args); var info = args.AssemblyNameInfo; if (info != null) { result.HashAlgorithm = info.Item1; result.Flags = info.Item2; if (info.Item3 != null) { result.PublicKey = info.Item3; if (result.PublicKey.IsNullOrEmpty()) { // .NET for some reason returns PublicKey-flag set, even with no public key... result.Flags = result.Flags & ~(AssemblyFlags.PublicKey); } } } return(result); }, () => ctx.CollectionsFactory.NewListProxy <CILModule>(ass .GetModules() .Select(module => ctx.Cache.GetOrAdd(module)) .ToList()), () => { // TODO seems that getting type forward info is not really possible via C# managed reflection API? throw new NotImplementedException(); }, () => ctx.Cache.GetOrAdd(ass.ManifestModule) ); }
private static void ctx_AssemblyNameLoadEvent(object sender, AssemblyNameEventArgs e) { var name = e.Assembly.GetName(); e.AssemblyNameInfo = Tuple.Create((AssemblyHashAlgorithm)name.HashAlgorithm, (AssemblyFlags)name.Flags, name.GetPublicKey()); }