Browse Source

fix the FastInvoke.cs for all the platforms

tags/Rel2b
sebas77 6 years ago
parent
commit
80ac93215b
1 changed files with 11 additions and 6 deletions
  1. +11
    -6
      Utilities/FastInvoke.cs

+ 11
- 6
Utilities/FastInvoke.cs View File

@@ -10,14 +10,14 @@ namespace Svelto.Utilities
public static class FastInvoke<T> where T : class
{
#if ENABLE_IL2CPP
public static Action<CastedType, object> MakeSetter<CastedType>(FieldInfo field) where CastedType:class
public static CastedAction<CastedType> MakeSetter<CastedType>(FieldInfo field) where CastedType:class
{
if (field.FieldType.IsInterface == true && field.FieldType.IsValueType == false)
if (field.FieldType.IsInterfaceEx() == true && field.FieldType.IsValueTypeEx() == false)
{
return new Action<CastedType, object>((target, value) => field.SetValue(target, value));
return new CastedAction<CastedType, T>(field.SetValue);
}

throw new ArgumentException("<color=orange>Svelto.ECS</color> unsupported EntityView field (must be an interface and a class)");
throw new ArgumentException("<color=orange>Svelto.ECS</color> unsupported field (must be an interface and a class)");
}
#elif !NETFX_CORE
public static CastedAction<CastedType> MakeSetter<CastedType>(FieldInfo field) where CastedType:class
@@ -38,7 +38,7 @@ namespace Svelto.Utilities
return new CastedAction<CastedType, T>(del);
}

throw new ArgumentException("<color=orange>Svelto.ECS</color> unsupported EntityView field (must be an interface and a class)");
throw new ArgumentException("<color=orange>Svelto.ECS</color> unsupported field (must be an interface and a class)");
}
#else
public static CastedAction<CastedType> MakeSetter<CastedType>(FieldInfo field) where CastedType:class
@@ -59,7 +59,7 @@ namespace Svelto.Utilities
return new CastedAction<CastedType, T>(setter);
}

throw new ArgumentException("<color=orange>Svelto.ECS</color> unsupported EntityView field (must be an interface and a class)");
throw new ArgumentException("<color=orange>Svelto.ECS</color> unsupported field (must be an interface and a class)");
}
#endif
}
@@ -78,6 +78,11 @@ namespace Svelto.Utilities
this.setter = (Action<T, object>)setter;
}

public CastedAction(Action<T, object> setter)
{
this.setter = setter;
}

override public void Call(W target, object value)
{
setter(target as T, value);


Loading…
Cancel
Save