For some reason I read as "Assembly". This is what a module is:
http://bytes.com/forum/thread250595.html
From my memory of reading Richter's book on .NET 1.1 some years ago you can
make an assembly up from multiple modules, however, the C# compiler creates
only a single module per assembly. I suspect VB.net lets you create modules
within an assembly, but I don't touch that language and it's purely a guess.
Anyway, the following code illustrates that defining an attribute on a
module in C# applies it to all classes within the assembly...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Linq;
using System.Reflection;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
var classes =
from c in typeof(Form1).Assembly.GetTypes()
where c.Module.GetCustomAttributes(typeof(MyModuleAttribute),
true).Length > 0
select c;
foreach (Type c in classes)
System.Diagnostics.Debug.WriteLine("Defined on: " + c.Name);
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace WindowsFormsApplication3.CompanyStuff
{
class Company
{
}
}
using System;
using System.Collections.Generic;
using System.Text;
[module: WindowsFormsApplication3.MyModule]
namespace WindowsFormsApplication3.PersonStuff
{
class Person
{
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace WindowsFormsApplication3
{
[AttributeUsage(AttributeTargets.Module)]
public class MyModuleAttribute : Attribute
{
}
}