ReviewR.Web.Infrastructure.UrlExtensions.CreateExtractor C# (CSharp) Method

CreateExtractor() private static method

private static CreateExtractor ( Type type ) : Func>
type System.Type
return Func>
        private static Func<object, Tuple<string, int>> CreateExtractor(Type type)
        {
            string name = type.Name;
            PropertyInfo idProp = type.GetProperty("Id", BindingFlags.Public | BindingFlags.Instance);
            ParameterExpression input = Expression.Parameter(typeof(object));
            return Expression.Lambda<Func<object, Tuple<string, int>>>(
                Expression.Call(TupleCreateMethod,
                    Expression.Constant(name),
                    Expression.Property(Expression.Convert(input, type), idProp)),
                input).Compile();
        }