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