Пример #1
0
        private static void AddPlugin(string plugin_path)
        {
            AssemblyName name     = AssemblyName.GetAssemblyName(plugin_path);
            Assembly     assembly = Assembly.Load(name);

            System.Diagnostics.Trace.WriteLine("Loaded " + assembly.FullName);
            foreach (Type type in assembly.GetExportedTypes())
            {
                try
                {
                    if (!type.IsClass || type.IsAbstract)
                    {
                        continue;
                    }
                    if (type.GetInterface(typeof(IAudioDecoderSettings).Name) != null)
                    {
                        decs.Add(Activator.CreateInstance(type) as IAudioDecoderSettings);
                    }
                    if (type.GetInterface(typeof(IAudioEncoderSettings).Name) != null)
                    {
                        encs.Add(Activator.CreateInstance(type) as IAudioEncoderSettings);
                    }
                    CompressionProviderClass archclass = Attribute.GetCustomAttribute(type, typeof(CompressionProviderClass)) as CompressionProviderClass;
                    if (archclass != null)
                    {
                        arcp.Add(type);
                        if (!arcp_fmt.Contains(archclass.Extension))
                        {
                            arcp_fmt.Add(archclass.Extension);
                        }
                    }
                    if (type.Name == "HDCDDotNet")
                    {
                        hdcd = type;
                    }
                    if (type.GetInterface(typeof(ICDRipper).Name) != null)
                    {
                        ripper = type;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                }
            }
        }
Пример #2
0
        private static void AddPlugin(string plugin_path)
        {
            AssemblyName name     = AssemblyName.GetAssemblyName(plugin_path);
            Assembly     assembly = Assembly.Load(name, Assembly.GetEntryAssembly().Evidence);

            System.Diagnostics.Trace.WriteLine("Loaded " + assembly.FullName);
            foreach (Type type in assembly.GetExportedTypes())
            {
                try
                {
                    if (Attribute.GetCustomAttribute(type, typeof(AudioDecoderClass)) != null)
                    {
                        decs.Add(type);
                    }
                    //if (type.IsClass && !type.IsAbstract && typeof(IAudioDest).IsAssignableFrom(type))
                    if (Attribute.GetCustomAttributes(type, typeof(AudioEncoderClassAttribute)).Length > 0)
                    {
                        encs.Add(type);
                    }
                    CompressionProviderClass archclass = Attribute.GetCustomAttribute(type, typeof(CompressionProviderClass)) as CompressionProviderClass;
                    if (archclass != null)
                    {
                        arcp.Add(type);
                        if (!arcp_fmt.Contains(archclass.Extension))
                        {
                            arcp_fmt.Add(archclass.Extension);
                        }
                    }
                    if (type.Name == "HDCDDotNet")
                    {
                        hdcd = type;
                    }
                    if (type.IsClass && !type.IsAbstract && typeof(ICDRipper).IsAssignableFrom(type))
                    {
                        ripper = type;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(ex.Message);
                }
            }
        }