This repository has been archived by the owner on May 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1192915
commit 0699337
Showing
5 changed files
with
105 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using Newtonsoft.Json; | ||
using System.IO; | ||
|
||
namespace Apk_Installer | ||
{ | ||
class Config | ||
{ | ||
class Data | ||
{ | ||
public string ip_address { get; set; } | ||
public int port { get; set; } | ||
public bool register_apk { get; set; } | ||
} | ||
|
||
private static string CONFIG_FILE = "config.ini"; | ||
private Data json_config; | ||
private static JsonSerializerSettings JSON_SETTINGS = new JsonSerializerSettings | ||
{ | ||
Formatting = Formatting.Indented, | ||
NullValueHandling = NullValueHandling.Include, | ||
}; | ||
|
||
public Config() | ||
{ | ||
string raw_config; | ||
|
||
if (File.Exists(CONFIG_FILE)) | ||
{ | ||
raw_config = File.ReadAllText(CONFIG_FILE); | ||
} | ||
else | ||
{ | ||
var data = new | ||
{ | ||
ip_address = "192.168.1.101", | ||
port = 5555, | ||
register_apk = true | ||
}; | ||
raw_config = JsonConvert.SerializeObject(data, JSON_SETTINGS); | ||
File.WriteAllText(CONFIG_FILE, raw_config); | ||
} | ||
|
||
json_config = JsonConvert.DeserializeObject<Data>(raw_config); | ||
} | ||
|
||
public void Save() | ||
{ | ||
string raw_config = JsonConvert.SerializeObject(json_config, JSON_SETTINGS); | ||
File.WriteAllText(CONFIG_FILE, raw_config); | ||
} | ||
|
||
public bool getRegisterApk() | ||
{ | ||
return json_config.register_apk; | ||
} | ||
|
||
public string getIPaddress() | ||
{ | ||
return json_config.ip_address; | ||
} | ||
|
||
public int getPort() | ||
{ | ||
return json_config.port; | ||
} | ||
|
||
public void setRegisterApk(bool value) | ||
{ | ||
json_config.register_apk = value; | ||
this.Save(); | ||
} | ||
|
||
public void setAdbWifi(string newIpAddress, int newPort) | ||
{ | ||
json_config.ip_address = newIpAddress; | ||
json_config.port = newPort; | ||
this.Save(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters