private IEnumerable <ItemType> processOperationInRegistryObject(RegistryObject registryObject)
        {
            List <string> hives = new List <string>()
            {
                registryObject.Hive
            };
            RegistryItemTypeFactory itemTypeFactory = new RegistryItemTypeFactory();

            List <ItemType> items = new List <ItemType>();
            List <string>   keys  = new List <string>();
            List <string>   names = new List <string>();

            try
            {
                var registryNameValue = registryObject.GetValueOfEntity("name");
                keys.AddRange(this.processOperationInEntity(registry_object_ItemsChoices.key, registryObject));

                var derivedRegistryObjects =
                    RegistryObjectFactory.CreateRegistryObjectsByCombinationOfEntitiesFrom(hives, keys, new string[] { registryNameValue }, registryObject);

                if (registryObject.GetNameOperation() != OperationEnumeration.equals)
                {
                    foreach (var newRegistryObject in derivedRegistryObjects)
                    {
                        if (!string.IsNullOrEmpty(registryNameValue))
                        {
                            names = this.processOperationInEntity(registry_object_ItemsChoices.name, newRegistryObject).ToList();
                            items.AddRange(itemTypeFactory.CreateRegistryItemTypesByCombinationOfEntitiesFrom(hives, new string[] { newRegistryObject.Key }, names, registryObject));
                        }
                    }
                }
                else
                {
                    names.AddRange(this.processOperationInEntity(registry_object_ItemsChoices.name, registryObject));
                    items.AddRange(itemTypeFactory.CreateRegistryItemTypesByCombinationOfEntitiesFrom(hives, keys, names, registryObject));
                }
            }
            catch (RegistryKeyNotFoundException)
            {
                items = itemTypeFactory.CreateRegistryItemTypesByCombinationOfEntitiesFrom(hives, null, null, registryObject).ToList();
            }
            catch (RegistryItemNotFoundException)
            {
                items = new List <ItemType>()
                {
                    itemTypeFactory.CreateRegistryItem("", "", "", StatusEnumeration.doesnotexist)
                };
            }
            catch (Exception ex)
            {
                registry_item registry = itemTypeFactory.CreateRegistryItem(registryObject.Hive, registryObject.Key, registryObject.Name, StatusEnumeration.error);
                registry.message = MessageType.FromErrorString(ex.Message);
                items            = new List <ItemType>()
                {
                    registry
                };
            }

            return(items);
        }
        private IEnumerable <string> processOperationInEntity(registry_object_ItemsChoices entity, RegistryObject registryObject)
        {
            string entityValue = registryObject.GetValueOfEntity(entity.ToString());
            OperationEnumeration entityOperation = registryObject.GetOperationOfEntity(entity.ToString());
            bool isKeyEntity = (entity == registry_object_ItemsChoices.key);

            if (operatorHelper.IsEqualsOperation(entityOperation))
            {
                return(new List <string>()
                {
                    this.processEqualsOperations(entity, registryObject, isKeyEntity)
                });
            }
            else
            {
                return(this.EvaluateOperation(entityOperation, entityValue, registryObject, isKeyEntity));
            }
        }
        private string processEqualsOperations(registry_object_ItemsChoices entity, RegistryObject registryObject, bool isKey)
        {
            string hive = registryObject.Hive;
            string key  = registryObject.Key;
            Dictionary <string, string> parameters = RegistryHelper.GetInputParametersForWmiEnumValuesMethod(hive, key);

            if (isKey)
            {
                Dictionary <string, object> result = this.wmiDataProvider.InvokeMethod("EnumKey", parameters);
                if ((uint)result["ReturnValue"] == 2)
                {
                    throw new RegistryKeyNotFoundException(String.Format("The key {0} does not exist", key));
                }
                return(key);
            }
            else
            {
                return(registryObject.GetValueOfEntity(entity.ToString()));
            }
        }
        private IEnumerable <string> ProcessEntityVariables(RegistryObject registry, string entityName)
        {
            var values     = new List <string>();
            var variableId = registry.GetVariableId(entityName);

            var variableValues = variables.GetVariableValueForVariableId(variableId);

            if ((variableValues != null) && (variableValues.Count() > 0))
            {
                foreach (VariableValue variableValue in variableValues)
                {
                    values.AddRange(variableValue.values);
                }
            }
            else
            if ((registry.GetEntity(entityName) == null) || (string.IsNullOrEmpty(registry.GetEntity(entityName).var_ref)))
            {
                values.Add(registry.GetValueOfEntity(entityName));
            }

            return(values);
        }
        private IEnumerable<ItemType> processOperationInRegistryObject(RegistryObject registryObject)
        {
            List<string> hives = new List<string>() { registryObject.Hive };
            RegistryItemTypeFactory itemTypeFactory = new RegistryItemTypeFactory();

            List<ItemType> items = new List<ItemType>();
            List<string> keys = new List<string>();
            List<string> names = new List<string>();
            try
            {
                var registryNameValue = registryObject.GetValueOfEntity("name");
                keys.AddRange(this.processOperationInEntity(registry_object_ItemsChoices.key, registryObject));

                var derivedRegistryObjects =
                    RegistryObjectFactory.CreateRegistryObjectsByCombinationOfEntitiesFrom(hives, keys, new string[] { registryNameValue }, registryObject);

                if (registryObject.GetNameOperation() != OperationEnumeration.equals)
                {
                    foreach (var newRegistryObject in derivedRegistryObjects)
                    {
                        if (!string.IsNullOrEmpty(registryNameValue))
                        {
                            names = this.processOperationInEntity(registry_object_ItemsChoices.name, newRegistryObject).ToList();
                            items.AddRange(itemTypeFactory.CreateRegistryItemTypesByCombinationOfEntitiesFrom(hives, new string[] { newRegistryObject.Key }, names, registryObject));
                        }
                    }
                }
                else
                {
                    names.AddRange(this.processOperationInEntity(registry_object_ItemsChoices.name, registryObject));
                    items.AddRange(itemTypeFactory.CreateRegistryItemTypesByCombinationOfEntitiesFrom(hives, keys, names, registryObject));
                }
            }
            catch (RegistryKeyNotFoundException)
            {
                items = itemTypeFactory.CreateRegistryItemTypesByCombinationOfEntitiesFrom(hives, null, null, registryObject).ToList();
            }
            catch (RegistryItemNotFoundException)
            {
                items = new List<ItemType>() { itemTypeFactory.CreateRegistryItem("", "", "", StatusEnumeration.doesnotexist) };
            }
            catch (Exception ex)
            {
                registry_item registry = itemTypeFactory.CreateRegistryItem(registryObject.Hive, registryObject.Key, registryObject.Name, StatusEnumeration.error);
                registry.message = MessageType.FromErrorString(ex.Message);
                items = new List<ItemType>() { registry };
            }

            return items;
        }
        private string processEqualsOperations(registry_object_ItemsChoices entity, RegistryObject registryObject, bool isKey)
        {
            string hive = registryObject.Hive;
            string key = registryObject.Key;
            Dictionary<string, string> parameters = RegistryHelper.GetInputParametersForWmiEnumValuesMethod(hive, key);
            if (isKey)
            {
                Dictionary<string, object> result = this.wmiDataProvider.InvokeMethod("EnumKey", parameters);
                if ((uint)result["ReturnValue"] == 2)
                    throw new RegistryKeyNotFoundException(String.Format("The key {0} does not exist", key));
                return key;
            }
            else
            {
                return registryObject.GetValueOfEntity(entity.ToString());
            }

        }
 private IEnumerable<string> processOperationInEntity(registry_object_ItemsChoices entity, RegistryObject registryObject)
 {
     string entityValue = registryObject.GetValueOfEntity(entity.ToString());
     OperationEnumeration entityOperation = registryObject.GetOperationOfEntity(entity.ToString());
     bool isKeyEntity = (entity == registry_object_ItemsChoices.key);
     if (operatorHelper.IsEqualsOperation(entityOperation))
     {
         return new List<string>() { this.processEqualsOperations(entity, registryObject, isKeyEntity) };
     }
     else
     {
         return this.EvaluateOperation(entityOperation, entityValue, registryObject, isKeyEntity);
     }
 }
        private IEnumerable<string> ProcessEntityVariables(RegistryObject registry,string entityName)
        {
            var values = new List<string>();
            var variableId = registry.GetVariableId(entityName);

            var variableValues =  variables.GetVariableValueForVariableId(variableId);
            if ((variableValues != null) && (variableValues.Count() > 0))
                foreach (VariableValue variableValue in variableValues)
                    values.AddRange(variableValue.values);
            else
                if ((registry.GetEntity(entityName) == null)  || (string.IsNullOrEmpty(registry.GetEntity(entityName).var_ref)))
                    values.Add(registry.GetValueOfEntity(entityName));

            return values;
        }