Ejemplo n.º 1
0
        internal void Initialize()
        {
            if (expression != null)
            {
                var modelExpression = DeclaringType.GetExpression(PropertyType, expression);

                // Expressions that do not require root instances (like static properties or constant expressions)
                if (modelExpression.CompiledExpression.Method.GetParameters().Length == 0)
                {
                    calculation = i => modelExpression.CompiledExpression.DynamicInvoke();
                }

                // Expressions requiring a root instance
                else
                {
                    calculation = i => modelExpression.CompiledExpression.DynamicInvoke(i);
                }
            }
        }