mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
code cleanup
This commit is contained in:
parent
c5349b7750
commit
65af535487
@ -11,19 +11,16 @@ using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
|
||||
namespace Compression.BSA
|
||||
{
|
||||
public class BSABuilder : IDisposable, IBSABuilder
|
||||
public class BSABuilder : IBSABuilder
|
||||
{
|
||||
internal uint _archiveFlags;
|
||||
internal uint _fileCount;
|
||||
internal uint _fileFlags;
|
||||
internal byte[] _fileId;
|
||||
|
||||
private List<FileEntry> _files = new List<FileEntry>();
|
||||
internal uint _folderCount;
|
||||
internal List<FolderRecordBuilder> _folders = new List<FolderRecordBuilder>();
|
||||
internal uint _offset;
|
||||
internal uint _totalFileNameLength;
|
||||
internal uint _totalFolderNameLength;
|
||||
internal uint _version;
|
||||
|
||||
public BSABuilder()
|
||||
@ -238,8 +235,6 @@ namespace Compression.BSA
|
||||
public class FileEntry
|
||||
{
|
||||
internal BSABuilder _bsa;
|
||||
internal Stream _bytesSource;
|
||||
internal string _filenameSource;
|
||||
internal bool _flipCompression;
|
||||
internal FolderRecordBuilder _folder;
|
||||
|
||||
|
@ -127,7 +127,7 @@ namespace VFS
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (EndOfStreamException ex)
|
||||
catch (EndOfStreamException)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ namespace Wabbajack.Common
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
@ -197,7 +197,7 @@ namespace Wabbajack.Common
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@ using ICSharpCode.SharpZipLib.BZip2;
|
||||
using IniParser;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Bson;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.NamingConventions;
|
||||
using File = Alphaleonis.Win32.Filesystem.File;
|
||||
using FileInfo = Alphaleonis.Win32.Filesystem.FileInfo;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
@ -577,5 +579,21 @@ namespace Wabbajack.Common
|
||||
select assembly.GetManifestResourceStream(name)).First();
|
||||
}
|
||||
|
||||
public static T FromYaml<T>(this Stream s)
|
||||
{
|
||||
var d = new DeserializerBuilder()
|
||||
.WithNamingConvention(PascalCaseNamingConvention.Instance)
|
||||
.Build();
|
||||
return d.Deserialize<T>(new StreamReader(s));
|
||||
}
|
||||
|
||||
public static T FromYaml<T>(this string s)
|
||||
{
|
||||
var d = new DeserializerBuilder()
|
||||
.WithNamingConvention(PascalCaseNamingConvention.Instance)
|
||||
.Build();
|
||||
return d.Deserialize<T>(new StreamReader(s));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -90,6 +90,9 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="YamlDotNet, Version=7.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\YamlDotNet.7.0.0\lib\net45\YamlDotNet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="BSDiff.cs" />
|
||||
|
@ -10,4 +10,5 @@
|
||||
<package id="SevenZip" version="19.0.0" targetFramework="net472" />
|
||||
<package id="SharpZipLib" version="1.2.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net472" />
|
||||
<package id="YamlDotNet" version="7.0.0" targetFramework="net472" />
|
||||
</packages>
|
@ -7,16 +7,11 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Web;
|
||||
using VFS;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
|
@ -178,12 +178,10 @@ namespace Wabbajack.Lib
|
||||
[Serializable]
|
||||
public class PatchedFromArchive : FromArchive
|
||||
{
|
||||
public string Hash;
|
||||
|
||||
/// <summary>
|
||||
/// The file to apply to the source file to patch it
|
||||
/// </summary>
|
||||
public String PatchID;
|
||||
public string PatchID;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@ -197,7 +195,6 @@ namespace Wabbajack.Lib
|
||||
public class MergedPatch : Directive
|
||||
{
|
||||
public List<SourcePatch> Sources;
|
||||
public string Hash;
|
||||
public string PatchID;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
{
|
||||
stream.Wait();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,13 @@
|
||||
using CG.Web.MegaApiClient;
|
||||
using Compression.BSA;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using VFS;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Wabbajack.Lib.NexusApi;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||
|
@ -48,7 +48,7 @@ namespace Wabbajack.Lib.ModListRegistry
|
||||
public static List<ModlistMetadata> LoadFromGithub()
|
||||
{
|
||||
var d = new DeserializerBuilder()
|
||||
.WithNamingConvention(new PascalCaseNamingConvention())
|
||||
.WithNamingConvention(PascalCaseNamingConvention.Instance)
|
||||
.Build();
|
||||
var client = new HttpClient();
|
||||
Utils.Log("Loading Modlists from Github");
|
||||
|
@ -1,14 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using YamlDotNet.Serialization;
|
||||
using YamlDotNet.Serialization.NamingConventions;
|
||||
using Path = Alphaleonis.Win32.Filesystem.Path;
|
||||
|
||||
namespace Wabbajack.Lib.Validation
|
||||
@ -24,37 +20,28 @@ namespace Wabbajack.Lib.Validation
|
||||
|
||||
public void LoadAuthorPermissionsFromString(string s)
|
||||
{
|
||||
var d = new DeserializerBuilder()
|
||||
.WithNamingConvention(new PascalCaseNamingConvention())
|
||||
.Build();
|
||||
AuthorPermissions = d.Deserialize<Dictionary<string, Author>>(s);
|
||||
AuthorPermissions = s.FromYaml<Dictionary<string, Author>>();
|
||||
}
|
||||
|
||||
public void LoadServerWhitelist(string s)
|
||||
{
|
||||
var d = new DeserializerBuilder()
|
||||
.WithNamingConvention(new PascalCaseNamingConvention())
|
||||
.Build();
|
||||
ServerWhitelist = d.Deserialize<ServerWhitelist>(s);
|
||||
ServerWhitelist = s.FromYaml<ServerWhitelist>();
|
||||
}
|
||||
|
||||
public void LoadListsFromGithub()
|
||||
{
|
||||
var d = new DeserializerBuilder()
|
||||
.WithNamingConvention(new PascalCaseNamingConvention())
|
||||
.Build();
|
||||
var client = new HttpClient();
|
||||
Utils.Log("Loading Nexus Mod Permissions");
|
||||
using (var result = new StringReader(client.GetStringSync(Consts.ModPermissionsURL)))
|
||||
using (var result = client.GetStreamSync(Consts.ModPermissionsURL))
|
||||
{
|
||||
AuthorPermissions = d.Deserialize<Dictionary<string, Author>>(result);
|
||||
AuthorPermissions = result.FromYaml<Dictionary<string, Author>>();
|
||||
Utils.Log($"Loaded permissions for {AuthorPermissions.Count} authors");
|
||||
}
|
||||
|
||||
Utils.Log("Loading Server Whitelist");
|
||||
using (var result = new StringReader(client.GetStringSync(Consts.ServerWhitelistURL)))
|
||||
using (var result = client.GetStreamSync(Consts.ServerWhitelistURL))
|
||||
{
|
||||
ServerWhitelist = d.Deserialize<ServerWhitelist>(result);
|
||||
ServerWhitelist = result.FromYaml<ServerWhitelist>();
|
||||
Utils.Log($"Loaded permissions for {ServerWhitelist.AllowedPrefixes.Count} servers and {ServerWhitelist.GoogleIDs.Count} GDrive files");
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Policy;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Wabbajack.Lib.Validation;
|
||||
using Game = Wabbajack.Common.Game;
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace Wabbajack.WebAutomation
|
||||
{
|
||||
stream.Wait();
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user