protected override CompilationResult Compile()
        {
            var script = this.Script.Trim();

            script = script.Contains(';') ? script : ("return " + script + ";");
            var entityTypeName = DynamicValidationEntity.GetMainType((DynamicValidationEntity)this.GetParentEntity()).FullName;

            return(Compile(DynamicCode.GetAssemblies(),
                           DynamicCode.GetUsingNamespaces() +
                           @"
namespace Signum.Entities.Dynamic
{
    class Evaluator : Signum.Entities.Dynamic.IDynamicValidationEvaluator
    {
        public string EvaluateUntyped(ModifiableEntity e, PropertyInfo pi)
        {
            return this.Evaluate((" + entityTypeName + @")e, pi);
        }

        string Evaluate(" + entityTypeName + @" e, PropertyInfo pi)
        {
            " + script + @"
        }
    }                   
}"));
        }
Exemple #2
0
        protected override CompilationResult Compile()
        {
            var script = this.Script.Trim();

            script = script.Contains(';') ? script : ("return " + script + ";");
            var entityTypeName = ((DynamicTypeConditionEntity)this.GetParentEntity()).EntityType.ToType().FullName;

            return(Compile(DynamicCode.GetAssemblies(),
                           DynamicCode.GetUsingNamespaces() +
                           @"
namespace Signum.Entities.Dynamic
{
    class Evaluator : Signum.Entities.Dynamic.IDynamicTypeConditionEvaluator
    {
        public bool EvaluateUntyped(ModifiableEntity e)
        {
            return this.Evaluate((" + entityTypeName + @")e);
        }

        bool Evaluate(" + entityTypeName + @" e)
        {
            " + script + @"
        }
    }                   
}"));
        }