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

View File

@ -6,18 +6,18 @@ namespace osu.Game.Beatmaps.Formats
{ {
public abstract class BeatmapDecoder 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) public static BeatmapDecoder GetDecoder(TextReader stream)
{ {
var line = stream.ReadLine().Trim(); var line = stream.ReadLine().Trim();
if (!Decoders.ContainsKey(line)) if (!decoders.ContainsKey(line))
throw new IOException("Unknown file format"); 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 protected static void AddDecoder<T>(string magic) where T : BeatmapDecoder
{ {
decoders[magic] = typeof(T); decoders[magic] = typeof(T);
} }

View File

@ -13,11 +13,11 @@ namespace osu.Game.Beatmaps.IO
public Type Type { get; set; } 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) public static ArchiveReader GetReader(BasicStorage storage, string path)
{ {
foreach (var reader in Readers) foreach (var reader in readers)
{ {
if (reader.Test(storage, path)) if (reader.Test(storage, path))
return (ArchiveReader)Activator.CreateInstance(reader.Type); return (ArchiveReader)Activator.CreateInstance(reader.Type);
@ -27,7 +27,7 @@ namespace osu.Game.Beatmaps.IO
protected static void AddReader<T>(Func<BasicStorage, string, bool> test) where T : ArchiveReader 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> /// <summary>

View File

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

View File

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