コード例 #1
0
 public ViolatedRuleDescriptor(RuleDescriptor src)
 {
     this.CreatedOn   = src.CreatedOn;
     this.Description = src.Description;
     this.Name        = src.Name;
     this.RuleId      = src.RuleId;
     this.RuleType    = src.RuleType;
     this.ScanProduct = src.ScanProduct;
 }
コード例 #2
0
        private static IEnumerable <RuleDescriptor> ParseRules(CxRestContext ctx,
                                                               CancellationToken token, JToken rulePayload)
        {
            using (var reader = new JTokenReader(rulePayload))
            {
                LinkedList <RuleDescriptor> rules = new LinkedList <RuleDescriptor>();

                while (JsonUtils.MoveToNextProperty(reader, "ruleId"))
                {
                    RuleDescriptor rule = new RuleDescriptor()
                    {
                        RuleId = Convert.ToInt32(((JProperty)reader.CurrentToken).Value)
                    };


                    if (!JsonUtils.MoveToNextProperty(reader, "name"))
                    {
                        continue;
                    }
                    rule.Name = ((JProperty)reader.CurrentToken).Value.ToString();

                    if (!JsonUtils.MoveToNextProperty(reader, "description"))
                    {
                        continue;
                    }
                    rule.Description = ((JProperty)reader.CurrentToken).Value.ToString();

                    if (!JsonUtils.MoveToNextProperty(reader, "scanType"))
                    {
                        continue;
                    }
                    rule.ScanProduct = ((JProperty)reader.CurrentToken).Value.ToString();

                    if (!JsonUtils.MoveToNextProperty(reader, "ruleType"))
                    {
                        continue;
                    }
                    rule.RuleType = ((JProperty)reader.CurrentToken).Value.ToString();

                    if (!JsonUtils.MoveToNextProperty(reader, "createdOn"))
                    {
                        continue;
                    }
                    rule.CreatedOn = JsonUtils.UtcEpochTimeToDateTime
                                         (Convert.ToInt64(((JProperty)reader.CurrentToken).Value) / 1000);

                    rules.AddLast(rule);
                }

                return(rules);
            }
        }