Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
Thick-Common
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
Thick-Common
Commits
eaf0704a
Commit
eaf0704a
authored
Mar 26, 2021
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化 SysParam 改为 保存 json文件
parent
da297f04
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
14 deletions
+39
-14
SysParam.cs
Project.FLY.Thick.Base/FLY.Thick.Base/Server/SysParam.cs
+39
-14
No files found.
Project.FLY.Thick.Base/FLY.Thick.Base/Server/SysParam.cs
View file @
eaf0704a
...
...
@@ -8,23 +8,23 @@ using System.IO;
using
System.ComponentModel
;
using
System.Xml.Serialization
;
using
FLY.Thick.Base.Common
;
using
Newtonsoft.Json
;
namespace
FLY.Thick.Base.Server
{
//代替TDInitParam
public
class
SysParam
:
INotifyPropertyChanged
,
ISaveToXml
public
class
SysParam
:
INotifyPropertyChanged
{
#
region
属性,成员变量的代理
/// <summary>
/// 本机obj服务地址
/// </summary>
[
PropertyChanged
.
DoNotCheckEquality
]
public
IPEndPoint
LocalEP
{
get
;
set
;
}
=
Misc
.
StringConverter
.
ToIPEndPoint
(
"127.0.0.1:20006"
);
public
string
Addr
{
get
;
set
;
}
=
"0.0.0.0:20006"
;
#
endregion
private
string
param_path
=
"sysparam.
xml
"
;
private
string
param_path
=
"sysparam.
json
"
;
public
SysParam
()
{
...
...
@@ -33,14 +33,44 @@ namespace FLY.Thick.Base.Server
{
if
(!
string
.
IsNullOrEmpty
(
param_path
))
this
.
param_path
=
param_path
;
Load
();
if
(!
Load
())
{
Save
();
}
}
public
bool
Load
()
bool
Load
()
{
try
{
if
(
File
.
Exists
(
param_path
))
{
string
json
=
File
.
ReadAllText
(
param_path
);
JsonConvert
.
PopulateObject
(
json
,
this
);
return
true
;
}
}
catch
{
bool
ret
=
Misc
.
SaveToXmlHepler
.
Load
(
param_path
,
this
);
return
ret
;
//异常,没有json 解码失败
}
return
false
;
}
public
bool
Save
()
{
try
{
File
.
WriteAllText
(
param_path
,
JsonConvert
.
SerializeObject
(
this
,
Formatting
.
Indented
));
return
true
;
}
catch
{
//异常,没有json 编码失败
}
return
false
;
}
...
...
@@ -50,11 +80,6 @@ namespace FLY.Thick.Base.Server
#
endregion
public
string
[]
GetSavePropertyNames
()
{
return
new
string
[]{
"LocalEP"
};
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment