Fix casing on private properties

This commit is contained in:
Drew DeVault 2016-10-10 14:00:33 -04:00 committed by Dean Herbert
parent dc4bd48f29
commit 880399f5a5
5 changed files with 43 additions and 43 deletions

View File

@ -18,36 +18,36 @@ static LegacyFilesystemReader()
AddReader<LegacyFilesystemReader>((storage, path) => Directory.Exists(path));
}
private string BasePath { get; set; }
private string[] Beatmaps { get; set; }
private Beatmap FirstMap { get; set; }
private string basePath { get; set; }
private string[] beatmaps { get; set; }
private Beatmap firstMap { get; set; }
public LegacyFilesystemReader(string path)
{
BasePath = path;
Beatmaps = Directory.GetFiles(BasePath, "*.osu").Select(f => Path.GetFileName(f)).ToArray();
if (Beatmaps.Length == 0)
basePath = path;
beatmaps = Directory.GetFiles(basePath, "*.osu").Select(f => Path.GetFileName(f)).ToArray();
if (beatmaps.Length == 0)
throw new FileNotFoundException("This directory contains no beatmaps");
using (var stream = new StreamReader(ReadFile(Beatmaps[0])))
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
FirstMap = decoder.Decode(stream);
firstMap = decoder.Decode(stream);
}
}
public override string[] ReadBeatmaps()
{
return Beatmaps;
return beatmaps;
}
public override Stream ReadFile(string name)
{
return File.OpenRead(Path.Combine(BasePath, name));
return File.OpenRead(Path.Combine(basePath, name));
}
public override BeatmapMetadata ReadMetadata()
{
return FirstMap.Metadata;
return firstMap.Metadata;
}
public override void Dispose()

View File

@ -6,18 +6,18 @@ namespace osu.Game.Beatmaps.Formats
{
public abstract class BeatmapDecoder
{
private static Dictionary<string, Type> Decoders { get; set; } = new Dictionary<string, Type>();
private static Dictionary<string, Type> decoders { get; set; } = new Dictionary<string, Type>();
public static BeatmapDecoder GetDecoder(TextReader stream)
{
var line = stream.ReadLine().Trim();
if (!Decoders.ContainsKey(line))
if (!decoders.ContainsKey(line))
throw new IOException("Unknown file format");
return (BeatmapDecoder)Activator.CreateInstance(Decoders[line]);
return (BeatmapDecoder)Activator.CreateInstance(decoders[line]);
}
protected static void AddDecoder<T>(string magic) where T : BeatmapDecoder
{
Decoders[magic] = typeof(T);
decoders[magic] = typeof(T);
}
public abstract Beatmap Decode(TextReader stream);

View File

@ -13,11 +13,11 @@ private class Reader
public Type Type { get; set; }
}
private static List<Reader> Readers { get; set; } = new List<Reader>();
private static List<Reader> readers { get; set; } = new List<Reader>();
public static ArchiveReader GetReader(BasicStorage storage, string path)
{
foreach (var reader in Readers)
foreach (var reader in readers)
{
if (reader.Test(storage, path))
return (ArchiveReader)Activator.CreateInstance(reader.Type);
@ -27,7 +27,7 @@ public static ArchiveReader GetReader(BasicStorage storage, string path)
protected static void AddReader<T>(Func<BasicStorage, string, bool> test) where T : ArchiveReader
{
Readers.Add(new Reader { Test = test, Type = typeof(T) });
readers.Add(new Reader { Test = test, Type = typeof(T) });
}
/// <summary>

View File

@ -23,32 +23,32 @@ public static void Register()
OsuLegacyDecoder.Register();
}
private ZipFile Archive { get; set; }
private string[] Beatmaps { get; set; }
private Beatmap FirstMap { get; set; }
private ZipFile archive { get; set; }
private string[] beatmaps { get; set; }
private Beatmap firstMap { get; set; }
public OszArchiveReader(Stream archive)
public OszArchiveReader(Stream archiveStream)
{
Archive = ZipFile.Read(archive);
Beatmaps = Archive.Entries.Where(e => e.FileName.EndsWith(".osu"))
archive = ZipFile.Read(archiveStream);
beatmaps = archive.Entries.Where(e => e.FileName.EndsWith(".osu"))
.Select(e => e.FileName).ToArray();
if (Beatmaps.Length == 0)
if (beatmaps.Length == 0)
throw new FileNotFoundException("This directory contains no beatmaps");
using (var stream = new StreamReader(ReadFile(Beatmaps[0])))
using (var stream = new StreamReader(ReadFile(beatmaps[0])))
{
var decoder = BeatmapDecoder.GetDecoder(stream);
FirstMap = decoder.Decode(stream);
firstMap = decoder.Decode(stream);
}
}
public override string[] ReadBeatmaps()
{
return Beatmaps;
return beatmaps;
}
public override Stream ReadFile(string name)
{
ZipEntry entry = Archive.Entries.SingleOrDefault(e => e.FileName == name);
ZipEntry entry = archive.Entries.SingleOrDefault(e => e.FileName == name);
if (entry == null)
throw new FileNotFoundException();
return entry.OpenReader();
@ -56,11 +56,11 @@ public override Stream ReadFile(string name)
public override BeatmapMetadata ReadMetadata()
{
return FirstMap.Metadata;
return firstMap.Metadata;
}
public override void Dispose()
{
Archive.Dispose();
archive.Dispose();
}
}
}

View File

@ -11,23 +11,23 @@ namespace osu.Game.Database
{
public class BeatmapDatabase
{
private static SQLiteConnection Connection { get; set; }
private static SQLiteConnection connection { get; set; }
public BeatmapDatabase(BasicStorage storage)
{
if (Connection == null)
if (connection == null)
{
Connection = storage.GetDatabase(@"beatmaps");
Connection.CreateTable<BeatmapMetadata>();
Connection.CreateTable<BaseDifficulty>();
Connection.CreateTable<BeatmapSet>();
Connection.CreateTable<Beatmap>();
connection = storage.GetDatabase(@"beatmaps");
connection.CreateTable<BeatmapMetadata>();
connection.CreateTable<BaseDifficulty>();
connection.CreateTable<BeatmapSet>();
connection.CreateTable<Beatmap>();
}
}
public void AddBeatmap(ArchiveReader input)
{
var metadata = input.ReadMetadata();
if (Connection.Table<BeatmapSet>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
if (connection.Table<BeatmapSet>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
return;
string[] mapNames = input.ReadBeatmaps();
var beatmapSet = new BeatmapSet { BeatmapSetID = metadata.BeatmapSetID };
@ -39,12 +39,12 @@ public BeatmapDatabase(BasicStorage storage)
var decoder = BeatmapDecoder.GetDecoder(stream);
var beatmap = decoder.Decode(stream);
maps.Add(beatmap);
beatmap.BaseDifficultyID = Connection.Insert(beatmap.BaseDifficulty);
beatmap.BaseDifficultyID = connection.Insert(beatmap.BaseDifficulty);
}
}
beatmapSet.BeatmapMetadataID = Connection.Insert(metadata);
Connection.Insert(beatmapSet);
Connection.InsertAll(maps);
beatmapSet.BeatmapMetadataID = connection.Insert(metadata);
connection.Insert(beatmapSet);
connection.InsertAll(maps);
}
}
}