Skip to content

Commit

Permalink
consistent naming style
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaBs committed May 31, 2021
1 parent da31419 commit a339ff3
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 56 deletions.
3 changes: 3 additions & 0 deletions CmlLib.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=1b89beda_002D4214_002D4128_002Db463_002D5c556bb68962/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Public" Description="public method"&gt;&lt;ElementKinds&gt;&lt;Kind Name="METHOD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;&lt;/Policy&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/UserRules/=31c49da0_002D9fe2_002D42ee_002Db6f8_002D81a44971aaf8/@EntryIndexedValue">&lt;Policy&gt;&lt;Descriptor Staticness="Static, Instance" AccessRightKinds="Private" Description="private method"&gt;&lt;ElementKinds&gt;&lt;Kind Name="METHOD" /&gt;&lt;/ElementKinds&gt;&lt;/Descriptor&gt;&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;&lt;/Policy&gt;</s:String></wpf:ResourceDictionary>
12 changes: 6 additions & 6 deletions CmlLib/Core/Auth/MLogin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ private string CreateNewClientToken()
return Guid.NewGuid().ToString().Replace("-", "");
}

private MSession CreateNewSession()
private MSession createNewSession()
{
var session = new MSession();
if (SaveSession)
{
session.ClientToken = CreateNewClientToken();
WriteSessionCache(session);
writeSessionCache(session);
}
return session;
}

private void WriteSessionCache(MSession session)
private void writeSessionCache(MSession session)
{
if (!SaveSession) return;
Directory.CreateDirectory(Path.GetDirectoryName(SessionCacheFilePath));
Expand Down Expand Up @@ -70,12 +70,12 @@ public MSession ReadSessionCache()
}
catch (JsonReaderException) // invalid json
{
return CreateNewSession();
return createNewSession();
}
}
else
{
return CreateNewSession();
return createNewSession();
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ private MLoginResponse parseSession(string json, string clientToken)
ClientToken = clientToken
};

WriteSessionCache(session);
writeSessionCache(session);
return new MLoginResponse(MLoginResult.Success, session, null, null);
}
}
Expand Down
8 changes: 4 additions & 4 deletions CmlLib/Core/Files/AssetChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ public Task<DownloadFile[]> CheckFilesTaskAsync(MinecraftPath path, MVersion ver
private DownloadFile[] checkIndexAndAsset(MinecraftPath path, MVersion version,
IProgress<DownloadFileChangedEventArgs> progress)
{
CheckIndex(path, version);
checkIndex(path, version);
return CheckAssetFiles(path, version, progress);
}

private void CheckIndex(MinecraftPath path, MVersion version)
private void checkIndex(MinecraftPath path, MVersion version)
{
string index = path.GetIndexFilePath(version.AssetId);

Expand Down Expand Up @@ -98,7 +98,7 @@ public DownloadFile[] CheckAssetFiles(MinecraftPath path, MVersion version,

foreach (var item in list)
{
var f = CheckAssetFile(item.Key, item.Value, path, version, isVirtual, mapResource);
var f = checkAssetFile(item.Key, item.Value, path, version, isVirtual, mapResource);

if (f != null)
downloadRequiredFiles.Add(f);
Expand All @@ -113,7 +113,7 @@ public DownloadFile[] CheckAssetFiles(MinecraftPath path, MVersion version,
return downloadRequiredFiles.Distinct().ToArray(); // 10ms
}

private DownloadFile CheckAssetFile(string key, JToken job, MinecraftPath path, MVersion version, bool isVirtual, bool mapResource)
private DownloadFile checkAssetFile(string key, JToken job, MinecraftPath path, MVersion version, bool isVirtual, bool mapResource)
{
// download hash resource
string hash = job["hash"]?.ToString();
Expand Down
6 changes: 3 additions & 3 deletions CmlLib/Core/Files/ClientChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public DownloadFile[] CheckFiles(MinecraftPath path, MVersion version,
IProgress<DownloadFileChangedEventArgs> progress)
{
progress?.Report(new DownloadFileChangedEventArgs(MFile.Minecraft, version.Jar, 1, 0));
DownloadFile result = CheckClientFile(path, version);
DownloadFile result = checkClientFile(path, version);
progress?.Report(new DownloadFileChangedEventArgs(MFile.Minecraft, version.Jar, 1, 1));

if (result == null)
Expand All @@ -27,7 +27,7 @@ public async Task<DownloadFile[]> CheckFilesTaskAsync(MinecraftPath path, MVersi
IProgress<DownloadFileChangedEventArgs> progress)
{
progress?.Report(new DownloadFileChangedEventArgs(MFile.Minecraft, version.Jar, 1, 0));
DownloadFile result = await Task.Run(() => CheckClientFile(path, version))
DownloadFile result = await Task.Run(() => checkClientFile(path, version))
.ConfigureAwait(false);
progress?.Report(new DownloadFileChangedEventArgs(MFile.Minecraft, version.Jar, 1, 1));

Expand All @@ -37,7 +37,7 @@ public async Task<DownloadFile[]> CheckFilesTaskAsync(MinecraftPath path, MVersi
return new [] { result };
}

private DownloadFile CheckClientFile(MinecraftPath path, MVersion version)
private DownloadFile checkClientFile(MinecraftPath path, MVersion version)
{
if (string.IsNullOrEmpty(version.ClientDownloadUrl)) return null;

Expand Down
10 changes: 5 additions & 5 deletions CmlLib/Core/Files/LibraryChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private DownloadFile[] checkLibraries(MinecraftPath path, MLibrary[] libs,
var files = new List<DownloadFile>(libs.Length);
foreach (MLibrary library in libs)
{
bool downloadRequire = CheckDownloadRequire(path, library);
bool downloadRequire = checkDownloadRequire(path, library);

if (downloadRequire)
{
Expand All @@ -69,7 +69,7 @@ private DownloadFile[] checkLibraries(MinecraftPath path, MLibrary[] libs,
Name = library.Name,
Path = Path.Combine(path.Library, library.Path),
Size = library.Size,
Url = CreateDownloadUrl(library)
Url = createDownloadUrl(library)
});
}

Expand All @@ -80,7 +80,7 @@ private DownloadFile[] checkLibraries(MinecraftPath path, MLibrary[] libs,
return files.Distinct().ToArray();
}

private string CreateDownloadUrl(MLibrary lib)
private string createDownloadUrl(MLibrary lib)
{
string url = lib.Url;

Expand All @@ -94,14 +94,14 @@ private string CreateDownloadUrl(MLibrary lib)
return url;
}

private bool CheckDownloadRequire(MinecraftPath path, MLibrary lib)
private bool checkDownloadRequire(MinecraftPath path, MLibrary lib)
{
return lib.IsRequire
&& !string.IsNullOrEmpty(lib.Path)
&& !IOUtil.CheckFileValidation(Path.Combine(path.Library, lib.Path), lib.Hash, CheckHash);
}

private async Task<bool> CheckDownloadRequireAsync(MinecraftPath path, MLibrary lib)
private async Task<bool> checkDownloadRequireAsync(MinecraftPath path, MLibrary lib)
{
return lib.IsRequire
&& !string.IsNullOrEmpty(lib.Path)
Expand Down
4 changes: 2 additions & 2 deletions CmlLib/Core/Files/ModChecker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<DownloadFile[]> CheckFilesTaskAsync(MinecraftPath path, MVersi
var files = new List<DownloadFile>(Mods.Length);
foreach (ModFile mod in Mods)
{
if (await CheckDownloadRequireAsync(path, mod).ConfigureAwait(false))
if (await checkDownloadRequireAsync(path, mod).ConfigureAwait(false))
{
files.Add(new DownloadFile
{
Expand All @@ -58,7 +58,7 @@ public async Task<DownloadFile[]> CheckFilesTaskAsync(MinecraftPath path, MVersi
return files.Distinct().ToArray();
}

private async Task<bool> CheckDownloadRequireAsync(MinecraftPath path, ModFile mod)
private async Task<bool> checkDownloadRequireAsync(MinecraftPath path, ModFile mod)
{
return !string.IsNullOrEmpty(mod.Url)
&& !string.IsNullOrEmpty(mod.Path)
Expand Down
22 changes: 11 additions & 11 deletions CmlLib/Core/Installer/MJava.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public string CheckJava(string binaryName)

if (!File.Exists(javapath))
{
string javaUrl = GetJavaUrl();
string lzmaPath = DownloadJavaLzma(javaUrl);
string javaUrl = getJavaUrl();
string lzmaPath = downloadJavaLzma(javaUrl);

DecompressJavaFile(lzmaPath);
decompressJavaFile(lzmaPath);

if (!File.Exists(javapath))
throw new WebException("failed to download");
Expand Down Expand Up @@ -88,10 +88,10 @@ public async Task<string> CheckJavaAsync(string binaryName, IProgress<ProgressCh
pProgressChanged = progress;
}

string javaUrl = await GetJavaUrlAsync().ConfigureAwait(false);
string lzmaPath = await DownloadJavaLzmaAsync(javaUrl).ConfigureAwait(false);
string javaUrl = await getJavaUrlAsync().ConfigureAwait(false);
string lzmaPath = await downloadJavaLzmaAsync(javaUrl).ConfigureAwait(false);

Task decompressTask = Task.Run(() => DecompressJavaFile(lzmaPath));
Task decompressTask = Task.Run(() => decompressJavaFile(lzmaPath));
await decompressTask.ConfigureAwait(false);

if (!File.Exists(javapath))
Expand All @@ -104,7 +104,7 @@ public async Task<string> CheckJavaAsync(string binaryName, IProgress<ProgressCh
return javapath;
}

private string GetJavaUrl()
private string getJavaUrl()
{
using (var wc = new WebClient())
{
Expand All @@ -113,7 +113,7 @@ private string GetJavaUrl()
}
}

private async Task<string> GetJavaUrlAsync()
private async Task<string> getJavaUrlAsync()
{
using (var wc = new WebClient())
{
Expand All @@ -137,7 +137,7 @@ private string parseLauncherMetadata(string json)
return javaUrl;
}

private string DownloadJavaLzma(string javaUrl)
private string downloadJavaLzma(string javaUrl)
{
Directory.CreateDirectory(RuntimeDirectory);
string lzmapath = Path.Combine(Path.GetTempPath(), "jre.lzma");
Expand All @@ -149,7 +149,7 @@ private string DownloadJavaLzma(string javaUrl)
return lzmapath;
}

private async Task<string> DownloadJavaLzmaAsync(string javaUrl)
private async Task<string> downloadJavaLzmaAsync(string javaUrl)
{
Directory.CreateDirectory(RuntimeDirectory);
string lzmapath = Path.Combine(Path.GetTempPath(), "jre.lzma");
Expand All @@ -164,7 +164,7 @@ await wc.DownloadFileTaskAsync(javaUrl, lzmapath)
return lzmapath;
}

private void DecompressJavaFile(string lzmaPath)
private void decompressJavaFile(string lzmaPath)
{
string zippath = Path.Combine(Path.GetTempPath(), "jre.zip");
SevenZipWrapper.DecompressFileLZMA(lzmaPath, zippath);
Expand Down
18 changes: 9 additions & 9 deletions CmlLib/Core/Launcher/MLaunch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public MLaunch(MLaunchOption option)
{
option.CheckValid();
LaunchOption = option;
this.MinecraftPath = option.Path;
this.minecraftPath = option.Path;
}

private readonly MinecraftPath MinecraftPath;
private readonly MinecraftPath minecraftPath;
public MLaunchOption LaunchOption { get; private set; }

/// <summary>
Expand All @@ -48,7 +48,7 @@ public Process GetProcess()
Process mc = new Process();
mc.StartInfo.FileName = LaunchOption.JavaPath;
mc.StartInfo.Arguments = arg;
mc.StartInfo.WorkingDirectory = MinecraftPath.BasePath;
mc.StartInfo.WorkingDirectory = minecraftPath.BasePath;

return mc;
}
Expand Down Expand Up @@ -84,13 +84,13 @@ public string[] CreateArg()

var libraries = version.Libraries
.Where(lib => lib.IsRequire && !lib.IsNative)
.Select(lib => Path.GetFullPath(Path.Combine(MinecraftPath.Library, lib.Path)));
.Select(lib => Path.GetFullPath(Path.Combine(minecraftPath.Library, lib.Path)));
classpath.AddRange(libraries);
classpath.Add(MinecraftPath.GetVersionJarPath(version.Jar));
classpath.Add(minecraftPath.GetVersionJarPath(version.Jar));

var classpathStr = IOUtil.CombinePath(classpath.ToArray());

var native = new MNative(MinecraftPath, LaunchOption.StartVersion);
var native = new MNative(minecraftPath, LaunchOption.StartVersion);
native.CleanNatives();
var nativePath = native.ExtractNatives();

Expand All @@ -117,14 +117,14 @@ public string[] CreateArg()
{
{ "auth_player_name" , LaunchOption.Session.Username },
{ "version_name" , LaunchOption.StartVersion.Id },
{ "game_directory" , MinecraftPath.BasePath },
{ "assets_root" , MinecraftPath.Assets },
{ "game_directory" , minecraftPath.BasePath },
{ "assets_root" , minecraftPath.Assets },
{ "assets_index_name", version.AssetId },
{ "auth_uuid" , LaunchOption.Session.UUID },
{ "auth_access_token", LaunchOption.Session.AccessToken },
{ "user_properties" , "{}" },
{ "user_type" , "Mojang" },
{ "game_assets" , MinecraftPath.GetAssetLegacyPath(version.AssetId) },
{ "game_assets" , minecraftPath.GetAssetLegacyPath(version.AssetId) },
{ "auth_session" , LaunchOption.Session.AccessToken },
{ "version_type" , useNotNull(LaunchOption.VersionType, version.TypeStr) }
};
Expand Down
4 changes: 2 additions & 2 deletions CmlLib/Core/Mojang/MojangServerStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static MojangServerStatus GetStatus()
if (property == null)
continue;

ServerStatusColor color = ToStatusColor(property.Value.ToString());
ServerStatusColor color = toStatusColor(property.Value.ToString());
dict.Add(property.Name, color);
}

Expand Down Expand Up @@ -56,7 +56,7 @@ private static ServerStatusColor getColorFromDict(Dictionary<string, ServerStatu
return ServerStatusColor.Unknown;
}

private static ServerStatusColor ToStatusColor(string str)
private static ServerStatusColor toStatusColor(string str)
{
switch (str)
{
Expand Down
18 changes: 9 additions & 9 deletions CmlLib/Core/Version/MVersionCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public MVersionCollection(
if (datas == null)
throw new ArgumentNullException(nameof(datas));

versions = new OrderedDictionary();
Versions = new OrderedDictionary();
foreach (var item in datas)
{
versions.Add(item.Name, item);
Versions.Add(item.Name, item);
}

MinecraftPath = originalPath;
Expand All @@ -43,11 +43,11 @@ public MVersionCollection(
public MVersionMetadata LatestReleaseVersion { get; private set; }
public MVersionMetadata LatestSnapshotVersion { get; private set; }
public MinecraftPath MinecraftPath { get; private set; }
protected OrderedDictionary versions;
protected OrderedDictionary Versions;

public MVersionMetadata this[int index]
{
get => (MVersionMetadata)versions[index];
get => (MVersionMetadata)Versions[index];
}

[MethodTimer.Time]
Expand All @@ -56,7 +56,7 @@ public virtual MVersion GetVersion(string name)
if (name == null)
throw new ArgumentNullException(nameof(name));

MVersionMetadata versionMetadata = (MVersionMetadata)versions[name];
MVersionMetadata versionMetadata = (MVersionMetadata)Versions[name];
if (versionMetadata == null)
throw new KeyNotFoundException("Cannot find " + name);

Expand Down Expand Up @@ -90,8 +90,8 @@ public virtual void Merge(MVersionCollection from)
{
foreach (var item in from)
{
if (!versions.Contains(item.Name))
versions[item.Name] = item;
if (!Versions.Contains(item.Name))
Versions[item.Name] = item;
}

if (this.MinecraftPath == null && from.MinecraftPath != null)
Expand All @@ -106,7 +106,7 @@ public virtual void Merge(MVersionCollection from)

public IEnumerator<MVersionMetadata> GetEnumerator()
{
foreach (DictionaryEntry item in versions)
foreach (DictionaryEntry item in Versions)
{
var version = (MVersionMetadata)item.Value;
yield return version;
Expand All @@ -115,7 +115,7 @@ public IEnumerator<MVersionMetadata> GetEnumerator()

IEnumerator IEnumerable.GetEnumerator()
{
foreach (DictionaryEntry item in versions)
foreach (DictionaryEntry item in Versions)
{
var version = item.Value;
yield return version;
Expand Down
Loading

0 comments on commit a339ff3

Please sign in to comment.