Exemple #1
0
            private Func <object> Map(Outer outer, Type match, Type type, object value)
            {
                Func <object> mapper = null;

                if
                (
                    (revs.Length > 0) &&
                    (
                        (
                            (value != null) && match.IsAssignableFrom(value.GetType())
                        ) ||
                        (
                            (value == null) && (match.IsClass || match.IsInterface)
                        )
                    )
                )
                {
                    for (int i = 0; i < revs.Length; i++)
                    {
                        var candidate = revs[i];
                        if
                        (
                            (candidate == null) ||
                            !candidate.GetType().IsGenericType ||
                            (candidate.GetType().GetGenericTypeDefinition() != typeof(Func <, , ,>))
                        )
                        {
                            continue;
                        }
                        var args = candidate.GetType().GetGenericArguments();
                        if
                        (
                            (args[0] != typeof(Outer)) ||
                            (args[1] != typeof(Type)) ||
                            (!args[2].IsAssignableFrom(match)) ||
                            (args[3] != typeof(object))
                        )
                        {
                            continue;
                        }
                        JSON.Callee ce;
                        if (!rces.Get(candidate, out ce))
                        {
                            ce = rces.Set(candidate, JSON.Callable(typeof(object), typeof(Outer), typeof(Type), match, candidate));
                        }
                        mapper = (ce.Invoke(outer, type, value) as Func <object>);
                        if (mapper != null)
                        {
                            break;
                        }
                    }
                }
                return(mapper);
            }
Exemple #2
0
 private Func <object> Map <TValue>(Outer outer, Type type, TValue value)
 {
     return(Map(outer, typeof(TValue), type, value));
 }