Ejemplo n.º 1
0
        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));
                }
            }
        }
Ejemplo n.º 2
0
        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
        }
Ejemplo n.º 3
0
 public void Swapped(object newInstance)
 {
     try
     {
         var s = RuntimeReflectionExtensions.GetRuntimeField(newInstance.GetType(), "HotSwapped");
         s.SetValue(newInstance, true);
     }
     catch (Exception e)
     {
         AudioEngine.Log(e.Message);
     }
 }