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 'VirtualDrive' C# sample provided with the SDK.
<Extensions> <desktop3:Extension Category="windows.cloudFiles"> <desktop3:CloudFiles> <desktop3:CustomStateHandler Clsid="000562AA-2879-4CF1-89E8-0AEC9596FE19"/> <desktop3:ThumbnailProviderHandler Clsid="05CF065E-E135-4B2B-9D4D-CFB3FBAC73A4"/> <desktop3:ExtendedPropertyHandler Clsid="20000000-0000-0000-0000-000000000001"/> <desktop3:BannersHandler Clsid="20000000-0000-0000-0000-000000000001"/> <desktop3:CloudFilesContextMenus> <desktop3:Verb Id="LockCommand" Clsid="9C923BF3-3A4B-487B-AB4E-B4CF87FD1C25" /> </desktop3:CloudFilesContextMenus> <desktop4:ContentUriSource Clsid="6D45BC7A-D0B7-4913-8984-FD7261550C08"/> </desktop3:CloudFiles> </desktop3:Extension> <com:Extension Category="windows.comServer"> <com:ComServer> <com:ExeServer DisplayName="VirtualDrive" Executable="dummy.exe"> <com:Class Id="05CF065E-E135-4B2B-9D4D-CFB3FBAC73A4" /> </com:ExeServer> <com:ExeServer DisplayName="VirtualDrive" Executable="dummy.exe"> <com:Class Id="9C923BF3-3A4B-487B-AB4E-B4CF87FD1C25" /> </com:ExeServer> <com:ExeServer DisplayName="VirtualDrive" Executable="dummy.exe"> <com:Class Id="000562AA-2879-4CF1-89E8-0AEC9596FE19" /> </com:ExeServer> <com:ExeServer DisplayName="VirtualDrive" Executable="dummy.exe"> <com:Class Id="6D45BC7A-D0B7-4913-8984-FD7261550C08" /> </com:ExeServer> </com:ComServer> </com:Extension> </Extensions>
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) { StorageProviderSyncRootInfo storageInfo = new StorageProviderSyncRootInfo(); storageInfo.Path = await StorageFolder.GetFolderFromPathAsync(path); storageInfo.Id = syncRootId; storageInfo.DisplayNameResource = displayName; storageInfo.IconResource = iconPath; storageInfo.Version = System.Reflection.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; proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = "Lock Owner" , Id = (int)CustomColumnIds.LockOwnerIcon }); proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = "Lock Scope" , Id = (int)CustomColumnIds.LockScope }); proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = "Lock Expires" , Id = (int)CustomColumnIds.LockExpirationDate }); proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = "Content ETag" , Id = (int)CustomColumnIds.ContentETag }); proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = "Metadata ETag", Id = (int)CustomColumnIds.MetadataETag }); proDefinitions.Add(new StorageProviderItemPropertyDefinition { DisplayNameResource = "ID" , Id = (int)CustomColumnIds.Id }); 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.TryGetLockInfo(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; }