Exemplo n.º 1
0
        /// <summary>
        /// Evaluates the setObjects in the tree. This method invokes the Evaluate method in the recursive form.
        /// The evaluation starts in the more deep level in the tree of objects.
        /// Then the upper levels will evaluated based on result of the deeper levels.
        /// </summary>
        /// <param name="setElement">The set element.</param>
        /// <returns></returns>
        private SetResult EvaluateOtherSets(set setElement)
        {
            IEnumerable <set> otherSetsElements = setElement.GetSets();
            SetResult         resultFirstSet    = this.Evaluate(otherSetsElements.First());
            SetResult         resultSecondSet   = new SetResult(new List <String>(), FlagEnumeration.notcollected);

            //the max number of set is 2 (reference: oval_definitions schema)
            if (otherSetsElements.Count() == MAX_NUMBER_OF_OBJECTS_IN_SET)
            {
                resultSecondSet = this.Evaluate(otherSetsElements.ElementAt(1));
            }
            SetOperation         operation  = this.GetOperation(setElement.set_operator);
            IEnumerable <string> results    = operation.Execute(resultFirstSet.Result, resultSecondSet.Result);
            FlagEnumeration      objectFlag = operation.GetObjectFlag(resultFirstSet.ObjectFlag, resultSecondSet.ObjectFlag);

            return(new SetResult(results, objectFlag));
        }
Exemplo n.º 2
0
        private SetResult ExecuteOperationForSetElement(set setElement, IEnumerable <sc.ObjectType> objectTypes)
        {
            sc.ObjectType        firstObjectType      = objectTypes.First();
            sc.ObjectType        secondObjectType     = null;
            IEnumerable <string> firstReferenceTypes  = firstObjectType.GetReferenceTypesInString();
            IEnumerable <string> secondReferenceTypes = new List <string>();
            FlagEnumeration      firstObjectFlag      = firstObjectType.flag;
            FlagEnumeration      secondObjectFlag     = FlagEnumeration.complete;

            if (objectTypes.Count() == MAX_NUMBER_OF_OBJECTS_IN_SET)
            {
                //the max number to the Object_Reference is 2 (reference: oval_definitions schema)
                secondObjectType     = objectTypes.ElementAt(1);
                secondReferenceTypes = secondObjectType.GetReferenceTypesInString();
                secondObjectFlag     = secondObjectType.flag;
            }
            SetOperation         operation  = this.GetOperation(setElement.set_operator);
            IEnumerable <string> results    = operation.Execute(firstReferenceTypes, secondReferenceTypes);
            FlagEnumeration      objectFlag = operation.GetObjectFlag(firstObjectFlag, secondObjectFlag);
            SetResult            result     = new SetResult(results, objectFlag);

            return(result);
        }