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 IList<ItemType> ProcessOperationsPatterns(
            textfilecontent54_object fileContentObject, IEnumerable<string> completePaths)
        {
            var result = new List<ItemType>();
            var pattern = ((EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.pattern)).Value;
            var instance = ((EntitySimpleBaseType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.instance)).Value;
            var multilineBehavior = fileContentObject.IsMultiline();
            var singlelineBehavior = fileContentObject.IsSingleline();

            foreach (var filepath in completePaths)
            {
                var parameters =
                    TextFileContentObjectCollector.GetDictionaryWithParametersToSearchTextFileConten(
                        filepath, pattern, Int32.Parse(instance), multilineBehavior, singlelineBehavior);

                result.Add(this.CollectItem(parameters));

                parameters.Clear();
            }

            return result;
        }
        private IEnumerable<ItemType> ProcessOperationsInstance(IEnumerable<ItemType> itemTypes, textfilecontent54_object textFileContent)
        {
            var result = new List<ItemType>();

            var instanceEntity =
                (EntityObjectIntType)textFileContent.GetItemValue(textfilecontent54_ItemsChoices.instance);

            var comparator = new OvalComparatorFactory().GetComparator(instanceEntity.datatype);

            foreach (var itemType in itemTypes)
            {
                if (itemType.status == StatusEnumeration.exists)
                {
                    var textFileContentItem = (textfilecontent_item)itemType;
                    if (comparator.Compare(textFileContentItem.instance.Value, instanceEntity.Value, instanceEntity.operation))
                        result.Add(itemType);
                }
                else
                {
                    result.Add(itemType);
                }
            }

            return result;
        }
 private IEnumerable<string> ProcessVariableForPattern(textfilecontent54_object fileContentObject)
 {
     var fileName = (EntityObjectStringType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.pattern);
     return this.processVariablesForEntity(fileName);
 }
 private IEnumerable<string> ProcessVariableForInstance(textfilecontent54_object fileContentObject)
 {
     var instance = (EntityObjectIntType)fileContentObject.GetItemValue(textfilecontent54_ItemsChoices.instance);
     return this.processVariablesForEntity(instance);
 }
 private void AssertTextFileContentObjectEntity(
     textfilecontent54_object textFileContentObject,
     textfilecontent54_ItemsChoices entityName,
     string expectedEntityValue)
 {
     var entityToAssert = (EntitySimpleBaseType)textFileContentObject.GetItemValue(entityName);
     Assert.IsNotNull(entityToAssert, "The entity cannot be null");
     Assert.AreEqual(expectedEntityValue, entityToAssert.Value, "An unexpected entity value was found.");
 }
 public IEnumerable<String> EvaluateVariableForEntity(textfilecontent54_object fileContentObj, textfilecontent54_ItemsChoices entityName)
 {
     var fileObjectEntity = (EntitySimpleBaseType)fileContentObj.GetItemValue(entityName);
     var evaluatedEntity = this.FilePathVarEvaluator.EvaluateEntityVariable(fileObjectEntity);
     return evaluatedEntity == null ? null : evaluatedEntity.Distinct().ToArray();
 }
예제 #8
0
        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);
            }
        }