mirror of https://github.com/dahall/Vanara.git
Fixed bug in ReadOnlyPropertyStore.TryGetValue (#219)
parent
b232e995ea
commit
035b30f146
|
@ -106,5 +106,13 @@ namespace Vanara.Windows.Shell.Tests
|
|||
Assert.That(i.Properties.ReadOnly, Is.True);
|
||||
Assert.That(i.Properties.Temporary, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PropXlsGetTest()
|
||||
{
|
||||
using ShellItem Item = new ShellItem(TestCaseSources.TempDirWhack + "Test.xlsx");
|
||||
if (Item.Properties.TryGetValue(PROPERTYKEY.System.Document.PageCount, out int PageCount))
|
||||
TestContext.Write($"PageCount={PageCount}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -181,7 +181,12 @@ namespace Vanara.Windows.Shell
|
|||
/// When this method returns, the value associated with the specified key, if the key is found; otherwise, <c>default(T)</c>.
|
||||
/// </param>
|
||||
/// <returns><see langword="true"/> if the property store contains an element with the specified key; otherwise, <see langword="false"/>.</returns>
|
||||
protected static bool TryGetValue<T>(IPropertyStore ps, PROPERTYKEY key, out T value) => (value = (T)ps.GetValue(key)) != null;
|
||||
protected static bool TryGetValue<T>(IPropertyStore ps, PROPERTYKEY key, out T value)
|
||||
{
|
||||
var ret = ps.GetValue(key);
|
||||
value = ret is null ? default : (T)ret;
|
||||
return ret is not null;
|
||||
}
|
||||
|
||||
/// <summary>The IPropertyStore instance. This can be null.</summary>
|
||||
protected virtual IPropertyStore GetIPropertyStore() => iPropertyStore;
|
||||
|
|
Loading…
Reference in New Issue