static List <IInteractionContextProxy> loadAllSpecializedScriptFunctionProxyExtension(string path) { List <IInteractionContextProxy> ssfp = new List <IInteractionContextProxy>(); if (System.IO.Directory.Exists(path)) { // load all available Types implementing the requested interface var proxies = extensibility.ExtensionLoader .LoadAllExtensions (typeof(IInteractionContextProxy), path ); // get list of extensions that should not been loaded var blocked = GetBlockedExtensionList(); // build the specialized function proxies if (proxies != null && proxies.Count > 0) { foreach (var suppl in proxies) { if (blocked.Contains(suppl.Key)) { continue; } try { var types = suppl.Value; if (types != null && types.Count > 0) { foreach (Type type in types) { if (typeof(IInteractionContextProxy).IsAssignableFrom(type)) { IInteractionContextProxy o = extensibility.ExtensionLoader.CreateObjectFromType(type) as IInteractionContextProxy; if (o != null) { ssfp.Add(o); } } } } } catch (System.Exception ex) { Logger.Instance.Log(LogPriority.DEBUG, "LectorGUI", "[ERROR] Can't build instance of specialized function proxy:\n" + ex); } } } } return(ssfp); }
/// <summary> /// Removes the function proxy. /// </summary> /// <param name="proxy">The proxy.</param> /// <returns></returns> public bool RemoveFunctionProxy(IInteractionContextProxy proxy) { if (proxy != null && proxies != null && proxies.Contains(proxy.GetHashCode())) { try { proxy.Active = false; proxy.UnregisterFromEvents(eventForwarder); proxies.Remove(proxy.GetHashCode()); } catch (System.Exception ex) { Logger.Instance.Log(LogPriority.ALWAYS, this, "Can not remove specialized function proxy", ex); } } return true; }
/// <summary> /// Adds a new proxy for receiving interaction events. /// </summary> /// <param name="proxy">The proxy.</param> /// <returns><c>true</c> if the proxy could been added.</returns> public bool AddProxy(IInteractionContextProxy proxy) { if (proxy != null && proxies != null) { if (proxies.Contains(proxy.GetHashCode())) return false; try { proxies.Add(proxy.GetHashCode(), proxy); reregisterEventHandlers(); return true; } catch (Exception ex) { Logger.Instance.Log(LogPriority.ALWAYS, this, "Can not add specialized function proxy", ex); } } return false; }