Ejemplo n.º 1
0
 private void AddObjectTypeInList(sc.ObjectType objectType, List <sc.ObjectType> objectTypes)
 {
     sc.ObjectType existingObjectType = objectTypes.Where(obj => obj.id == objectType.id).SingleOrDefault();
     if (existingObjectType == null)
     {
         objectTypes.Add(objectType);
     }
 }
Ejemplo n.º 2
0
        private IEnumerable <sc.ObjectType> GetSystemCharacteristicsObjectType(IEnumerable <string> objectReferences)
        {
            List <sc.ObjectType> objectTypes = new List <sc::ObjectType>();

            foreach (string objectReference in objectReferences)
            {
                sc.ObjectType objectType = this.systemCharacteristics.GetCollectedObjectByID(objectReference);
                if (objectType != null)
                {
                    objectTypes.Add(objectType);
                }
            }
            return(objectTypes);
        }
Ejemplo n.º 3
0
        private List <sc.ObjectType> ApplyFilterInObjectType(string filterValue, sc.ObjectType objectType)
        {
            List <sc.ObjectType> objectTypesAfterFilter = new List <sc.ObjectType>();
            IEnumerable <string> referenceIds           = objectType.GetReferenceTypesInString();

            foreach (string id in referenceIds)
            {
                ItemType            itemType   = this.systemCharacteristics.GetSystemDataByReferenceId(id);
                StateType           state      = this.GetStateById(filterValue);
                StateTypeComparator comparator = new StateTypeComparator(state, itemType, this.variables);
                if (!comparator.IsEquals())
                {
                    this.AddObjectTypeInList(objectType, objectTypesAfterFilter);
                }
            }
            return(objectTypesAfterFilter);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
 private void AssertCollectedObject(ObjectType collectedObject, string expectedObjectID)
 {
     Assert.IsNotNull(collectedObject);
     Assert.AreEqual(expectedObjectID, collectedObject.id);
     var referencedItem = collectedObject.reference;
     Assert.IsNotNull(referencedItem);
     Assert.AreEqual(1, referencedItem.Count());
 }
Ejemplo n.º 6
0
 public CollectedObject(string componentOvalID)
 {
     this.objectType = new ObjectType() { id = componentOvalID, flag = FlagEnumeration.notcollected, version = "1" };
     referenceTypeList = new List<ReferenceType>();
 }
 /// <summary>
 /// This method returns the CollectedObjects from the ProbeResult.
 /// </summary>
 /// <param name="probeResult">The probe result.</param>
 /// <returns></returns>
 private ObjectType[] GetCollectedObjects(ProbeResult probeResult)
 {
     ObjectType[] objectTypes = new ObjectType[probeResult.CollectedObjects.Count()];
     for(int i = 0; i <= (probeResult.CollectedObjects.Count() - 1); i++)
     {
         CollectedObject collectedObject = probeResult.CollectedObjects.ElementAt(i);
         objectTypes[i] = collectedObject.ObjectType;
     }
     return objectTypes;            
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Sets the type of the reference types in the objectType.
 /// </summary>
 /// <param name="itemTypes">the item types of system characteristics.</param>
 /// <param name="itemsCache">The items cache is the list of item already created.</param>
 /// <param name="sourceObjectType">Type of the source object.</param>        
 private void SetReferenceTypesInTheObjectType(IList<ItemType> itemTypes, Dictionary<String, ItemType> itemsCache,
                                               ObjectType sourceObjectType)
 {
     if (sourceObjectType.reference != null)
     {
         for (int j = 0; j <= (sourceObjectType.reference.Count() - 1); j++)
         {
             string sourceReferenceItemId = sourceObjectType.reference[j].item_ref;
             if (!itemsCache.ContainsKey(sourceReferenceItemId))
             {
                 ItemType itemType = this.GetItemTypeById(sourceReferenceItemId, itemTypes);
                 itemTypes.Remove(itemType);
                 itemType.id = sequence.ToString();
                 sourceObjectType.reference[j].item_ref = itemType.id;
                 this.newItemTypes.Add(itemType);
                 itemsCache.Add(sourceReferenceItemId, itemType);
                 sequence = sequence + 1;
             }
             else
             {
                 sourceObjectType.reference[j].item_ref = itemsCache[sourceReferenceItemId].id;
             }
         }
     }
 }