Ejemplo n.º 1
0
        public static void AddExternalAddIns(IList <AddIn> addIns)
        {
            List <string> addInFiles = new List <string>();
            List <string> disabled   = new List <string>();

            LoadAddInConfiguration(addInFiles, disabled);

            foreach (AddIn addIn in addIns)
            {
                if (!addInFiles.Contains(addIn.FileName))
                {
                    addInFiles.Add(addIn.FileName);
                }
                addIn.Enabled = false;
                addIn.Action  = AddInAction.Install;
                AddInTree.InsertAddIn(addIn);
            }

            SaveAddInConfiguration(addInFiles, disabled);
        }
Ejemplo n.º 2
0
        public static void Load(System.Collections.Generic.List <string> addInFiles, List <string> disabledAddIns)
        {
            System.Collections.Generic.List <AddIn> list = new System.Collections.Generic.List <AddIn>();
            System.Collections.Generic.Dictionary <string, System.Version> dictionary  = new System.Collections.Generic.Dictionary <string, System.Version>();
            System.Collections.Generic.Dictionary <string, AddIn>          dictionary2 = new System.Collections.Generic.Dictionary <string, AddIn>();
            foreach (string current in addInFiles)
            {
                AddIn addIn;
                try
                {
                    addIn = AddIn.Load(current);
                }
                catch (System.Exception ex)
                {
                    addIn = new AddIn();
                    addIn.addInFileName      = current;
                    addIn.CustomErrorMessage = ex.Message;
                }
                if (addIn.Action == AddInAction.CustomError)
                {
                    list.Add(addIn);
                }
                else
                {
                    addIn.Enabled = true;
                    if (disabledAddIns != null && disabledAddIns.Count > 0)
                    {
                        foreach (string current2 in addIn.Manifest.Identities.Keys)
                        {
                            if (disabledAddIns.Contains(current2))
                            {
                                addIn.Enabled = false;
                                break;
                            }
                        }
                    }
                    if (addIn.Enabled)
                    {
                        foreach (System.Collections.Generic.KeyValuePair <string, System.Version> current3 in addIn.Manifest.Identities)
                        {
                            if (dictionary.ContainsKey(current3.Key))
                            {
                                addIn.Enabled = false;
                                addIn.Action  = AddInAction.InstalledTwice;
                                break;
                            }
                            dictionary.Add(current3.Key, current3.Value);
                            dictionary2.Add(current3.Key, addIn);
                        }
                    }
                    list.Add(addIn);
                }
            }
            while (true)
            {
IL_175:
                for (int i = 0; i < list.Count; i++)
                {
                    AddIn addIn2 = list[i];
                    if (addIn2.Enabled)
                    {
                        foreach (AddInReference current4 in addIn2.Manifest.Conflicts)
                        {
                            System.Version version;
                            if (current4.Check(dictionary, out version))
                            {
                                AddInTree.DisableAddin(addIn2, dictionary, dictionary2);
                                goto IL_175;
                            }
                        }
                        foreach (AddInReference current5 in addIn2.Manifest.Dependencies)
                        {
                            System.Version version;
                            if (!current5.Check(dictionary, out version))
                            {
                                AddInTree.DisableAddin(addIn2, dictionary, dictionary2);
                                goto IL_175;
                            }
                        }
                    }
                }
                break;
            }
            foreach (AddIn current6 in list)
            {
                try
                {
                    AddInTree.InsertAddIn(current6);
                }
                catch (System.Exception ex2)
                {
                    MessageBox.Show(ex2.Message);
                }
            }
        }