Click or drag to resize

IFileSystemItemGetPropertiesAsync Method

IT Hit User File System
Gets list of custom properties.

Namespace:  ITHit.FileSystem
Assembly:  ITHit.FileSystem (in ITHit.FileSystem.dll) Version: 8.4.27341.0
Syntax
Task<IEnumerable<FileSystemItemPropertyData>> GetPropertiesAsync(
	IOperationContext operationContext
)

Parameters

operationContext
Type: ITHit.FileSystemIOperationContext
Provides information about the environment.

Return Value

Type: TaskIEnumerableFileSystemItemPropertyData
List of properties to be displayed in the file manager. Return null or throw NotImplementedException if no custom properties for this item should be displayed.
Remarks

To show custom properties in your virtual drive on Windows platform follow these steps:

  1. Derive your class from one of the [!:CustomStateHandlerBase] class descendants. Add the GuidAttribute, ProgIdAttribute and ComVisibleAttribute attributes to your class. You do not need to implement any methods in your class.
  2. Add the desktop3:CustomStateHandler tag to your Package.appxmanifest (in case of packaged app) or appxmanifest.xml (in case of a sparse package) that references your class. Alternativly you can register your class as a COM component using regsvr32 or any other method.
  3. Register properties as part of your virtual drive registration using the [!:StorageProviderSyncRootInfo.StorageProviderItemPropertyDefinitions] property.
  4. Implement the GetPropertiesAsync(IOperationContext) method to return a list of properties.
  5. Register your calss as a WinRT component when starting the application using the [!:LocalServer.RegisterWinRTClass] method. This will allow your app to receive COM calls. Note that this step is requied in all cases, regardless if you are installing a packaged application, sparse package or doing a regular COM registartion.
  6. After starting your virtual drive application show columns in the "More..." context menu on the columns header in Windows Explorer.

Custom properties functionality does NOT require package or application identity.

Examples

The code below is part of 'VirtualDrive' C# sample provided with the SDK.

XML
<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.

C#
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.

C#
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;
}
See Also