public void Release() { if (pFactory != null) { ProtocolFactoryManager.UnRegisterProtocolFactory(pFactory); pFactory = null; } //if (libHandler != null) //{ // AppDomain.Unload(appDomain); //} }
public static bool UnRegisterProtocolFactory(BaseProtocolFactory pFactory) { if (pFactory == null) { Logger.WARN("pFactory is null"); return(true); } if (!_factoriesById.ContainsKey(pFactory.Id)) { Logger.WARN("Factory id not found: {0}", pFactory.Id); return(true); } pFactory.HandledProtocolChains.AsParallel().ForAll(x => _factoriesByChainName.Remove(x)); pFactory.HandledProtocols.AsParallel().ForAll(x => _factoriesByProtocolId.Remove(x)); _factoriesById.Remove(pFactory.Id); return(true); }
public static bool UnRegisterProtocolFactory(BaseProtocolFactory pFactory) { if (pFactory == null) { Logger.WARN("pFactory is null"); return true; } if (!_factoriesById.ContainsKey(pFactory.Id)) { Logger.WARN("Factory id not found: {0}",pFactory.Id); return true; } pFactory.HandledProtocolChains.AsParallel().ForAll(x => _factoriesByChainName.Remove(x)); pFactory.HandledProtocols.AsParallel().ForAll(x => _factoriesByProtocolId.Remove(x)); _factoriesById.Remove(pFactory.Id); return true; }
public static bool RegisterProtocolFactory(this BaseProtocolFactory pFactory) {//1. Test to see if this factory is already registered if (_factoriesById.ContainsKey(pFactory.Id)) { Logger.FATAL("Factory id {0} already registered", pFactory.Id); return(false); } //2. Test to see if the protocol chains exported by this factory are already in use if (pFactory.HandledProtocolChains.Any(x => _factoriesByChainName.ContainsKey(x))) { Logger.FATAL("protocol chain already handled by factory "); return(false); } //3. Test to see if the protocols exported by this factory are already in use if (pFactory.HandledProtocols.Any(x => _factoriesByProtocolId.ContainsKey(x))) { Logger.FATAL("protocol already handled by factory "); return(false); } //4. Register everything #if PARALLEL pFactory.HandledProtocolChains().AsParallel().ForAll(x => _factoriesByChainName[x] = pFactory); pFactory.HandledProtocols().AsParallel().ForAll(x => _factoriesByProtocolId[x] = pFactory); #else foreach (var handledProtocolChain in pFactory.HandledProtocolChains) { _factoriesByChainName[handledProtocolChain] = pFactory; } foreach (var handledProtocol in pFactory.HandledProtocols) { _factoriesByProtocolId[handledProtocol] = pFactory; } #endif _factoriesById[pFactory.Id] = pFactory; return(true); }
public bool ConfigFactory() { if (getFactory == null) return true; pFactory = getFactory(config); if (pFactory == null) return true; if (pFactory.RegisterProtocolFactory()) { INFO("Loaded factory from application {0}", config[CONF_APPLICATION_NAME]); return true; } FATAL("Unable to register factory exported by application {0}", config[CONF_APPLICATION_NAME]); return false; }