// Load assembly and find video encoder descriptors there private void LoadAssembly(string fname) { try { Type typeVideoSourceDesc = typeof(VsICoreEncoderDescription); Assembly asm = null; // try to load assembly asm = Assembly.LoadFrom(fname); // get types of the assembly Type[] types = asm.GetTypes(); // check all types foreach (Type type in types) { // get interfaces ot the type Type[] interfaces = type.GetInterfaces(); // check, if the type is inherited from VsICoreEncoderDescription if (Array.IndexOf(interfaces, typeVideoSourceDesc) != -1) { VsICoreEncoderDescription desc = null; try { // create an instance of the type desc = (VsICoreEncoderDescription)Activator.CreateInstance(type); // create encoder object InnerList.Add(new VsEncoder(desc)); } catch (Exception err) { // something failed during instance creatinion Console.WriteLine(err.Message); } } } } catch (Exception err) { //logger.Log(LogLevel.Error, err.Message + " " + err.Source + " " + err.StackTrace);; Console.WriteLine(err.Message); } }
// Constructor public VsEncoder(VsICoreEncoderDescription encoderDesc) { this.encoderDesc = encoderDesc; }