2014-04-25 01:19:57 +00:00
|
|
|
|
using System;
|
2014-11-24 00:38:29 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
2014-11-30 14:52:52 +00:00
|
|
|
|
using BizHawk.Common.ReflectionExtensions;
|
2014-04-25 01:19:57 +00:00
|
|
|
|
|
2014-05-31 14:29:27 +00:00
|
|
|
|
namespace BizHawk.Emulation.Common.IEmulatorExtensions
|
2014-04-25 01:19:57 +00:00
|
|
|
|
{
|
|
|
|
|
public static class Extensions
|
|
|
|
|
{
|
|
|
|
|
public static CoreAttributes Attributes(this IEmulator core)
|
|
|
|
|
{
|
|
|
|
|
return (CoreAttributes)Attribute.GetCustomAttribute(core.GetType(), typeof(CoreAttributes));
|
|
|
|
|
}
|
2014-09-01 18:43:41 +00:00
|
|
|
|
|
|
|
|
|
public static bool HasMemoryDomains(this IEmulator core)
|
|
|
|
|
{
|
|
|
|
|
return core is IMemoryDomains;
|
|
|
|
|
}
|
2014-11-24 00:38:29 +00:00
|
|
|
|
|
2014-11-30 15:22:08 +00:00
|
|
|
|
public static bool HasSaveRam(this IEmulator core)
|
|
|
|
|
{
|
|
|
|
|
return core is ISaveRam;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-30 14:18:44 +00:00
|
|
|
|
public static bool IsNull(this IEmulator core)
|
|
|
|
|
{
|
|
|
|
|
return core == null || core is NullEmulator;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-24 00:38:29 +00:00
|
|
|
|
// TODO: a better place for these
|
|
|
|
|
public static bool IsImplemented(this MethodInfo info)
|
|
|
|
|
{
|
2014-11-30 14:52:52 +00:00
|
|
|
|
// If a method is marked as Not implemented, it is not implemented no matter what the body is
|
|
|
|
|
if (info.GetCustomAttributes(false).OfType<FeatureNotImplemented>().Any())
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If a method is not marked but all it does is throw an exception, consider it not implemented
|
|
|
|
|
return !info.ThrowsError();
|
2014-11-24 00:38:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsImplemented(this PropertyInfo info)
|
|
|
|
|
{
|
|
|
|
|
return !info.GetCustomAttributes(false).OfType<FeatureNotImplemented>().Any();
|
|
|
|
|
}
|
2014-04-25 01:19:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|