File tree Expand file tree Collapse file tree 4 files changed +24
-7
lines changed
Expand file tree Collapse file tree 4 files changed +24
-7
lines changed Original file line number Diff line number Diff line change 1313using System . Text ;
1414using System . Threading . Tasks ;
1515using System . Windows . Forms ;
16+ using QpTestClient . Utils ;
1617
1718namespace QpTestClient
1819{
@@ -31,8 +32,8 @@ public ConnectForm()
3132 }
3233
3334 public void EditConnectionInfo ( TestConnectionInfo connectionInfo )
34- {
35- this . ConnectionInfo = XmlConvert . Deserialize < TestConnectionInfo > ( XmlConvert . Serialize ( connectionInfo ) ) ;
35+ {
36+ this . ConnectionInfo = XmlConvert . Deserialize < TestConnectionInfo > ( XmlConvert . Serialize ( connectionInfo ) , QpdFileUtils . XmlConvertOptions ) ;
3637 txtName . Text = connectionInfo . Name ;
3738 var qpClientTypeInfo = QpClientTypeManager . Instance . GetAll ( ) . FirstOrDefault ( t => t . ClientType . FullName == connectionInfo . QpClientTypeName ) ;
3839 cbConnectType . SelectedItem = qpClientTypeInfo ;
Original file line number Diff line number Diff line change 5454 </ItemGroup >
5555
5656 <ItemGroup >
57- <PackageReference Include =" Quick.Xml" Version =" 1.0.1 " />
57+ <PackageReference Include =" Quick.Xml" Version =" 1.0.2 " />
5858 </ItemGroup >
5959
6060 <ItemGroup >
Original file line number Diff line number Diff line change 1- using Newtonsoft . Json . Linq ;
2- using Quick . Protocol ;
1+ using Quick . Protocol ;
32using System ;
43using System . Collections . Generic ;
54using System . Text ;
Original file line number Diff line number Diff line change 1- using System ;
1+ using Quick . Protocol ;
2+ using Quick . Xml ;
3+ using System ;
24using System . Collections . Generic ;
35using System . IO ;
6+ using System . Linq ;
47using System . Text ;
58
69namespace QpTestClient . Utils
@@ -47,10 +50,24 @@ public static void DeleteQpbFile(TestConnectionInfo connectionInfo)
4750 File . Delete ( file ) ;
4851 }
4952
53+ public static Quick . Xml . XmlConvertOptions XmlConvertOptions { get ; private set ; }
54+
5055 public static TestConnectionInfo Load ( string file )
5156 {
57+ if ( XmlConvertOptions == null )
58+ {
59+ XmlConvertOptions = new XmlConvertOptions ( )
60+ {
61+ InstanceFactory = QpClientTypeManager . Instance . GetAll ( ) . ToDictionary ( t => t . OptionsType , t =>
62+ {
63+ return new Func < object > ( ( ) => t . CreateOptionsInstanceFunc ( ) ) ;
64+ } )
65+ } ;
66+ XmlConvertOptions . InstanceFactory . Add ( typeof ( TestConnectionInfo ) , ( ) => new TestConnectionInfo ( ) ) ;
67+ XmlConvertOptions . InstanceFactory . Add ( typeof ( QpInstruction ) , ( ) => new QpInstruction ( ) ) ;
68+ }
5269 var content = File . ReadAllText ( file ) ;
53- return Quick . Xml . XmlConvert . Deserialize < TestConnectionInfo > ( content ) ;
70+ return Quick . Xml . XmlConvert . Deserialize < TestConnectionInfo > ( content , XmlConvertOptions ) ;
5471 }
5572 }
5673}
You can’t perform that action at this time.
0 commit comments