public IEnumerable <IRegistryRecord> StringToMultipleRegistryRecords(IEnumerable <string> textToConvertFrom)
        {
            ValidateInputData();

            IList <IRegistryRecord> result = new List <IRegistryRecord>();

            foreach (string row in textToConvertFrom)
            {
                if (!StringExtensions.IsNullOrEmptyWhitespace_Ext(row))
                {
                    IRegistryRecord tmp = StringToRegistryRecord(row);
                    result.Add(tmp);
                }
            }

            return(result);

            void ValidateInputData()
            {
                if (textToConvertFrom == null)
                {
                    throw new ArgumentNullException(nameof(textToConvertFrom));
                }

                int textRowsCount = textToConvertFrom.Count();
                int textNullRows  = textToConvertFrom.Where(x => x.Trim().Length == 0).Count();

                if (textRowsCount == textNullRows)
                {
                    throw new ArgumentNullException(nameof(textToConvertFrom));
                }
            }
        }
示例#2
0
        public void EqualsIRegRecArg_SameObjOtherPtr_ExpectTrue()
        {
            IRegistryRecord registryRecordOther = registryRecord_testSubject;

            bool comparisonResult = registryRecord_testSubject.Equals(registryRecordOther);

            Assert.IsTrue(comparisonResult);
        }
        public bool RegistryRecordExists(IRegistryRecord registryRecord)
        {
            if (registryRecord == null)
            {
                throw new ArgumentNullException(nameof(registryRecord));
            }

            string keyName   = GetKeyName(registryRecord);
            string valueName = GetValueName(registryRecord);

            return(RegistryRecordExists(keyName, valueName));
        }
        public bool SetRegistryValue(IRegistryRecord registryRecord)
        {
            if (registryRecord == null)
            {
                throw new ArgumentNullException(nameof(registryRecord));
            }

            string keyName   = GetKeyName(registryRecord);
            string valueName = GetValueName(registryRecord);

            Registry.SetValue(keyName, valueName, registryRecord.Value, registryRecord.ValueKind);

            return(true);
        }
        public bool Equals(IRegistryRecord other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (GetType() != other.GetType())
            {
                return(false);
            }

            //IList<int> comparisonResult = new List<int>();
            //IList<PropertyInfo> thisProperties = GetType().GetProperties().ToList();
            //IList<PropertyInfo> otherProperties = other.GetType().GetProperties().ToList();

            //if (thisProperties.Count != otherProperties.Count) {
            //    return false;
            //}

            IList <int> comparisonResult = new List <int> {
                string.Compare(Root.ToString(), other.Root.ToString()),
                string.Compare(Key, other.Key),
                string.Compare(ValueName, other.ValueName),
                string.Compare(Value.ToString(), other.Value.ToString()),
                string.Compare(ValueKind.ToString(), other.ValueKind.ToString())
            };

            if (comparisonResult.Sum() == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public bool RegistryRecordExists(IRegistryRecord registryRecord)
 {
     return(RegistryEditor.RegistryRecordExists(registryRecord));
 }
        private string GetValueName(IRegistryRecord registryRecord)
        {
            string valueName = registryRecord.ValueName;

            return(valueName);
        }
        private string GetKeyName(IRegistryRecord registryRecord)
        {
            string keyName = registryRecord.Root + "\\" + registryRecord.Key;

            return(keyName);
        }