Proposal: Add factory methods to ListedItem
See original GitHub issueWhat’s the Problem?
There doesn’t presently exist a standardized way to create a ListedItem from external constructs such as IStorageItem-derived types, WIN32_FIND_DATA, and IShellItem. We currently expose numerous public properties on ListedItem and expect users of it to automatically and correctly populate all of them.
This expectation adds a level of redundancy and duplication everywhere we have to create ListedItems, and is not good architecture.
Solution/Idea
We should discuss improving code quality in this area with all of the tasks below:
1. Define factory methods inside ListedItem.cs (draft)
public static ListedItem FromFindData(WIN32_FIND_DATAW findData, string dateReturnFormat = null)
public static ListedItem FromStorageItem(IStorageItem storageItem, string dateReturnFormat = null)
public static ListedItem FromShellItem(IShellItem shellItem, string dateReturnFormat = null)
2. Make all properties on ListedItem read only
3. Add a way to determine what type of external construct(s) back a ListedItem instance
Alternatives
Add multiple constructor overloads to ListedItem: This idea might not be ideal because we may access the filesystem directly when constructing the item.
Priorities
Capability | Priority |
---|---|
This proposal will allow users of ListedItem to easily create one from external constructs in a standard way | Must |
Add a way to determining the backing OS filesystem construct(s) | Could |
Files Version
v2
Windows Version
Windows 11 21H2
Additional comment
No response
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (6 by maintainers)
Top GitHub Comments
@duke7553 Thank you. As mentioned on Discord, that’s what I was planning to do.
@d2dyno1 I support that idea. ListedItem has kind of a mixture of entirely exposed UI and non-UI properties.
The alternative practice you mentioned is more typical. It appears to be a sound design, and we could separate the implementations in a UI focused way rather than arbitrarily.
Good feedback as always. 👍