public VendorParser(Locale locale, int flags) : base(locale, flags) { m_extendedCostStorage = DBFileLoader.GetLoader <ItemExtendedCost>(); if (m_extendedCostStorage == null) { throw new ArgumentNullException("_itemExtendedCost"); } Builder.Setup("npc_vendor", "entry", false, "item", "maxcount", "incrtime", "ExtendedCost"); }
protected override void OnLoad(EventArgs e) { #region Language loading string stringCulture = Settings.Default.Culture; foreach (string language in _language) { MenuItem item = new MenuItem(language, LanguageMenuItemClick) { Checked = stringCulture.Equals(language) }; languageMenuItem.MenuItems.Add(item); } _currentCulture = new CultureInfo(stringCulture, true); ReloadUILanguage(); #endregion #region Files loading DBFileLoader.Initial(); LoadWelfFiles(); #endregion #region Parsers loading int loadedParsers = 0; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; ++i) { Type type = types[i]; if (!type.IsSubclassOf(typeof(PageParser))) { continue; } ParserAttribute[] attributes = type.GetCustomAttributes(typeof(ParserAttribute), true) as ParserAttribute[]; if (attributes == null || attributes.Length < 1) { throw new InvalidOperationException(); // Each parsers should be marked with this attribute } parserBox.Items.Add(GetNameByParserType(attributes[0].Type)); _parsers.Add(loadedParsers++, new KeyValuePair <ParserType, Type>(attributes[0].Type, type)); } parserBox.SelectIndex(Settings.Default.LastParser); #endregion #region Locale loading parserBox.SelectIndex(Settings.Default.LastParser); localeBox.SetEnumValues <Locale>(Settings.Default.LastLocale); #endregion #region Plugins loading string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), DllExtension, SearchOption.TopDirectoryOnly); foreach (string file in files) { Assembly assembly = Assembly.LoadFile(file); foreach (Type type in assembly.GetTypes()) { if (type.GetInterface(typeof(IPlugin).Name, true) == null) { continue; } IPlugin plugin = Activator.CreateInstance(type) as IPlugin; if (plugin == null) { continue; } MenuItem item = new MenuItem(plugin.Name, PluginMenuItemClick) { Tag = plugin }; editMenuItem.MenuItems.Add(item); } } #endregion }