Beispiel #1
0
 /// <summary>
 /// Construct a module assembly from an assembly. Automatically find and load the ModuleInfo type
 /// for the module assembly.
 /// </summary>
 /// <param name="Assembly"></param>
 /// <param name="FileName"></param>
 public ModuleAssembly(Assembly Assembly, String FileName)
 {
     this.Assembly = Assembly;
     var InfoType = Assembly.GetTypes().FirstOrDefault(t => t.IsSubclassOf(typeof(ModuleInfo)));
     Info = Activator.CreateInstance(InfoType) as ModuleInfo;
     if (Info == null) throw new InvalidOperationException("Specified assembly is not a module.");
     this.FileName = FileName;
 }
Beispiel #2
0
        /// <summary>
        /// Construct a module assembly from an assembly on disc. Automatically find and load the ModuleInfo
        /// type.
        /// </summary>
        /// <param name="FileName">The assembly file to load</param>
        public ModuleAssembly(String FileName)
        {
            FileName = System.IO.Path.GetFullPath(FileName);
            this.FileName = FileName;

            Assembly = System.Reflection.Assembly.LoadFrom(FileName);
            if (Assembly == null) throw new InvalidOperationException("Could not load assembly " + FileName);

            Info = Activator.CreateInstance(Assembly.GetTypes().FirstOrDefault(t => t.IsSubclassOf(typeof(ModuleInfo)))) as ModuleInfo;
            if (Info == null) throw new InvalidOperationException("Specified assembly is not a module.");
        }
Beispiel #3
0
 /// <summary>
 /// Construct a module assembly from an assembly
 /// </summary>
 /// <param name="Assembly"></param>
 /// <param name="Info"></param>
 /// <param name="FileName"></param>
 public ModuleAssembly(Assembly Assembly, ModuleInfo Info, String FileName = "")
 {
     this.Assembly = Assembly;
     this.Info = Info;
     this.FileName = FileName;
 }