mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-15 15:09:29 +00:00
Add compile time exclusion (#964)
* Add compile time exclusion * Accept suggested changes
This commit is contained in:
@@ -9,12 +9,21 @@ namespace MonoGame.Extended.Content
|
|||||||
{
|
{
|
||||||
public static class ContentReaderExtensions
|
public static class ContentReaderExtensions
|
||||||
{
|
{
|
||||||
private static readonly FieldInfo _contentReaderGraphicsDeviceFieldInfo = typeof(ContentReader).GetTypeInfo().GetDeclaredField("graphicsDevice");
|
|
||||||
|
#if FNA
|
||||||
|
public static GraphicsDevice GetGraphicsDevice(this ContentReader contentReader)
|
||||||
|
{
|
||||||
|
var serviceProvider = contentReader.ContentManager.ServiceProvider;
|
||||||
|
var graphicsDeviceService = serviceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
|
||||||
|
|
||||||
|
if (graphicsDeviceService == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("No Graphics Device Service");
|
||||||
|
}
|
||||||
|
|
||||||
public static GraphicsDevice GetGraphicsDevice(this ContentReader contentReader)
|
return graphicsDeviceService.GraphicsDevice;
|
||||||
{
|
}
|
||||||
return (GraphicsDevice)_contentReaderGraphicsDeviceFieldInfo.GetValue(contentReader);
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
public static string RemoveExtension(string path)
|
public static string RemoveExtension(string path)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user