示例#1
0
        internal NotifyKind CheckChangedValueCount(ref RegistryChangeInfo changeInfos)
        {
            RegistryKey key = _rootKey.OpenSubKey(_registryPath);

            if (null == key)
            {
                bool found = false;
                foreach (string keyExists in _keyExists)
                {
                    if (keyExists == (RootKey.ToString() + "\\" + _registryPath))
                    {
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    _parent.RaisePropertyChanged(this);
                    _keyExists.Remove(RootKey.ToString() + "\\" + _registryPath);
                }
            }
            else
            {
                bool found = false;
                foreach (string keyExists in _keyExists)
                {
                    if (keyExists == (RootKey.ToString() + "\\" + _registryPath))
                    {
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    _keyExists.Add(RootKey.ToString() + "\\" + _registryPath);
                }

                string[] valueNames = key.GetValueNames();
                int      valueCount = key.ValueCount;
                if (valueCount != _lastValueCount)
                {
                    _parent.RaisePropertyChanged(this);

                    NotifyKind returnKind;
                    if ((valueCount > _lastValueCount) && (!_parent.FirstRun))
                    {
                        NewDeactivatedElementInfo newElementInfo = new NewDeactivatedElementInfo();
                        newElementInfo.RootKey = _rootKey;
                        newElementInfo.KeyPath = _registryPath;

                        string newValueName = GetNewValueName(valueNames, _valueNames);
                        object regValue     = key.GetValue(newValueName, null);
                        regValue            = DisabledValue.ConvertDisabledItemValueName(regValue, newValueName);
                        newElementInfo.Name = regValue as string;
                        newElementInfo.OfficeProductVersion = OfficeProductVersion;
                        changeInfos = newElementInfo;
                        _valueNames = valueNames;
                        returnKind  = NotifyKind.DisabledItemNew;
                    }
                    else if (!_parent.FirstRun)
                    {
                        DeleteDeactivatedElementInfo deleteElementInfo = new DeleteDeactivatedElementInfo();
                        deleteElementInfo.RootKey = _rootKey;
                        deleteElementInfo.KeyPath = _registryPath;
                        deleteElementInfo.Name    = GetDeletedValueName(valueNames, _valueNames);

                        string convertedName = null;
                        _convertedNames.TryGetValue(deleteElementInfo.Name, out convertedName);
                        _convertedNames.Remove(deleteElementInfo.Name);
                        deleteElementInfo.Name = convertedName;

                        deleteElementInfo.OfficeProductVersion = OfficeProductVersion;
                        changeInfos = deleteElementInfo;
                        _valueNames = valueNames;
                        returnKind  = NotifyKind.DisabledItemDelete;
                    }
                    else
                    {
                        foreach (string name in valueNames)
                        {
                            string existingName = null;
                            _convertedNames.TryGetValue(name, out existingName);
                            if (null == existingName)
                            {
                                object regValue = key.GetValue(name, null);
                                regValue = DisabledValue.ConvertDisabledItemValueName(regValue, name);
                                _convertedNames.Add(name, regValue as string);
                            }
                        }
                        returnKind = NotifyKind.Nothing;
                    }


                    _lastValueCount = valueCount;
                    return(returnKind);
                }
                _valueNames = valueNames;
                key.Close();
            }
            return(NotifyKind.Nothing);
        }