@@ -15,34 +15,25 @@ public class QpClientTypeManager
1515 public static QpClientTypeManager Instance { get ; } = new QpClientTypeManager ( ) ;
1616 private Dictionary < string , QpClientTypeInfo > dict = null ;
1717
18- private void register < TClient > ( )
18+ private void register ( Type clientType , Type clientOptionsType )
1919 {
20- register ( typeof ( TClient ) ) ;
21- }
22-
23- private void register ( Type type )
24- {
25- var typeConstructor = type . GetConstructors ( ) [ 0 ] ;
26- var typeConstructorParameters = typeConstructor . GetParameters ( ) ;
27- if ( typeConstructorParameters == null || typeConstructorParameters . Length != 1 )
28- return ;
29- var optionsType = typeConstructorParameters [ 0 ] . ParameterType ;
30- var name = type . GetCustomAttribute < DisplayNameAttribute > ( ) ? . DisplayName ?? type . Name ;
31- dict [ type . FullName ] = new QpClientTypeInfo ( )
20+ var clientTypeFullName = clientType . FullName ;
21+ var name = clientType . GetCustomAttribute < DisplayNameAttribute > ( ) ? . DisplayName ?? clientTypeFullName ;
22+ dict [ clientTypeFullName ] = new QpClientTypeInfo ( )
3223 {
3324 Name = name ,
34- QpClientType = type ,
35- QpClientOptionsType = optionsType
25+ QpClientType = clientType ,
26+ QpClientOptionsType = clientOptionsType
3627 } ;
3728 }
3829
3930 public void Init ( )
4031 {
4132 dict = new Dictionary < string , QpClientTypeInfo > ( ) ;
42- register < Quick . Protocol . Tcp . QpTcpClient > ( ) ;
43- register < Quick . Protocol . Pipeline . QpPipelineClient > ( ) ;
44- register < Quick . Protocol . SerialPort . QpSerialPortClient > ( ) ;
45- register < Quick . Protocol . WebSocket . Client . QpWebSocketClient > ( ) ;
33+ register ( typeof ( Quick . Protocol . Tcp . QpTcpClient ) , typeof ( Quick . Protocol . Tcp . QpTcpClientOptions ) ) ;
34+ register ( typeof ( Quick . Protocol . Pipeline . QpPipelineClient ) , typeof ( Quick . Protocol . Pipeline . QpPipelineClientOptions ) ) ;
35+ register ( typeof ( Quick . Protocol . SerialPort . QpSerialPortClient ) , typeof ( Quick . Protocol . SerialPort . QpSerialPortClientOptions ) ) ;
36+ register ( typeof ( Quick . Protocol . WebSocket . Client . QpWebSocketClient ) , typeof ( Quick . Protocol . WebSocket . Client . QpWebSocketClientOptions ) ) ;
4637 }
4738
4839 public QpClientTypeInfo Get ( string qpClientTypeName )
0 commit comments