Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion DisableNvidiaTelemetry/Controller/NvidiaController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ public static IEnumerable<NvidiaControllerResult<TelemetryRegistryKey>> Enumerat
error = ex;
}

yield return new NvidiaControllerResult<TelemetryRegistryKey>(telemetryRegistryKey, error) {Name = key.Name};
if (key.exists())
yield return new NvidiaControllerResult<TelemetryRegistryKey>(telemetryRegistryKey, error) { Name = key.Name };
else
yield return new NvidiaControllerResult<TelemetryRegistryKey>(null, new RegistryKeyNotFoundException($"Failed to find registry key: {key.Name}"));
}
}

Expand Down
1 change: 1 addition & 0 deletions DisableNvidiaTelemetry/DisableNvidiaTelemetry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<Compile Include="Controller\NvidiaController.cs" />
<Compile Include="Controller\NvidiaControllerResult.cs" />
<Compile Include="MarginSetter.cs" />
<Compile Include="Model\RegistryKeyNotFoundException.cs" />
<Compile Include="Model\ITelemetry.cs" />
<Compile Include="Model\TaskNotFoundException.cs" />
<Compile Include="Model\TelemetryRegistryKey.cs" />
Expand Down
16 changes: 16 additions & 0 deletions DisableNvidiaTelemetry/Model/RegistryKeyNotFoundException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace DisableNvidiaTelemetry.Model
{
/// <summary> Represents an exception where a registry key could not be found. </summary>
public class RegistryKeyNotFoundException : Exception
{
public RegistryKeyNotFoundException()
{
}

public RegistryKeyNotFoundException(string message) : base(message)
{
}
}
}
2 changes: 1 addition & 1 deletion DisableNvidiaTelemetry/Model/TaskNotFoundException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace DisableNvidiaTelemetry.Model
{
/// <summary>
/// Represents an exception where a secheduled task could not be found.
/// Represents an exception where a scheduled task could not be found.
/// </summary>
public class TaskNotFoundException : Exception
{
Expand Down
21 changes: 21 additions & 0 deletions DisableNvidiaTelemetry/Model/TelemetryRegistryKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ public Replacement(Regex regex, string replacment)
public string Replacment { get; }
}

/// <summary>Check to see if the value exists.</summary>
/// <returns>True if it exists, false if not.</returns>
public bool exists()
{
var subKey = SubKey;

try
{
if (_useRegex)
ValueExpressions.Select(vd => vd.Value.Match.IsMatch(subKey.GetValue(vd.Key).ToString())).FirstOrDefault();
else
ValueStrings.Any(vd => subKey.GetValue(vd.Key).ToString() == vd.Value.Enabled);
}
catch (System.NullReferenceException)
{
return false;
}

return true;
}

#region Implementation of ITelemetry

public bool IsActive()
Expand Down