ShellObjectBase Class
Provides an abstract base class for an IShellObject implementation.
public abstract class ShellObjectBase : DisposableObjectBase, IShellObject, IDisposable
- Inheritance:
- object DisposableObjectBase object
- Derived:
- ShellObjectWrapper
- Implements:
- IShellObject IDisposable
Constructors
ShellObjectBase(IShellService)
Initializes an instance of the class.
protected ShellObjectBase(IShellService shellService)
| Parameter | Type | Description |
|---|---|---|
| shellService | IShellService | The IShellService used to return this shell object's children. |
Properties
AreChildrenLoaded
Indicates whether the Children collection is loaded.
public virtual bool AreChildrenLoaded { get; }
Property Value
Remarks
Since the Children collection is lazy-loaded when called, this property returns whether it has been loaded without triggering a load.
CanCreateChildFolder
Indicates whether the shell object can create a child folder.
public virtual bool CanCreateChildFolder { get; }
Property Value
- bool:
trueif the shell object can create a child folder; otherwise,false.
Remarks
Only shell folders can create child folders.
CanHaveChildFolders
Indicates whether the shell object may have child folders.
public virtual bool CanHaveChildFolders { get; }
Property Value
- bool:
trueif the shell object may have child folders; otherwise,false.
Remarks
Some shell objects can immediately return that they don't have any child folders, whereas others might require a query to determine if there are any.
CanRename
Indicates whether the shell object may be renamed.
public virtual bool CanRename { get; }
Property Value
- bool:
trueif the shell object may be renamed; otherwise,false.
Children
The collection of child shell objects.
EditingName
The full user-friendly editing name of the shell object, if available.
public virtual string? EditingName { get; }
Property Value
Remarks
This value is usually the same as FileSystemPath, except that it can also return a special value to identify special shell objects.
ExtraLargeIcon
The extra-large icon.
ExtraLargeIconOverlay
The extra-large icon overlay.
ExtraLargeThumbnail
The extra-large thumbnail.
FileSystemPath
The file system path of the shell object, if available.
IsFolder
Indicates whether the shell object is a folder, which is anything that can contain other shell objects.
public virtual bool IsFolder { get; }
Property Value
- bool:
trueif the shell object is a folder, which is anything that can contain other shell objects; otherwise,false.
IsLink
Indicates whether the shell object is a link, meaning a shortcut to another shell object.
public virtual bool IsLink { get; }
Property Value
- bool:
trueif the shell object is a link, meaning a shortcut to another shell object; otherwise,false.
IsRemovable
Indicates whether the shell object is on removable media or is a removable device.
public virtual bool IsRemovable { get; }
Property Value
- bool:
trueif the shell object is on removable media or is a removable device; otherwise,false.
IsVirtual
Indicates whether the shell object is not part of the file system (files, directories, or root directories).
public virtual bool IsVirtual { get; }
Property Value
- bool:
trueif the shell object is not part of the file system (files, directories, or root directories); otherwise,false.
IsWatching
Indicates whether the shell object's tree hierarchy is currently watching for change notifications.
public virtual bool IsWatching { get; }
Property Value
- bool:
trueif the shell object's tree hierarchy is currently watching for change notifications; otherwise,false.
Kind
A ShellObjectKind that specifies the kind of this shell object.
LargeIcon
The large icon.
LargeIconOverlay
The large icon overlay.
LargeThumbnail
The large thumbnail.
MediumIcon
The medium icon.
MediumIconOverlay
The medium icon overlay.
MediumThumbnail
The medium thumbnail.
Name
The name of the shell object.
ParsingName
The full parsing name of the shell object, if available.
public virtual string? ParsingName { get; }
Property Value
Remarks
This value is usually the same as FileSystemPath, except that it can also return a special syntax to identify special shell objects.
RelativeParsingName
The parent-relative parsing name of the shell object, if available.
public virtual string? RelativeParsingName { get; }
Property Value
Remarks
This value is usually the same as Name, except that it can also return a special syntax to identify special shell objects.
ShellService
The IShellService used to return this shell object's children.
SmallIcon
The small icon.
SmallIconOverlay
The small icon overlay.
SortOrder
A numeric sort order for sorting the shell object within other shell objects.
public virtual int SortOrder { get; set; }
Property Value
- int:
A numeric sort order for sorting the shell object within other shell objects. The default value is
0.
SpecialFolderKind
A SpecialFolderKind that specifies kind of special folder represented by this shell object, if applicable.
ToolTip
The tool-tip object that is displayed for this shell object in the user interface (UI).
Methods
CreateChildFolder(string)
Creates a child folder with the specified name.
public virtual bool CreateChildFolder(string name)
| Parameter | Type | Description |
|---|---|---|
| name | string | The name of the child folder. |
Returns
- bool:
trueif the child folder was created; otherwise,false.
Remarks
Only shell folders can create child folders.
Dispose(bool)
Releases the unmanaged resources used by the object and optionally releases the managed resources.
protected override void Dispose(bool disposing)
| Parameter | Type | Description |
|---|---|---|
| disposing | bool |
|
Remarks
This method is called by the public Dispose() method and the Finalize method.
Dispose invokes this method with the disposing parameter set to true.
Finalize invokes this method with disposing set to false.
GetChildComparisonKey(IShellObject)
Returns the comparison key object to use for an IShellObject in the RefreshChildren() method when it looks for existing shell objects.
protected virtual object GetChildComparisonKey(IShellObject shellObject)
| Parameter | Type | Description |
|---|---|---|
| shellObject | IShellObject | The IShellObject to examine. |
Returns
NotifyPropertyChanged(string?)
Notifies that a property has changed.
[Obsolete("Use one of the new SetProperty or OnPropertyChanged methods instead of this deprecated NotifyPropertyChanged method.", false)]
protected void NotifyPropertyChanged(string? propertyName)
| Parameter | Type | Description |
|---|---|---|
| propertyName | string | The name of the property that was changed. |
OnPropertyChanged(PropertyChangedEventArgs)
Raises the PropertyChanged event.
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | PropertyChangedEventArgs | The event data. |
OnPropertyChanged(string?)
Raises the PropertyChanged event.
protected void OnPropertyChanged(string? propertyName = null)
| Parameter | Type | Description |
|---|---|---|
| propertyName | string | (Optional) The name of the property that changed. |
RaiseChangedEvent(ShellObjectChangedEventArgs)
Raises the Changed event.
protected void RaiseChangedEvent(ShellObjectChangedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | ShellObjectChangedEventArgs | The event data. |
RaisePropertyChangedEvent(PropertyChangedEventArgs)
Raises the PropertyChanged event.
protected void RaisePropertyChangedEvent(PropertyChangedEventArgs e)
| Parameter | Type | Description |
|---|---|---|
| e | PropertyChangedEventArgs | The event data. |
RefreshChildren()
Refreshes the Children collection.
public virtual void RefreshChildren()
SetProperty<T>(ref T, T, string?)
Called from a property setter to change the backing field's value and raise PropertyChanged notification events if the new value is not equal to the current value.
protected bool SetProperty<T>(ref T field, T newValue, string? propertyName = null)
- Type Parameters:
-
T-The type of the property that changed.
| Parameter | Type | Description |
|---|---|---|
| field | T | The backing field that holds the property's value, which may be updated. |
| newValue | T | The new property value. |
| propertyName | string | (Optional) The name of the property that changed. |
Returns
- bool:
trueif the property was changed; otherwise,false.
StartWatching()
Starts watching the shell object's tree hierarchy for change notifications.
public virtual bool StartWatching()
Returns
- bool:
trueif the shell object is watching its tree hierarchy; otherwise,false.
Remarks
The default implementation of this method does nothing, and returns false.
StopWatching()
Stops watching the shell object's tree hierarchy for change notifications.
public virtual void StopWatching()
Remarks
The default implementation of this method does nothing.
ToString()
Returns the string representation of this object.
Events
Changed
Occurs when the shell object has changed.
public event EventHandler<ShellObjectChangedEventArgs>? Changed
Event Type
PropertyChanged
Occurs when a property value changes.
Inherited Members
- DisposableObjectBase.Dispose()
- object.GetType()
- object.MemberwiseClone()
- object.Equals(object)
- object.Equals(object, object)
- object.ReferenceEquals(object, object)
- object.GetHashCode()