Exemplo n.º 1
0
        public BaseViewModel()
        {
            var allProperties = typeof(T).GetProperties();

            PropertyChanged += (s, e) => UpdateRegistry(e.PropertyName);

            for (int i = 0; i < allProperties.Length; i++)
            {
                var attribute = allProperties[i].GetCustomAttribute <RegistrySyncAttribute>();
                if (attribute != null)
                {
                    var regItem = ABSRegistry.GetItem(attribute.RegistryPath);
                    if (regItem is RegGroup)
                    {
                        ABSLog.ThrowError("Cannot registry sync to a group.");
                    }

                    var syncInfo = new RegistrySyncInfo(allProperties[i], regItem, attribute.BooleanGroupPos);
                    _registrySyncProperties.Add(allProperties[i].Name, syncInfo);
                    AddEventHandlerToItem(syncInfo, regItem);

                    UpdateProperty(syncInfo);
                }
            }
        }