/// <summary> /// Gets the value from property. The property is defined by the item_ref property of ObjectComponentType. /// </summary> /// <param name="itemtype">The itemtype.</param> /// <param name="propertyName">Name of the property.</param> /// <returns></returns> private IEnumerable<string> GetValueFromProperty(ItemType itemtype, string propertyName) { var property = this.GetPropertyByName(itemtype, propertyName, itemtype.GetType()); var values = new List<String>(); if (property is EntityItemSimpleBaseType) { var propertyValue = GetPropertyByName(property, "Value", typeof(EntityItemSimpleBaseType)); if (propertyValue != null) values.Add(propertyValue.ToString()); } else if (property is EntityItemSimpleBaseType[]) { var propertyValues = GetValuesOfArrayProperty(property); if (propertyValues != null) values.AddRange(propertyValues); } return values; }
private IEnumerable<string> GetValueFromRecordField(ItemType itemType, string propertyName, string recordFieldname) { var values = new List<String>(); var property = this.GetPropertyByName(itemType, propertyName, itemType.GetType()); if (property is EntityItemRecordType) { foreach (var recordField in ((EntityItemRecordType)property).field) if (recordField.name.Equals(recordFieldname, StringComparison.InvariantCultureIgnoreCase)) values.Add(recordField.Value); } else if (property is EntityItemRecordType[]) { foreach (var prop in (EntityItemRecordType[])property) foreach (var recordField in prop.field) if (recordField.name.Equals(recordFieldname, StringComparison.InvariantCultureIgnoreCase)) values.Add(recordField.Value); } return values; }
private String GetCompleteFilepath(ItemType itemType) { if (itemType is OVAL.SystemCharacteristics.file_item) return ((OVAL.SystemCharacteristics.file_item)itemType).GetFullFilepath(); if (itemType is OVAL.SystemCharacteristics.Unix.file_item) return ((OVAL.SystemCharacteristics.Unix.file_item)itemType).GetFullFilepath(); else throw new ArgumentException(String.Format("The object type '{0}' is not supported.", itemType.GetType().ToString())); }