/// <summary> /// Produces the proper AVRelation<T> instance for the given classname. /// </summary> internal static AVRelationBase CreateRelation(AVObject parent, string key, string targetClassName) { // `Expression` is unstable in IL2CPP environment. Let's call the method directly! #if UNITY if (PlatformHooks.IsCompiledByIL2CPP) { return(CreateRelation <AVObject>(parent, key, targetClassName)); } else { var targetType = AVObject.GetType(targetClassName); Expression <Func <AVRelation <AVObject> > > createRelationExpr = () => CreateRelation <AVObject>(parent, key, targetClassName); var createRelationMethod = ((MethodCallExpression)createRelationExpr.Body) .Method .GetGenericMethodDefinition() .MakeGenericMethod(targetType); return((AVRelationBase)createRelationMethod.Invoke(null, new object[] { parent, key, targetClassName })); } #else var targetType = AVObject.GetType(targetClassName); Expression <Func <AVRelation <AVObject> > > createRelationExpr = () => CreateRelation <AVObject>(parent, key, targetClassName); var createRelationMethod = ((MethodCallExpression)createRelationExpr.Body) .Method .GetGenericMethodDefinition() .MakeGenericMethod(targetType); return((AVRelationBase)createRelationMethod.Invoke(null, new object[] { parent, key, targetClassName })); #endif }