private ItemType CreateTextFileContentItemType(string filepath, string pattern, int instance, string text) { var status = StatusEnumeration.exists; EntityItemAnySimpleType textEntity = null; if (string.IsNullOrEmpty(text)) { status = StatusEnumeration.doesnotexist; } else { textEntity = OvalHelper.CreateEntityItemAnyTypeWithValue(text); } return(new textfilecontent_item() { status = status, pattern = OvalHelper.CreateItemEntityWithStringValue(pattern), instance = OvalHelper.CreateItemEntityWithIntegerValue(instance.ToString()), filename = OvalHelper.CreateItemEntityWithStringValue(Path.GetFileName(filepath)), path = OvalHelper.CreateItemEntityWithStringValue(Path.GetDirectoryName(filepath)), filepath = OvalHelper.CreateItemEntityWithStringValue(filepath), text = textEntity }); }
private CollectedItem GetFakeCollectedItem() { var newCollectedItem = new environmentvariable_item() { name = OvalHelper.CreateItemEntityWithStringValue(FAKE_ENVIRONMENT_VARIABLE_NAME), value = OvalHelper.CreateEntityItemAnyTypeWithValue(FAKE_ENVIRONMENT_VARIABLE_VALUE) }; return(ProbeHelper.CreateFakeCollectedItem(newCollectedItem)); }
private ItemType CreateTextFileContentItem( string filepath, string path, string filename, string pattern, string instance, string text) { return(new textfilecontent_item() { filepath = OvalHelper.CreateItemEntityWithStringValue(filepath), path = OvalHelper.CreateItemEntityWithStringValue(path), filename = OvalHelper.CreateItemEntityWithStringValue(filename), pattern = OvalHelper.CreateItemEntityWithStringValue(pattern), instance = OvalHelper.CreateItemEntityWithIntegerValue(instance), text = OvalHelper.CreateEntityItemAnyTypeWithValue(text) }); }
private void ConfigureXmlFileContentItem(xmlfilecontent_item xmlFileContentItem, IEnumerable <String> xPathResult) { var completeFilepath = this.GetCompleteFilepath(xmlFileContentItem); xmlFileContentItem.filepath = OvalHelper.CreateItemEntityWithStringValue(completeFilepath); xmlFileContentItem.path = OvalHelper.CreateItemEntityWithStringValue(Path.GetDirectoryName(completeFilepath)); xmlFileContentItem.filename = OvalHelper.CreateItemEntityWithStringValue(Path.GetFileName(completeFilepath)); xmlFileContentItem.value_of = new EntityItemAnySimpleType[xPathResult.Count()]; for (int i = 0; i < xPathResult.Count(); i++) { xmlFileContentItem.value_of[i] = OvalHelper.CreateEntityItemAnyTypeWithValue(xPathResult.ElementAt(i)); } }
protected override IEnumerable <CollectedItem> collectDataForSystemItem(ItemType systemItem) { this.CreateEnvironmentVariablesCollectorInstance(); var environmentVariableItem = (environmentvariable_item)systemItem; try { var collectedVariableValue = this.TryToCollectEnvironmentVariable(environmentVariableItem.name.Value); environmentVariableItem.value = OvalHelper.CreateEntityItemAnyTypeWithValue(collectedVariableValue); } catch (EnvironmentVariableNotExistsException) { base.SetDoesNotExistStatusForItemType(systemItem, environmentVariableItem.name.Value); } return(new ItemTypeHelper().CreateCollectedItemsWithOneItem(systemItem, BuildExecutionLog())); }
private void SetVariableItemFromVariableValues(variable_item variableItem, IEnumerable <VariableValue> variableValues) { var values = new List <string>(); foreach (var variableValue in variableValues) { foreach (string value in variableValue.values) { values.Add(value); } } if (values.Count == 0) { throw new VariableNotFoundException(); } variableItem.value = new EntityItemAnySimpleType[values.Count()]; for (int i = 0; i < values.Count(); i++) { variableItem.value[i] = OvalHelper.CreateEntityItemAnyTypeWithValue(values.ElementAt(i)); } }