This repository was archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 334
This repository was archived by the owner on Dec 7, 2023. It is now read-only.
Refactoring Suggestion #214
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Feature description
We can introduce a intermediatory class like below to ease development and reduce code duplicates.
New components can be added by just inheriting from this class and mentioning instance variables.
using Microsoft.Win32;
namespace ThisIsWin11.OpenTweaks.Assessment
{
internal class SingleKeyAssessmentBase : AssessmentBase
{
private static readonly ErrorHelper logger = ErrorHelper.Instance;
string id;
string info;
string keyName;
string valueType = RegistryValueKind.String;
string desiredValue; /// or doValue
string undesiredValue; /// or undoValue
string doLog;
string undoLog;
public override string ID() { return id; }
public override string Info() { return info; }
public override bool CheckAssessment()
{
return !(
RegistryHelper.StringEquals(keyName, "Value", desiredValue)
);
}
public override bool DoAssessment()
{
try
{
Registry.SetValue(keyName, "Value", desiredValue, valueType);
logger.Log(doLog);
logger.Log(keyName);
return true;
}
catch
{ }
return false;
}
public override bool UndoAssessment()
{
try
{
Registry.SetValue(keyName, "Value", undesiredValue, valueType);
logger.Log(undoLog);
return true;
}
catch
{ }
return false;
}
}
}
Logs
No response
Issue tracker rule checks (please read carefully)
- I have checked that this feature is not already asked.
- I have checked that this feature is not already implemented
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request