Browse Source

FIX UWP (.net) compatibility

tags/Rel1
sebas77 7 years ago
parent
commit
12ca06416a
2 changed files with 12 additions and 19 deletions
  1. +11
    -1
      ECS/EnginesRoot.cs
  2. +1
    -18
      Utilities/WeakActionStruct.cs

+ 11
- 1
ECS/EnginesRoot.cs View File

@@ -8,6 +8,9 @@ using WeakReference = Svelto.DataStructures.WeakReference<Svelto.ECS.EnginesRoot
#if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
using Svelto.ECS.Profiler;
#endif
#if NETFX_CORE
using System.Reflection;
#endif

namespace Svelto.ECS
{
@@ -122,9 +125,16 @@ namespace Svelto.ECS

return;
}
#if !NETFX_CORE
var baseType = engine.GetType().BaseType;

if (baseType.IsGenericType)
#else
var baseType = engine.GetType().GetTypeInfo().BaseType;

if (baseType.IsConstructedGenericType)
#endif
{
var genericType = baseType.GetGenericTypeDefinition();



+ 1
- 18
Utilities/WeakActionStruct.cs View File

@@ -12,16 +12,11 @@ namespace BetterWeakEvents
public WeakAction(Action<T1, T2> listener)
{
ObjectRef = GCHandle.Alloc(listener.Target, GCHandleType.Weak);

#if !NETFX_CORE
Method = listener.Method;

if (Method.DeclaringType.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0)
throw new ArgumentException("Cannot create weak event to anonymous method with closure.");
#else
Method = listener.GetMethodInfo();
if (CustomAttributeExtensions.IsDefined(Method, typeof(CompilerGeneratedAttribute), false) == false)
throw new ArgumentException("Cannot create weak event to anonymous method with closure.");
#endif
}

@@ -58,14 +53,8 @@ namespace BetterWeakEvents
ObjectRef = GCHandle.Alloc(listener.Target, GCHandleType.Weak);
#if !NETFX_CORE
Method = listener.Method;

if (Method.DeclaringType.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0)
throw new ArgumentException("Cannot create weak event to anonymous method with closure.");
#else
Method = listener.GetMethodInfo();
if (CustomAttributeExtensions.IsDefined(Method, typeof(CompilerGeneratedAttribute), false) == false)
throw new ArgumentException("Cannot create weak event to anonymous method with closure.");
#endif
}

@@ -102,14 +91,8 @@ namespace BetterWeakEvents
ObjectRef = GCHandle.Alloc(listener.Target, GCHandleType.Weak);
#if !NETFX_CORE
Method = listener.Method;

if (Method.DeclaringType.GetCustomAttributes(typeof(CompilerGeneratedAttribute), false).Length != 0)
throw new ArgumentException("Cannot create weak event to anonymous method with closure.");
#else
Method = listener.GetMethodInfo();
if (CustomAttributeExtensions.IsDefined(Method, typeof(CompilerGeneratedAttribute), false) == false)
throw new ArgumentException("Cannot create weak event to anonymous method with closure.");
#endif
}



Loading…
Cancel
Save