diff --git a/Windows.Shell.Common/ShellProperties/PropertyDescription.cs b/Windows.Shell.Common/ShellProperties/PropertyDescription.cs
index 9d46e9ad..0aa08354 100644
--- a/Windows.Shell.Common/ShellProperties/PropertyDescription.cs
+++ b/Windows.Shell.Common/ShellProperties/PropertyDescription.cs
@@ -29,11 +29,34 @@ public class PropertyDescription : IDisposable
key = pkey ?? iDesc.GetPropertyKey();
}
+ /// Initializes a new instance of the class from a specified property key.
+ /// The property key.
+ public PropertyDescription(PROPERTYKEY propkey)
+ {
+ PSGetPropertyDescription(propkey, typeof(IPropertyDescription).GUID, out var ppv).ThrowIfFailed();
+ iDesc = (IPropertyDescription)ppv;
+ key = propkey;
+ }
+
+ /// Initializes a new instance of the class from a property name.
+ /// A string that identifies the property.
+ public PropertyDescription(string name)
+ {
+ PSGetPropertyDescriptionByName(name, typeof(IPropertyDescription).GUID, out var ppv).ThrowIfFailed();
+ iDesc = (IPropertyDescription)ppv;
+ key = iDesc.GetPropertyKey();
+ }
+
/// Creates a instance from a specified property key.
/// The property key.
/// An associated instance of or if the PROPERTYKEY does not exist in the schema subsystem cache.
public static PropertyDescription? Create(PROPERTYKEY propkey) => PSGetPropertyDescription(propkey, typeof(IPropertyDescription).GUID, out var ppv).Succeeded ? new PropertyDescription((IPropertyDescription)ppv, propkey) : null;
+ /// Creates a instance from a property key name.
+ /// A string that identifies the property.
+ /// An associated instance of or if the PROPERTYKEY does not exist in the schema subsystem cache.
+ public static PropertyDescription? Create(string name) => PSGetPropertyDescriptionByName(name, typeof(IPropertyDescription).GUID, out var ppv).Succeeded ? new PropertyDescription((IPropertyDescription)ppv) : null;
+
/// Tries to create a instance from a specified property key.
/// The property key.
///
@@ -152,7 +175,7 @@ public class PropertyDescription : IDisposable
/// An IconLocation for the image associated with the property value.
public IconLocation GetImageLocationForValue(object obj)
{
- if (iDesc2 == null) iDesc2 = iDesc as IPropertyDescription2;
+ iDesc2 ??= iDesc as IPropertyDescription2;
return iDesc2 != null && IconLocation.TryParse(iDesc2.GetImageReferenceForValue(new PROPVARIANT(obj), out var img).Succeeded ? img : null, out var loc) ? loc : new IconLocation();
}
diff --git a/Windows.Shell.Common/ShellProperties/PropertyStore.cs b/Windows.Shell.Common/ShellProperties/PropertyStore.cs
index 8e66aaff..a2018a7d 100644
--- a/Windows.Shell.Common/ShellProperties/PropertyStore.cs
+++ b/Windows.Shell.Common/ShellProperties/PropertyStore.cs
@@ -10,13 +10,23 @@ namespace Vanara.Windows.Shell;
/// Encapsulates the IPropertyStore object.
///
///
-public abstract class PropertyStore : ReadOnlyPropertyStore, IDictionary, IDisposable, INotifyPropertyChanged
+public class PropertyStore : ReadOnlyPropertyStore, IDictionary, IDisposable, INotifyPropertyChanged
{
private bool noICapabilities = false;
private IPropertyStoreCapabilities? pCapabilities;
/// Initializes a new instance of the class.
- protected PropertyStore() { }
+ protected PropertyStore() => flags |= GETPROPERTYSTOREFLAGS.GPS_READWRITE;
+
+ /// Initializes a new instance of the class from a file system path.
+ /// A string that specifies the item path.
+ /// The optional property changed handler.
+ public PropertyStore(string path, PropertyChangedEventHandler? propChangedHandler = null) : base(path)
+ {
+ flags |= GETPROPERTYSTOREFLAGS.GPS_READWRITE;
+ if (propChangedHandler != null)
+ PropertyChanged += propChangedHandler;
+ }
/// Occurs when a property value changes.
public event PropertyChangedEventHandler? PropertyChanged;
@@ -25,15 +35,14 @@ public abstract class PropertyStore : ReadOnlyPropertyStore, IDictionarytrue if this instance is dirty; otherwise, false.
public bool IsDirty { get; protected set; }
- ///
- public override bool IsReadOnly => false;
-
/// Gets an containing the keys of the .
public new ICollection Keys => base.Keys.ToList();
/// Gets an containing the values in the .
public new ICollection