Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factory could be replaced with new TThis(); #31

Open
dbarwikowski opened this issue Jul 27, 2022 · 0 comments
Open

Factory could be replaced with new TThis(); #31

dbarwikowski opened this issue Jul 27, 2022 · 0 comments

Comments

@dbarwikowski
Copy link
dbarwikowski commented Jul 27, 2022

Code could be simplified.

TThis x = Factory();

TThis x = new TThis();

Contents of constructor could be removed then:

static ValueOf()
{
ConstructorInfo ctor = typeof(TThis)
.GetTypeInfo()
.DeclaredConstructors
.First();
var argsExp = new Expression[0];
NewExpression newExp = Expression.New(ctor, argsExp);
LambdaExpression lambda = Expression.Lambda(typeof(Func<TThis>), newExp);
Factory = (Func<TThis>)lambda.Compile();
}

@dbarwikowski dbarwikowski changed the title Factory could be replaced with new(); Factory could be replaced with new TThis(); Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant