update structure
This commit is contained in:
30
ModpackUpdater.Model/ModpackInfo.vb
Normal file
30
ModpackUpdater.Model/ModpackInfo.vb
Normal file
@@ -0,0 +1,30 @@
|
||||
Imports System.IO
|
||||
|
||||
Imports Newtonsoft.Json
|
||||
Imports Newtonsoft.Json.Converters
|
||||
Imports Newtonsoft.Json.Linq
|
||||
|
||||
Public Class ModpackInfo
|
||||
|
||||
Private Const FILENAME_MODPACKINFO = "modpack-info.json"
|
||||
|
||||
<JsonConverter(GetType(VersionConverter))>
|
||||
Public Property Version As Version
|
||||
|
||||
Public Sub Save(mcRoot As String)
|
||||
File.WriteAllText(GetFilePath(mcRoot), JObject.FromObject(Me).ToString)
|
||||
End Sub
|
||||
|
||||
Public Shared Function Load(mcRoot As String) As ModpackInfo
|
||||
Return JObject.Parse(File.ReadAllText(GetFilePath(mcRoot))).ToObject(Of ModpackInfo)
|
||||
End Function
|
||||
|
||||
Public Shared Function HasModpackInfo(mcRoot As String) As Boolean
|
||||
Return File.Exists(GetFilePath(mcRoot))
|
||||
End Function
|
||||
|
||||
Private Shared Function GetFilePath(mcRoot As String)
|
||||
Return Path.Combine(mcRoot, FILENAME_MODPACKINFO)
|
||||
End Function
|
||||
|
||||
End Class
|
||||
12
ModpackUpdater.Model/ModpackUpdater.Model.vbproj
Normal file
12
ModpackUpdater.Model/ModpackUpdater.Model.vbproj
Normal file
@@ -0,0 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<RootNamespace>ModpackUpdater.Model</RootNamespace>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Pilz.Cryptography" Version="2.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
13
ModpackUpdater.Model/UpdateAction.vb
Normal file
13
ModpackUpdater.Model/UpdateAction.vb
Normal file
@@ -0,0 +1,13 @@
|
||||
Imports Newtonsoft.Json
|
||||
Imports Newtonsoft.Json.Converters
|
||||
|
||||
Public Class UpdateAction
|
||||
|
||||
<JsonConverter(GetType(StringEnumConverter))>
|
||||
Public Property Type As UpdateActionType
|
||||
Public Property DestPath As String
|
||||
Public Property SrcPath As String
|
||||
Public Property DownloadUrl As String
|
||||
Public Property IsDirectory As Boolean
|
||||
|
||||
End Class
|
||||
7
ModpackUpdater.Model/UpdateActionType.vb
Normal file
7
ModpackUpdater.Model/UpdateActionType.vb
Normal file
@@ -0,0 +1,7 @@
|
||||
Public Enum UpdateActionType
|
||||
None
|
||||
Update
|
||||
Delete
|
||||
Move
|
||||
Copy
|
||||
End Enum
|
||||
22
ModpackUpdater.Model/UpdateConfig.vb
Normal file
22
ModpackUpdater.Model/UpdateConfig.vb
Normal file
@@ -0,0 +1,22 @@
|
||||
Imports System.IO
|
||||
|
||||
Imports Newtonsoft.Json.Linq
|
||||
|
||||
Imports Pilz.Cryptography
|
||||
|
||||
Public Class UpdateConfig
|
||||
|
||||
Public Property UpdateUrl As String
|
||||
Public Property WebdavURL As SecureString
|
||||
Public Property WebdavUsername As SecureString
|
||||
Public Property WebdavPassword As SecureString
|
||||
|
||||
Public Sub SaveToFile(filePath As string)
|
||||
File.WriteAllText(filePath, JObject.FromObject(Me).ToString)
|
||||
End Sub
|
||||
|
||||
Public Shared Function LoadFromFile(filePath As String) As UpdateConfig
|
||||
Return JObject.Parse(File.ReadAllText(filePath)).ToObject(Of UpdateConfig)
|
||||
End Function
|
||||
|
||||
End Class
|
||||
10
ModpackUpdater.Model/UpdateInfo.vb
Normal file
10
ModpackUpdater.Model/UpdateInfo.vb
Normal file
@@ -0,0 +1,10 @@
|
||||
Imports Newtonsoft.Json
|
||||
Imports Newtonsoft.Json.Converters
|
||||
|
||||
Public Class UpdateInfo
|
||||
|
||||
<JsonConverter(GetType(VersionConverter))>
|
||||
Public Property Version As Version
|
||||
Public ReadOnly Property Actions As New List(Of UpdateAction)
|
||||
|
||||
End Class
|
||||
11
ModpackUpdater.Model/UpdateInfos.vb
Normal file
11
ModpackUpdater.Model/UpdateInfos.vb
Normal file
@@ -0,0 +1,11 @@
|
||||
Imports Newtonsoft.Json.Linq
|
||||
|
||||
Public Class UpdateInfos
|
||||
|
||||
Public ReadOnly Property Updates As New List(Of UpdateInfo)
|
||||
|
||||
Public Shared Function Parse(content As String) As UpdateInfos
|
||||
Return JObject.Parse(content).ToObject(Of UpdateInfos)
|
||||
End Function
|
||||
|
||||
End Class
|
||||
Reference in New Issue
Block a user