protected static TransportAddress NoCacheCreateInstance(string s) { string scheme = s.Substring(0, s.IndexOf(":")); string t = scheme.Substring(scheme.IndexOf('.') + 1); //Console.Error.WriteLine(t); TransportAddress result = null; TransportAddress.TAType ta_type = StringToType(t); if (ta_type == TransportAddress.TAType.Tcp) { result = new IPTransportAddress(s); } if (ta_type == TransportAddress.TAType.Udp) { result = new IPTransportAddress(s); } if (ta_type == TransportAddress.TAType.Function) { result = new IPTransportAddress(s); } if (ta_type == TransportAddress.TAType.Tls) { result = new IPTransportAddress(s); } if (ta_type == TransportAddress.TAType.TlsTest) { result = new IPTransportAddress(s); } if (ta_type == TransportAddress.TAType.Tunnel) { result = new TunnelTransportAddress(s); } return result; }
protected static TransportAddress NoCacheCreateInstance(string s) { string scheme = s.Substring(0, s.IndexOf(":")); string t = scheme.Substring(scheme.IndexOf('.') + 1); //Console.Error.WriteLine(t); TransportAddress result = null; TransportAddress.TAType ta_type = StringToType(t); switch(ta_type) { case TransportAddress.TAType.Tcp: result = new IPTransportAddress(s); break; case TransportAddress.TAType.Udp: result = new IPTransportAddress(s); break; case TransportAddress.TAType.Function: result = new IPTransportAddress(s); break; case TransportAddress.TAType.S: result = new SimulationTransportAddress(s); break; case TransportAddress.TAType.Tls: result = new IPTransportAddress(s); break; case TransportAddress.TAType.TlsTest: result = new IPTransportAddress(s); break; case TransportAddress.TAType.Tunnel: result = new TunnelTransportAddress(s); break; } return result; }
public static TransportAddress CreateInstance(TransportAddress.TAType t, System.Net.IPAddress host, int port) { Cache ta_cache = Interlocked.Exchange<Cache>(ref _ta_cache, null); if( ta_cache != null ) { TransportAddress ta = null; try { CacheKey key = new CacheKey(host, port, t); ta = (TransportAddress) ta_cache[key]; if( ta == null ) { ta = new IPTransportAddress(t, host, port); ta_cache[key] = ta; } } finally { Interlocked.Exchange<Cache>(ref _ta_cache, ta_cache); } return ta; } else { return new IPTransportAddress(t, host, port); } }