added shortcuts to standard formats as static properties of ImageFormat and AudioFormat.

namely,
ImageFormat.Jpeg
ImageFormat.Png
ImageFormat.Bmp
AudioFormat.Wav
This commit is contained in:
morkt 2015-08-14 06:05:15 +04:00
parent 7fb26371e3
commit a9ffd7cccc
3 changed files with 21 additions and 2 deletions

View File

@ -23,7 +23,9 @@
// IN THE SOFTWARE. // IN THE SOFTWARE.
// //
using System;
using System.IO; using System.IO;
using System.Linq;
namespace GameRes namespace GameRes
{ {
@ -167,5 +169,9 @@ namespace GameRes
} }
return null; return null;
} }
public static AudioFormat Wav { get { return s_WavFormat.Value; } }
static readonly Lazy<AudioFormat> s_WavFormat = new Lazy<AudioFormat> (() => FormatCatalog.Instance.AudioFormats.FirstOrDefault (x => x.Tag == "WAV"));
} }
} }

View File

@ -178,5 +178,18 @@ namespace GameRes
{ {
get { return this.GetType().Assembly == typeof(ImageFormat).Assembly; } get { return this.GetType().Assembly == typeof(ImageFormat).Assembly; }
} }
public static ImageFormat FindByTag (string tag)
{
return FormatCatalog.Instance.ImageFormats.FirstOrDefault (x => x.Tag == tag);
}
static readonly Lazy<ImageFormat> s_JpegFormat = new Lazy<ImageFormat> (() => FindByTag ("JPEG"));
static readonly Lazy<ImageFormat> s_PngFormat = new Lazy<ImageFormat> (() => FindByTag ("PNG"));
static readonly Lazy<ImageFormat> s_BmpFormat = new Lazy<ImageFormat> (() => FindByTag ("BMP"));
public static ImageFormat Jpeg { get { return s_JpegFormat.Value; } }
public static ImageFormat Png { get { return s_PngFormat.Value; } }
public static ImageFormat Bmp { get { return s_BmpFormat.Value; } }
} }
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers // You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion ("1.1.4.8")] [assembly: AssemblyVersion ("1.1.5.8")]
[assembly: AssemblyFileVersion ("1.1.4.8")] [assembly: AssemblyFileVersion ("1.1.5.8")]