public void Initializes(string optionFile) { string optionFilePath = string.Empty; if (File.Exists(optionFile)) { optionFilePath = optionFile; } else { optionFilePath = Path.Combine(ApplicationStartPath, optionFile); } this.OptionFile = OptionFile.Load(optionFilePath); this.OptionDocument = new XmlDocument(); this.OptionDocument.Load(optionFilePath); StringCollection files = UtilityFile.SearchDirectory(ApplicationStartPath, "*.dll", true, true); foreach (string file in files) { Assembly ass = Assembly.LoadFile(file); Type[] types = ass.GetTypes(); foreach (Type type in types) { if (type.IsDefined(typeof(OptionAttribute), false))//如果Class被定制特性标记 { object[] objs = type.GetCustomAttributes(false); foreach (var obj in objs) { if (!(obj is OptionAttribute)) { continue; } Option[] options = Option.Load(ass, type, (OptionAttribute)obj); foreach (Option o in options) { o.OptionChangingEvent += new Option.OptionChangingEventHandler(OptionChangingEvent); } } } } } }