本文整理汇总了C#中BizHawk.Emulation.Cores.Nintendo.NES.NES.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# NES.GetType方法的具体用法?C# NES.GetType怎么用?C# NES.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BizHawk.Emulation.Cores.Nintendo.NES.NES
的用法示例。
在下文中一共展示了NES.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public static void Apply(NES.INESBoard board)
{
var fields = board.GetType().GetFields();
foreach (var field in fields)
{
var attribs = field.GetCustomAttributes(false);
foreach (var attrib in attribs)
{
if (attrib is MapperPropAttribute)
{
string Name = ((MapperPropAttribute)attrib).Name ?? field.Name;
string Value;
if (board.InitialRegisterValues.TryGetValue(Name, out Value))
{
try
{
field.SetValue(board, Convert.ChangeType(Value, field.FieldType));
}
catch (Exception e)
{
if (e is InvalidCastException || e is FormatException || e is OverflowException)
throw new InvalidDataException("Auto Mapper Properties were in a bad format!", e);
else
throw e;
}
}
break;
}
}
}
}
示例2: Populate
public static void Populate(NES.INESBoard board, NES.NESSyncSettings settings)
{
var fields = board.GetType().GetFields();
foreach (var field in fields)
{
var attrib = field.GetCustomAttributes(typeof(MapperPropAttribute), false).OfType<MapperPropAttribute>().SingleOrDefault();
if (attrib == null)
continue;
string Name = attrib.Name ?? field.Name;
if (!settings.BoardProperties.ContainsKey(Name))
{
settings.BoardProperties.Add(Name, (string)Convert.ChangeType(field.GetValue(board), typeof(string)));
}
}
}