QSoft.Registry 1.0.0.4

There is a newer version of this package available.
See the version list below for details.
dotnet add package QSoft.Registry --version 1.0.0.4
NuGet\Install-Package QSoft.Registry -Version 1.0.0.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="QSoft.Registry" Version="1.0.0.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QSoft.Registry --version 1.0.0.4
#r "nuget: QSoft.Registry, 1.0.0.4"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install QSoft.Registry as a Cake Addin
#addin nuget:?package=QSoft.Registry&version=1.0.0.4

// Install QSoft.Registry as a Cake Tool
#tool nuget:?package=QSoft.Registry&version=1.0.0.4

Use Linq style read registry(Linq to Registry)

Use Queryable read data

  • Support Queryable function
  • Auto control Registry resource no control resource create and dispose
  • Support Update RegistryKey

Sample code

Create definition

public class InstalledApp
{
    public string DisplayName { set; get; }
    public string DisplayVersion { set; get; }
    public int? EstimatedSize { set; get; }
}

if you want to use exist class, can add attribute,like below code

public class App
{
    [RegPropertyName(Name = "DisplayName")]
    public string Name { set; get; }
    [RegPropertyName(Name = "DisplayVersion")]
    public string Version { set; get; }
    [RegIgnore]
    public int Size { set; get; }
}

Create Query

var regt = new RegQuery<InstalledApp>()
	.useSetting(x =>
	{
		x.Hive = RegistryHive.LocalMachine;
		x.SubKey = @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
		x.View = RegistryView.Registry64;
	});

Get data

var first1 = regt.First();
var first2 = regt.First(x => x.DisplayName != "");
var last1 = regt.Last();
var last2 = regt.Last(x => x.DisplayName != "");


var count1 = regt.Count();
var count2 = regt.Count(x => x.DisplayName == "AA");
var all = regt.All(x => x.DisplayName != "");
var any = regt.Any(x => x.EstimatedSize > 0);
var reverse = regt.Reverse();
var average = regt.Average(x => x.EstimatedSize);
var sum = regt.Sum(x => x.EstimatedSize);
var min = regt.Min(x => x.EstimatedSize);
var max = regt.Max(x => x.EstimatedSize);

var loopup = regt.ToLookup(x => x.DisplayName);
var tolist = regt.ToList();
var toarray = regt.ToArray();
var dictonary = regt.ToDictionary(x => x.EstimatedSize);

Query data

var take = regt.Take(10);
var takewhile = regt.TakeWhile(x => x.DisplayVersion <= new Version(2,2,2,2));
var orderbydesc = regt.OrderByDescending(x => x.DisplayVersion);
var oderby = regt.OrderBy(x => x.EstimatedSize);
var where = regt.Where(x => x.DisplayName != "" && x.DisplayVersion > new Version(3,3,3,3));

Update Data

//update all data
int update_count1 = regt.Update(x => new InstalledApp() { DisplayName = $"{x.DisplayName}_AA" });
int update_count2 = regt.Update(x => new { DisplayName = $"{x.DisplayName}_AA" });
//update by rule
int update_count3 = regt.Where(x=>x.Version>new Version(1,1,1,1)).Update(x => new InstalledApp() { DisplayName = $"{x.DisplayName}_AA" });
int update_count4 = regt.Where(x=>x.Version>new Version(1,1,1,1)).Update(x => new { DisplayName = $"{x.DisplayName}_AA" });

GroupBy Data

var group1 = regt.GroupBy(x => x.DisplayName);
var group2 = regt.GroupBy(x => x.DisplayName, (key, app) => new { key, app });

Use extension linq function like below code

using QSoft.Registry;
using QSoft.Registry.Linq;

RegistryKey reg = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
RegistryKey uninstall = reg.OpenSubKey(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
var where = uninstall.Where(x => x.GetValue<string>("DisplayName") == "Intel(R) Processor Graphics");

Open RegistryKey

var regs = RegistryHive.LocalMachine.OpenView(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
foreach(var reg in regs)
{

}
RegistryKey reg_32 = RegistryHive.LocalMachine.OpenView32(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall");
RegistryKey reg_64 = RegistryHive.LocalMachine.OpenView64(@"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall");

Current provide

FirstOrDefault, LastOrDefault

var first = uninstall.FirstOrDefault(x => x.GetValue<string>("DisplayName") == "Intel(R) Processor Graphics");
var last = uninstall.LastOrDefault(x => x.GetValue<string>("DisplayName") == "Intel(R) Processor Graphics");

Count

var count = uninstall.Count();
var count_1 = uninstall.Count(x => string.IsNullOrEmpty(x.GetValue<string>("DisplayName")) == false);

Where

var where = uninstall.Where(x => x.GetValue<string>("DisplayName") == "Intel(R) Processor Graphics");

ToList, ToDictionary

var list = uninstall.ToList();
var dic = uninstall.ToDictionary(x => x.Name);

ToLookup

var lookups = uninstall.ToLookup(x => x.GetValue<string>("DisplayName"));
foreach (var item in lookups)
{
    System.Diagnostics.Trace.WriteLine($"DisplayName:{item.Key} count:{item.Count()}");
}
Product Compatible and additional computed target framework versions.
.NET Framework net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.0

    • No dependencies.
  • .NETFramework 4.7.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0.7 406 9/30/2022
1.0.0.6 439 2/21/2022
1.0.0.5 263 12/20/2021
1.0.0.4 277 12/9/2021
1.0.0.3 835 12/3/2021
1.0.0.2 312 10/25/2021
1.0.0.1 330 2/18/2021
1.0.0 340 1/14/2021

1. Add RegIgnore attribute
2. Add RegPropertyName
3. Fix parse Expression issue
4. Fix data type translate issue