Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
oven425 committed Feb 21, 2022
1 parent d527f7a commit 8c3c669
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 39 deletions.
5 changes: 2 additions & 3 deletions ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class App
public int ID { set; get; }
[RegPropertyName(Name = "DisplayName")]
public string Name { set; get; }
[RegPropertyName(Name = "DisplayVersion")]
//[RegPropertyName(Name = "DisplayVersion")]
public Version Version { set; get; }
[RegIgnore]
public int Size { set; get; }
Expand Down Expand Up @@ -160,8 +160,6 @@ static void Main(string[] args)





var qi = Enumerable.Range(1, 10).AsQueryable();
var qi_where = qi.Where(x => x > 10).Select(x => x);
var qi_groupby = qi.GroupBy(x => x > 5);
Expand All @@ -172,6 +170,7 @@ static void Main(string[] args)
x.SubKey = @"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
x.View = RegistryView.Registry64;
});
regt.GroupBy(x => x.DisplayName, x => x.DisplayName).ToList();
var sel = regt.Select(x => new { x.DisplayName, x.Version });
var where_version = regt.Where(x => x.Version > new Version(1, 1, 1, 1));
List<InstalledApp> m_Tests = new List<InstalledApp>();
Expand Down
2 changes: 1 addition & 1 deletion QSoft.Reg/QSoft.Registry.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>QSoft.Registry</RootNamespace>
<AssemblyName>QSoft.Registry</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
Expand Down
25 changes: 11 additions & 14 deletions QSoft.Reg/RegProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define TestProvider
//#define TestProvider
using Microsoft.Win32;
using QSoft.Registry;
using QSoft.Registry.Linq;
Expand All @@ -17,24 +17,21 @@ namespace QSoft.Registry.Linq
public class RegProvider<TData> : IQueryProvider
{
public RegSetting Setting { set; get; } = new RegSetting();
static int Count = 0;
int CountName;
//int CountName;
public MethodCallExpression m_RegSource;
public RegProvider()
{
CountName = Count++;

var method = typeof(RegProvider<TData>).GetMethod("CreateRegs");
this.m_RegSource = Expression.Call(Expression.Constant(this), method);
}
#if TestProvider
public Expression Expression_Src { private set; get; }
public Expression Expression_Dst { private set; get; }
//public Expression Expression_Src { private set; get; }
//public Expression Expression_Dst { private set; get; }
public RegProvider(Expression src, Expression dst)
{
CountName = Count++;
this.Expression_Src = src;
this.Expression_Dst = dst;
//this.Expression_Src = src;
//this.Expression_Dst = dst;
this.m_Exprs[src] = dst;
this.m_RegMethod = dst;
}
Expand All @@ -50,7 +47,6 @@ public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
var type1 = typeof(TElement);
var type2 = typeof(TData);
#if TestProvider
System.Diagnostics.Debug.WriteLine($"Name:{this.CountName} Count:{Count}");
RegProvider<TElement> provid = null;
RegExpressionVisitor<TData> reg = new RegExpressionVisitor<TData>();
MethodCallExpression method1 = expression as MethodCallExpression;
Expand Down Expand Up @@ -236,11 +232,11 @@ public TResult Execute<TResult>(Expression expression)
var expr = expression;
var sd = typeof(TData).ToSelectData();
var select = typeof(TData).SelectMethod();
updatemethod = Expression.Call(select, this.m_RegSource, sd);
this.m_ProcessExprs[expression] = updatemethod;
this.m_RegMethod = Expression.Call(select, this.m_RegSource, sd);
this.m_ProcessExprs[expression] = this.m_RegMethod;
//var creatquerys = typeof(IQueryProvider).GetMethods().Where(x => x.Name == "CreateQuery" && x.IsGenericMethod == true);
var creatquery = this.m_CreateQuery.MakeGenericMethod(tts);
var excute = creatquery.Invoke(this.m_RegsQuery.Provider, new object[] { updatemethod });
var excute = creatquery.Invoke(this.m_RegsQuery.Provider, new object[] { this.m_RegMethod });
return (TResult)excute;
}

Expand Down Expand Up @@ -502,8 +498,9 @@ public TResult Execute<TResult>(Expression expression)
arg2 = typeof(TData).ToSelectData();
}
updatemethod1 = Expression.Call(oo, updatemethod1.Arguments[0], arg2, typeof(TData).ToSelectData());
this.m_ProcessExprs[expression] = updatemethod1;

}
this.m_ProcessExprs[expression] = updatemethod1;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion QSoft.Reg/RegQueryHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace QSoft.Registry.Linq
{
public static class RegQueryHelper
internal static class RegQueryHelper
{
static int m_BuildTypeCount = 0;
static void AddProperty(this TypeBuilder tb, FieldBuilder fbNumber, GenericTypeParameterBuilder generic, bool canread, bool canwrite)
Expand Down
24 changes: 4 additions & 20 deletions UnitTestProject1/LikeDB.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,8 @@ public void LeftJoin_3Table()
.SelectMany(x => x.mapping.DefaultIfEmpty(), (company, mapping) => new { company.company, mapping })
.Where(x => x.mapping != null)
.GroupJoin(apps, mapping => mapping.mapping.AppID, app => app.ID, (x, y) => new { x.company, app = y })
.SelectMany(x => x.app.DefaultIfEmpty(), (x, y) => new { x.company, app=y })
.Select(x => new { company = x.company.Key, app = x.app.ID });

//Check(left1, left2);
.SelectMany(x => x.app.DefaultIfEmpty(), (x, y) => new { Company = x.company.Name, App = y.DisplayName });
Check(left1, left2);
}

[TestMethod]
Expand Down Expand Up @@ -253,8 +251,8 @@ public void Delete()
//{
// Assert.Fail("remove fail");
//}
regt_apps.Where(x => x.Version != new Version(1, 1, 1, 1)).RemoveAll();
var apps = regt_apps.ToList();
//regt_apps.Where(x => x.Version != new Version(1, 1, 1, 1)).RemoveAll();
//var apps = regt_apps.ToList();
}

[TestMethod]
Expand All @@ -263,20 +261,6 @@ public void Update()
regt_company.Update(x => new Company() { Address = $"{x.Name}_{x.Name}" });
regt_company.Where(x => x.Name == "One").Update(x => new { Address = "Test" });
}


[TestMethod]
public void RightJoin()
{
var gj1 = regt_appmapping.GroupJoin(regt_apps, mapping => mapping.AppID, app => app.ID, (mapping, app) => new { mapping, app });
var left1 = gj1.SelectMany(x => x.app.DefaultIfEmpty(), (mapping, app) => new { mapping.mapping, app });
var apps = regt_apps.ToList();
var mappings = regt_appmapping.ToList();
var gj2 = mappings.GroupJoin(apps, mapping => mapping.AppID, app => app.ID, (mapping, app) => new { mapping, app });
var left2 = gj2.SelectMany(x => x.app.DefaultIfEmpty(), (mapping, app) => new { mapping.mapping, app });
Check(left1, left2);
}

}

public class App
Expand Down

0 comments on commit 8c3c669

Please sign in to comment.