Ejemplo n.º 1
0
        /// <summary>
        /// Hydrates the properties from the registry asyncronously.
        /// </summary>
        public virtual async Task LoadAsync()
        {
            ShellSettingsManager manager = await _settingsManager.GetValueAsync().ConfigureAwait(true);

            SettingsStore settingsStore = manager.GetReadOnlySettingsStore(SettingsScope.UserSettings);

            if (!settingsStore.CollectionExists(CollectionName))
            {
                return;
            }

#if DEBUG_OPTION_VALUES_LOAD_SAVE
            Debug.WriteLine($"LoadAsync<{typeof(T).Name}>()");
            Debug.WriteLine($"GetPropertyCount = {settingsStore.GetPropertyCount(CollectionName)}");
            Debug.WriteLine($"GetPropertyCount = {settingsStore.GetPropertyCount(CollectionName)}");
            //var pnv = settingsStore.GetPropertyNamesAndValues(CollectionName);
            var pn = settingsStore.GetPropertyNames(CollectionName);
            foreach (var n in pn)
            {
                Debug.WriteLine($"Property: Name={n} Type = {settingsStore.GetPropertyType(CollectionName, n).ToString()}");
            }
#endif
            var propertiesToSerialize = GetOptionProperties();
            foreach (PropertyInfo property in propertiesToSerialize)
            {
                if (!settingsStore.PropertyExists(CollectionName, property.Name))
                {
#if DEBUG_OPTION_VALUES_LOAD_SAVE
                    Debug.WriteLine($"Skipping property {property.Name}. Not found in settings store");
#endif
                    property.SetValue(this, property.GetValue(this));
                    continue;
                }
                try
                {
                    string serializedProp = settingsStore.GetString(CollectionName, property.Name);
                    object value          = DeserializeValue(serializedProp, property.PropertyType);
                    property.SetValue(this, value);
#if DEBUG_OPTION_VALUES_LOAD_SAVE
                    Debug.WriteLine($"{property.Name} = {property.GetValue(this)} | value = {value}");
#endif
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex);
                }
            }
#if DEBUG_OPTION_VALUES_LOAD_SAVE
            Debug.WriteLine($"LoadAsync<{typeof(T).Name}>() finished ===================================");
#endif
        }
Ejemplo n.º 2
0
 public int GetPropertyCount([ComAliasName("OLE.LPCOLESTR")] string collectionPath, [ComAliasName("OLE.DWORD")] out uint propertyCount)
 {
     propertyCount = (uint)inner.GetPropertyCount(collectionPath);
     return(0);
 }