Пример #1
0
 protected GraphLabsModuleInfo(string fileName,
                   string title,
                   string version,
                   IGraphLabsModule module)
 {
     _fileName = fileName;
     _title = title;
     _version = version;
     _module = module;
 }
Пример #2
0
        public bool ReloadModule()
        {
            Assembly assembly = Assembly.LoadFile(Environment.CurrentDirectory + "\\" + _fileName);
            Type[] typesAll = assembly.GetExportedTypes();

            List<Type> types = new List<Type>();
            foreach (Type t in typesAll)
                if (typeof(UserControl).IsAssignableFrom(t) &&
                    (typeof(IGraphLabsModule).IsAssignableFrom(t)))
                    types.Add(t);
            if (types.Count != 1)
                return false;
            string moduleName = assembly.FullName.Substring(0, assembly.FullName.IndexOf(','));
            int indexStart = assembly.FullName.LastIndexOf("Version=") + 8;
            string moduleVersion = assembly.FullName.Substring(indexStart, assembly.FullName.IndexOf(',', indexStart) - indexStart);
            if (moduleVersion != _version && MessageBox.Show(string.Format("Версия используемого в загружаемой работе модуля {0} отличается от установленной.\n" +
                "Требуется: {1}; Установлена: {2}.\n Всё равно продолжить?", _fileName, moduleVersion, _version), "", MessageBoxButtons.YesNo,
                MessageBoxIcon.Warning) == DialogResult.No)
                return false;
            _module = (IGraphLabsModule)Activator.CreateInstance(types[0]);
            return true;
        }