Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
 public static SqaleDescriptor Convert(RuleDescriptors.RuleDetail ruleDetail)
 {
     return ruleDetail.SqaleDescriptor == null
         ? null
         : new SqaleDescriptor
         {
             Remediation = new SqaleRemediation
             {
                 Properties =
                     ruleDetail.SqaleDescriptor.Remediation.Properties.Select(
                         property => new SqaleRemediationProperty
                         {
                             Key = property.Key,
                             Value = property.Value,
                             Text = property.Text
                         }).ToList(),
                 RuleKey = ruleDetail.Key
             },
             SubCharacteristic = ruleDetail.SqaleDescriptor.SubCharacteristic
         };
 }
Esempio n. 4
0
 public static RuleDetail Convert(RuleDescriptors.RuleDetail ruleDetail)
 {
     return new RuleDetail
     {
         Key = ruleDetail.Key,
         Title = ruleDetail.Title,
         Severity = ruleDetail.Severity.ToUpper(CultureInfo.InvariantCulture),
         Description = ruleDetail.Description,
         IsActivatedByDefault = ruleDetail.IsActivatedByDefault,
         Tags = ruleDetail.Tags,
         Parameters = ruleDetail.Parameters.Select(
             parameter =>
                 new RuleParameter
                 {
                     Type = parameter.Type,
                     Key = parameter.Key,
                     Description = parameter.Description,
                     DefaultValue = parameter.DefaultValue
                 }).ToList(),
         Cardinality = CardinalitySingle
     };
 }