public void GetRuntimeField() { var types = GetTypes(); Assert.Throws <ArgumentNullException>(() => { RuntimeReflectionExtensions.GetRuntimeField(null, "foo"); }); Assert.Throws <ArgumentNullException>(() => { typeof(RuntimeReflectionExtensionsTests).GetRuntimeField(null); }); List <String> fields = new List <String>(); foreach (TypeInfo type in types) { if (!type.Namespace.Equals("FieldDefinitions", StringComparison.Ordinal)) { continue; } fields.Clear(); fields.AddRange((IEnumerable <String>)type.GetDeclaredField("PublicFieldNames").GetValue(null)); foreach (String fieldName in fields) { Assert.NotNull(type.AsType().GetRuntimeField(fieldName)); } } }
public static FieldInfo GetRuntimeField(this Type type, string name) { #if UNITY_METRO && !UNITY_EDITOR return(RuntimeReflectionExtensions.GetRuntimeField(type, name)); #else return(type.GetField(name)); #endif }
public void Swapped(object newInstance) { try { var s = RuntimeReflectionExtensions.GetRuntimeField(newInstance.GetType(), "HotSwapped"); s.SetValue(newInstance, true); } catch (Exception e) { AudioEngine.Log(e.Message); } }