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

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

            return(Compile(DynamicCode.GetCoreMetadataReferences()
                           .Concat(DynamicCode.GetMetadataReferences()), 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();

            return(Compile(DynamicCode.GetCoreMetadataReferences()
                           .Concat(DynamicCode.GetMetadataReferences()), DynamicCode.GetUsingNamespaces() +
                           @"
namespace Signum.Entities.Dynamic
{
    class Evaluator : ControllerBase, Signum.Entities.Dynamic.IDynamicApiEvaluator
    {
        " + script + @"

        public bool DummyEvaluate() => true;
    }
}"));
        }