protected virtual void ConvertRule(RuleEntity entity, RuleExpression expression) { Guard.NotNull(entity, nameof(entity)); Guard.NotNull(expression, nameof(expression)); var descriptor = RuleDescriptors.FindDescriptor(entity.RuleType); if (descriptor == null) { // A descriptor for this entity data does not exist. Allow deletion of it. descriptor = new InvalidRuleDescriptor(Scope) { Name = entity.RuleType, DisplayName = entity.RuleType }; } else if (descriptor.Scope != Scope) { throw new SmartException($"Differing rule scope {descriptor.Scope}. Expected {Scope}."); } expression.Id = entity.Id; expression.RuleSetId = entity.RuleSetId; expression.Descriptor = descriptor; expression.Operator = entity.Operator; expression.RawValue = entity.Value; expression.Value = entity.Value.Convert(descriptor.RuleType.ClrType); }
protected virtual void ConvertRule(RuleEntity entity, RuleExpression expression) { Guard.NotNull(entity, nameof(entity)); Guard.NotNull(expression, nameof(expression)); var descriptor = RuleDescriptors.FindDescriptor(entity.RuleType); if (descriptor == null || descriptor.Scope != this.Scope) { // TODO: ErrHandling and EmptynessCheck } expression.Id = entity.Id; expression.Descriptor = descriptor; expression.Operator = entity.Operator; expression.RawValue = entity.Value; expression.Value = entity.Value.Convert(descriptor.RuleType.ClrType); }