public void Apply(ref List <Node.Node> nodes) { if (acceptableUsers.Count == 0) { return; //dont apply filter if no users to filter on } //iterate backwards because iterating forwards would be an issue with a list of changing size. for (int i = nodes.Count - 1; i >= 0; i--) { Node.Node node = nodes[i]; IShellItem nParent = node.aEvent.Parent; var props = nParent.GetAllProperties(); var keyName = "RegistryOwner"; //check for the property and if it exists, verify its a user we want if (props.ContainsKey(keyName)) { if (!acceptableUsers.Contains(props[keyName])) { node.Visibility = Visibility.Collapsed; } } else { node.Visibility = Visibility.Collapsed; } } }
/// <summary> /// Reconstructs the Absolute File Path to find the Item represented by this ShellItem, by obtaining the names of all parents <br/> /// (i.e. "C:\Users\User\Desktop" when the ShellItem is the "Desktop" ShellItem Type) /// </summary> /// <param name="parentShellItem">The ShellItem which represents the hiearchical parent to the information in this ShellItem</param> /// <returns>A filepath that should contain enough information to find the original item and related parent Shellbag items</returns> protected string SetAbsolutePath(IShellItem parentShellItem) { if (parentShellItem == null) { return(Name); } IDictionary <string, string> parentProperties = parentShellItem.GetAllProperties(); if (parentProperties.TryGetValue(AbsolutePathIdentifier, out string parentPath)) { //replace instances of \\\ because thats cascading, \\ can exist in network paths and \ is normal. return($@"{parentPath}\{Name}".Replace("\\\\\\", "\\")); } return(Name); }
private void printProperties(IShellItem shellItem) { string s = string.Join(";\n", shellItem.GetAllProperties().Select(x => x.Key + "=" + x.Value).ToArray()); Console.WriteLine(s); }