public static Dictionary <string, EntitySimpleBaseType> GetFileContentEntitiesFromObjectType(textfilecontent54_object textFileContentObject) { string fileName = textfilecontent54_ItemsChoices.filename.ToString(); string filePath = textfilecontent54_ItemsChoices.filepath.ToString(); string path = textfilecontent54_ItemsChoices.path.ToString(); string pattern = textfilecontent54_ItemsChoices.pattern.ToString(); string instance = textfilecontent54_ItemsChoices.instance.ToString(); object[] allEntities = textFileContentObject.Items.ToArray(); string[] allEntityNames = textFileContentObject.Textfilecontent54ItemsElementName.Select(i => i.ToString()).ToArray <String>(); Dictionary <String, EntitySimpleBaseType> fileContentEntities = new Dictionary <string, EntitySimpleBaseType>(); if (textFileContentObject.IsFilePathDefined()) { fileContentEntities.Add(filePath, OvalHelper.GetEntityObjectByName(filePath, allEntities, allEntityNames)); } else { fileContentEntities.Add(fileName, OvalHelper.GetEntityObjectByName(fileName, allEntities, allEntityNames)); fileContentEntities.Add(path, OvalHelper.GetEntityObjectByName(path, allEntities, allEntityNames)); } fileContentEntities.Add(pattern, OvalHelper.GetEntityObjectByName(pattern, allEntities, allEntityNames)); fileContentEntities.Add(instance, OvalHelper.GetEntityObjectIntTypeByName(instance, allEntities, allEntityNames)); return(fileContentEntities); }
private void AssertEntityNamesOrder(textfilecontent54_object textFileContentObject) { if (textFileContentObject.IsFilePathDefined()) { var firstElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(0); var secondElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(1); var thirdElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(2); var fourthElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(3); Assert.AreEqual(textfilecontent54_ItemsChoices.behaviors, firstElement, UNEXPECTED_ENTITY_ORDER); Assert.AreEqual(textfilecontent54_ItemsChoices.filepath, secondElement, UNEXPECTED_ENTITY_ORDER); Assert.AreEqual(textfilecontent54_ItemsChoices.pattern, thirdElement, UNEXPECTED_ENTITY_ORDER); Assert.AreEqual(textfilecontent54_ItemsChoices.instance, fourthElement, UNEXPECTED_ENTITY_ORDER); } else { var firstElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(0); var secondElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(1); var thirdElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(2); var fourthElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(3); var fifthElement = textFileContentObject.Textfilecontent54ItemsElementName.ElementAt(4); Assert.AreEqual(textfilecontent54_ItemsChoices.behaviors, firstElement, UNEXPECTED_ENTITY_ORDER); Assert.AreEqual(textfilecontent54_ItemsChoices.path, secondElement, UNEXPECTED_ENTITY_ORDER); Assert.AreEqual(textfilecontent54_ItemsChoices.filename, thirdElement, UNEXPECTED_ENTITY_ORDER); Assert.AreEqual(textfilecontent54_ItemsChoices.pattern, fourthElement, UNEXPECTED_ENTITY_ORDER); Assert.AreEqual(textfilecontent54_ItemsChoices.instance, fifthElement, UNEXPECTED_ENTITY_ORDER); } }
public IEnumerable <ItemType> ProcessOperation(textfilecontent54_object fileContentObject) { IEnumerable <string> fileNames = null; IEnumerable <string> paths = null; var fileEntities = FileContentOvalHelper.GetFileContentEntitiesFromObjectType(fileContentObject); var pattern = ((EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.pattern)).Value; if (fileContentObject.IsFilePathDefined()) { var filePath = this.GetDictionaryWithElement(textfilecontent54_ItemsChoices.filepath, fileEntities); var filePathOperationResult = this.PathOperatorEvaluator.ProcessOperationFilePath(filePath); fileNames = filePathOperationResult.FileNames; paths = filePathOperationResult.Paths; } else { paths = this.ProcessOperationsPaths(fileEntities); fileNames = this.ProcessOperationsFileNames(fileEntities, paths); } var itemTypes = this.ProcessOperationsPatterns(fileContentObject, fileNames); return(this.ProcessOperationsInstance(itemTypes, fileContentObject)); }
private ObjectType CreateObjectTypeFrom(textfilecontent54_object fileContentObject, string filePath, string fileName, string path, string pattern, string instance) { EntityObjectStringType filePathFrom = null; EntityObjectStringType pathFrom = null; EntityObjectStringType fileNameFrom = null; EntityObjectStringType newFilePath = null; EntityObjectStringType newPath = null; EntityObjectStringType newFileName = null; var patternFrom = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.pattern); var instanceFrom = (EntityObjectIntType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.instance); var newPattern = this.CopyEntityObjectStringType(patternFrom); newPattern.Value = !string.IsNullOrEmpty(pattern) ? pattern : newPattern.Value; var newInstance = this.CopyEntityObjectIntType(instanceFrom); newInstance.Value = !string.IsNullOrEmpty(instance) ? instance : newInstance.Value; var behaviors = fileContentObject.Items.OfType <Textfilecontent54Behaviors>().ToArray(); if (fileContentObject.IsFilePathDefined()) { filePathFrom = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.filepath); newFilePath = this.CopyEntityObjectStringType(filePathFrom); newFilePath.Value = !string.IsNullOrEmpty(filePath) ? filePath : newFilePath.Value; return(this.CreateTextFileContentObject(newFilePath, null, null, newPattern, newInstance, behaviors)); } else { pathFrom = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.path); fileNameFrom = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.filename); newPath = this.CopyEntityObjectStringType(pathFrom); newPath.Value = !string.IsNullOrEmpty(path) ? path : newPath.Value; newFileName = this.CopyEntityObjectStringType(fileNameFrom); newFileName.Value = !string.IsNullOrEmpty(fileName) ? fileName : newFileName.Value; return(this.CreateTextFileContentObject(null, newFileName, newPath, newPattern, newInstance, behaviors)); } }
public IEnumerable <ObjectType> CreateFileObjects( textfilecontent54_object fileContentObject, IEnumerable <string> filePaths, IEnumerable <string> fileNames, IEnumerable <string> paths, IEnumerable <string> patterns, IEnumerable <string> instances) { var fileContentObjects = new List <ObjectType>(); if (fileContentObject.IsFilePathDefined()) { this.CreateFileObjectsWithFilePath(fileContentObject, filePaths, patterns, instances, fileContentObjects); } else { this.CreateFileObjectsWithoutFilePath(fileContentObject, fileNames, paths, patterns, instances, fileContentObjects); } return(fileContentObjects); }