Esempio n. 1
0
        public IDoBadStuff Get()
        {
            IDoBadStuff test = null;

            GetDlls().ForEach(d =>
            {
                try
                {
                    foreach (Type t in Assembly.LoadFrom(d).GetTypes())
                    {
                        if (typeof(IDoBadStuff) == t)
                        {
                            continue;
                        }
                        if (t.GetInterface(typeof(IDoBadStuff).FullName) is null)
                        {
                            continue;
                        }

                        test = (IDoBadStuff)Activator.CreateInstance(t);
                    }
                }
                catch { }
            });

            return(test);
        }
Esempio n. 2
0
        // Check wether a .dll file implementing IDoBadStuff is available
        // if its available, it replaces the default bad stuff object
        private void InitializeBadStuff()
        {
            try
            {
                DoBadStuff = InterfaceLoader.Get <IDoBadStuff>(true);

                if (DoBadStuff is null)
                {
                    DoBadStuff = new DefaultBadStuff();
                }
            }
            catch (Exception ex)
            {
                DoBadStuff = new DefaultBadStuff();
                if (Configuration.DebugMode)
                {
                    MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }