示例#1
0
        private void buttonRemovePlugin_Click(object sender, EventArgs e)
        {
            object o = ListPlugins.SelectedItem;

            osalot.AssemblyTracker tracker = o as osalot.AssemblyTracker;
            tracker.removed = true;
            ListPlugins.Items.Remove(o);
        }
示例#2
0
            static bool LoadDepartments(osalot.AssemblyTracker tracker, Type[] assembly_types)
            {
                bool useful = false;

                foreach (Type t in assembly_types)
                {
                    Type[] interfaces;
                    interfaces = t.FindInterfaces(MyInterfaceFilter, "DepartmentInterface");
                    if (interfaces.Length > 0)
                    {
                        DepartmentInterface Department = Activator.CreateInstance(t) as DepartmentInterface;
                        useful = true;
                        Departments.Add(Department);
                    }
                }
                return(useful);
            }
示例#3
0
            internal static bool LoadAssembly(string name, out xperdex.core.osalot.AssemblyTracker tracker)
            {
                Assembly a;

                tracker = null;
                try
                {
                    a = LoadAssembly(name);
                    if (a == null)
                    {
                        return(false);
                    }

                    if (tracker == null)
                    {
                        tracker = new osalot.AssemblyTracker(a);
                    }
                    else
                    {
                        tracker.assembly = a;
                    }

                    foreach (osalot.AssemblyTracker assembly in POS.Local.assemblies)
                    {
                        if (String.Compare(assembly.ToString(), tracker.ToString()) == 0)
                        {
                            // uhmm really trusting garbabe collector here...
                            tracker.assembly = null;
                            a = null;
                            //outitems = null;
                            tracker = null;
                            return(false);
                        }
                    }
                    Type[] assembly_types = null;
                    try
                    {
                        assembly_types = a.GetTypes();
                    }
                    catch (Exception ex)
                    {
                        Log.log("Failed to get types from assembly." + ex.Message);
                        a = null;
                        tracker.assembly = null;
                        POS.Local.assemblies.Remove(tracker);
                        tracker = null;
                        return(false);
                    }

                    bool useful = false;

                    // search for any objects which implement IReflectorPlugin method Preload()

                    if (LoadDepartments(tracker, assembly_types))
                    {
                        useful = true;
                    }


                    if (useful)
                    {
                        POS.Local.assemblies.Add(tracker);

                        return(useful);                        // just cause there's no menu options (IReflectorSecurity) doesn't mean we didn't use it...
                    }
                    else
                    {
                        // help garbage collection...
                        tracker.assembly = null;
                        tracker          = null;
                        a = null;
                    }
                }
                catch (FileNotFoundException)
                {
                    Console.WriteLine("Could not load Assembly: \"{0}\"", name);
                }
                catch (TypeLoadException)
                {
                    Console.WriteLine("Could not load Type: \"{0}\"\nfrom assembly: \"{1}\"", name);
                }

                return(false);
            }