IFileSystemItemGetPropertiesAsync Method |
Namespace: ITHit.FileSystem
Task<IEnumerable<FileSystemItemPropertyData>> GetPropertiesAsync( IOperationContext operationContext )
To show custom properties in your virtual drive on Windows platform follow these steps:
Custom properties functionality does NOT require package or application identity.
The code below is part of 'Common' C# sample provided with the SDK.
private static async Task<StorageProviderSyncRootInfo> RegisterAsync(string syncRootId, string path, string remoteStoragePath, string displayName, string iconPath, Dictionary<int, string>? customColumns) { StorageProviderSyncRootInfo storageInfo = new StorageProviderSyncRootInfo(); storageInfo.Path = await StorageFolder.GetFolderFromPathAsync(path); storageInfo.Id = syncRootId; storageInfo.DisplayNameResource = displayName; storageInfo.IconResource = iconPath; storageInfo.Version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); storageInfo.RecycleBinUri = new Uri("https://userfilesystem.com/recyclebin"); storageInfo.SetRemoteStoragePath(remoteStoragePath); //storageInfo.ProviderId = providerID; // Provider ID is not returned by StorageProviderSyncRootManager.GetCurrentSyncRoots() // To open mp4 files using Windows Movies & TV application the Hydration Policy must be set to Full. storageInfo.HydrationPolicy = StorageProviderHydrationPolicy.Full; storageInfo.HydrationPolicyModifier = StorageProviderHydrationPolicyModifier.AutoDehydrationAllowed; //| StorageProviderHydrationPolicyModifier.ValidationRequired; // To implement folders on-demand placeholders population set the // StorageProviderSyncRootInfo.PopulationPolicy to StorageProviderPopulationPolicy.Full. storageInfo.PopulationPolicy = StorageProviderPopulationPolicy.Full; // Set to Full to list folder content immediately on program start. // The read-only attribute is used to indicate that the item is being locked by another user. Do NOT include it into InSyncPolicy. storageInfo.InSyncPolicy = StorageProviderInSyncPolicy.Default; // Adds columns to Windows File Manager. // Show/hide columns in the "More..." context menu on the columns header in Windows Explorer. var proDefinitions = storageInfo.StorageProviderItemPropertyDefinitions; if (customColumns != null) { foreach (var column in customColumns) { proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = column.Value, Id = column.Key }); } } ValidateStorageProviderSyncRootInfo(storageInfo); StorageProviderSyncRootManager.Register(storageInfo); return storageInfo; }
The code below is part of 'VirtualDrive' C# sample provided with the SDK.
public async Task<IEnumerable<FileSystemItemPropertyData>> GetPropertiesAsync(IOperationContext operationContext) { // For this method to be called you need to register a properties handler. // See method description for more details. Logger.LogDebug($"{nameof(IFileSystemItem)}.{nameof(GetPropertiesAsync)}()", UserFileSystemPath, default, operationContext); IList<FileSystemItemPropertyData> props = new List<FileSystemItemPropertyData>(); // Read LockInfo and choose the lock icon. if (operationContext.Properties.TryGetActiveLockInfo(out ServerLockInfo lockInfo)) { // Determine if the item is locked by this user or thirt-party user. bool thisUser = Engine.IsCurrentUser(lockInfo.Owner); string lockIconName = thisUser ? "Locked" : "LockedByAnotherUser"; // Get Lock Mode. if (thisUser && (lockInfo.Mode == LockMode.Auto)) { lockIconName += "Auto"; } // Set Lock Owner. FileSystemItemPropertyData propertyLockOwner = new FileSystemItemPropertyData() { Id = (int)CustomColumnIds.LockOwnerIcon, Value = lockInfo.Owner, IconResource = Path.Combine(Engine.IconsFolderPath, lockIconName + ".ico") }; props.Add(propertyLockOwner); // Set Lock Expires. FileSystemItemPropertyData propertyLockExpires = new FileSystemItemPropertyData() { Id = (int)CustomColumnIds.LockExpirationDate, Value = lockInfo.LockExpirationDateUtc.ToString(), IconResource = Path.Combine(Engine.IconsFolderPath, "Empty.ico") }; props.Add(propertyLockExpires); // Set Lock Scope FileSystemItemPropertyData propertyLockScope = new FileSystemItemPropertyData() { Id = (int)CustomColumnIds.LockScope, Value = lockInfo.Exclusive ? "Exclusive" : "Shared", IconResource = Path.Combine(Engine.IconsFolderPath, "Empty.ico") }; props.Add(propertyLockScope); } return props; }