Mono.Addins.AddinEngine.LoadAddin C# (CSharp) Method

LoadAddin() private method

private LoadAddin ( IProgressStatus statusMonitor, string id, bool throwExceptions ) : bool
statusMonitor IProgressStatus
id string
throwExceptions bool
return bool
        internal bool LoadAddin(IProgressStatus statusMonitor, string id, bool throwExceptions)
        {
            try {
                lock (LocalLock) {
                    if (IsAddinLoaded (id))
                        return true;

                    if (!Registry.IsAddinEnabled (id)) {
                        string msg = GettextCatalog.GetString ("Disabled add-ins can't be loaded.");
                        ReportError (msg, id, null, false);
                        if (throwExceptions)
                            throw new InvalidOperationException (msg);
                        return false;
                    }

                    ArrayList addins = new ArrayList ();
                    Stack depCheck = new Stack ();
                    ResolveLoadDependencies (addins, depCheck, id, false);
                    addins.Reverse ();

                    if (statusMonitor != null)
                        statusMonitor.SetMessage ("Loading Addins");

                    for (int n=0; n<addins.Count; n++) {

                        if (statusMonitor != null)
                            statusMonitor.SetProgress ((double) n / (double)addins.Count);

                        Addin iad = (Addin) addins [n];
                        if (IsAddinLoaded (iad.Id))
                            continue;

                        if (statusMonitor != null)
                            statusMonitor.SetMessage (string.Format(GettextCatalog.GetString("Loading {0} add-in"), iad.Id));

                        if (!InsertAddin (statusMonitor, iad))
                            return false;
                    }
                    return true;
                }
            }
            catch (Exception ex) {
                ReportError ("Add-in could not be loaded: " + ex.Message, id, ex, false);
                if (statusMonitor != null)
                    statusMonitor.ReportError ("Add-in '" + id + "' could not be loaded.", ex);
                if (throwExceptions)
                    throw;
                return false;
            }
        }

Same methods

AddinEngine::LoadAddin ( IProgressStatus statusMonitor, string id ) : void

Usage Example

コード例 #1
0
        public override bool Evaluate(ExtensionContext ctx)
        {
            if (!base.Evaluate(ctx))
            {
                return(false);
            }

            if (!string.IsNullOrEmpty(addin))
            {
                // Make sure the add-in that implements the condition is loaded
                addinEngine.LoadAddin(null, addin, true);
                addin = null;                 // Don't try again
            }

            ConditionType type = ctx.GetCondition(typeId);

            if (type == null)
            {
                addinEngine.ReportError("Condition '" + typeId + "' not found in current extension context.", null, null, false);
                return(false);
            }

            try {
                return(type.Evaluate(node));
            }
            catch (Exception ex) {
                addinEngine.ReportError("Error while evaluating condition '" + typeId + "'", null, ex, false);
                return(false);
            }
        }
All Usage Examples Of Mono.Addins.AddinEngine::LoadAddin