Skip to content

Commit fb79218

Browse files
committed
Continue refactoring
1 parent e217422 commit fb79218

89 files changed

Lines changed: 303 additions & 386 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlAddColumn.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ public class SqlAddColumn : SqlAction
1212
{
1313
public TableColumn Column { get; private set; }
1414

15-
internal override object Clone(SqlNodeCloneContext context) =>
16-
context.NodeMapping.TryGetValue(this, out var clone)
17-
? clone
18-
: context.NodeMapping[this] = new SqlAddColumn(Column);
15+
internal override SqlAddColumn Clone(SqlNodeCloneContext context) =>
16+
context.GetOrAdd(this, static (t, c) =>
17+
new SqlAddColumn(t.Column));
1918

2019
// Constructors
2120

Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlAddConstraint.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ public class SqlAddConstraint : SqlAction
1212
{
1313
public Constraint Constraint { get; private set; }
1414

15-
internal override object Clone(SqlNodeCloneContext context) =>
16-
context.NodeMapping.TryGetValue(this, out var clone)
17-
? clone
18-
: context.NodeMapping[this] = new SqlAddConstraint(Constraint);
15+
internal override SqlAddConstraint Clone(SqlNodeCloneContext context) =>
16+
context.GetOrAdd(this, static (t, c) =>
17+
new SqlAddConstraint(t.Constraint));
1918

2019
// Constructors
2120

Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlAlterIdentityInfo.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ public class SqlAlterIdentityInfo : SqlAction
1414
public SequenceDescriptor SequenceDescriptor { get; set; }
1515
public SqlAlterIdentityInfoOptions InfoOption { get; set; }
1616

17-
internal override object Clone(SqlNodeCloneContext context) =>
18-
context.NodeMapping.TryGetValue(this, out var clone)
19-
? clone
20-
: context.NodeMapping[this] = new SqlAlterIdentityInfo(Column, (SequenceDescriptor) SequenceDescriptor.Clone(), InfoOption);
17+
internal override SqlAlterIdentityInfo Clone(SqlNodeCloneContext context) =>
18+
context.GetOrAdd(this, static (t, c) =>
19+
new SqlAlterIdentityInfo(t.Column, (SequenceDescriptor) t.SequenceDescriptor.Clone(), t.InfoOption));
2120

2221
internal SqlAlterIdentityInfo(TableColumn column, SequenceDescriptor sequenceDescriptor, SqlAlterIdentityInfoOptions infoOption)
2322
{

Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlDropColumn.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ public class SqlDropColumn : SqlCascadableAction
1212
{
1313
public TableColumn Column { get; private set; }
1414

15-
internal override object Clone(SqlNodeCloneContext context) =>
16-
context.NodeMapping.TryGetValue(this, out var clone)
17-
? clone
18-
: context.NodeMapping[this] = new SqlDropColumn(Column);
15+
internal override SqlDropColumn Clone(SqlNodeCloneContext context) =>
16+
context.GetOrAdd(this, static (t, c) =>
17+
new SqlDropColumn(t.Column));
1918

2019
// Constructors
2120

Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlDropConstraint.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ public class SqlDropConstraint : SqlCascadableAction
1212
{
1313
public Constraint Constraint { get; private set; }
1414

15-
internal override object Clone(SqlNodeCloneContext context) =>
16-
context.NodeMapping.TryGetValue(this, out var clone)
17-
? clone
18-
: context.NodeMapping[this] = new SqlDropConstraint(Constraint, Cascade);
15+
internal override SqlDropConstraint Clone(SqlNodeCloneContext context) =>
16+
context.GetOrAdd(this, static (t, c) =>
17+
new SqlDropConstraint(t.Constraint, t.Cascade));
1918

2019
// Constructors
2120

Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlDropDefault.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ public class SqlDropDefault : SqlAction
1212
{
1313
public TableColumn Column { get; private set; }
1414

15-
internal override object Clone(SqlNodeCloneContext context) =>
16-
context.NodeMapping.TryGetValue(this, out var clone)
17-
? clone
18-
: context.NodeMapping[this] = new SqlDropDefault(Column);
15+
internal override SqlDropDefault Clone(SqlNodeCloneContext context) =>
16+
context.GetOrAdd(this, static (t, c) =>
17+
new SqlDropDefault(t.Column));
1918

2019
// Constructors
2120

Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlRenameColumn.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@ public class SqlRenameColumn : SqlAction
1515
public TableColumn Column { get; private set; }
1616
public string NewName { get; private set; }
1717

18-
internal override object Clone(SqlNodeCloneContext context) =>
19-
context.NodeMapping.TryGetValue(this, out var clone)
20-
? clone
21-
: context.NodeMapping[this] = new SqlRenameColumn(Column, NewName);
18+
internal override SqlRenameColumn Clone(SqlNodeCloneContext context) =>
19+
context.GetOrAdd(this, static (t, c) =>
20+
new SqlRenameColumn(t.Column, t.NewName));
2221

2322

2423
// Constructors

Orm/Xtensive.Orm/Sql/Ddl/Actions/SqlSetDefault.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ public class SqlSetDefault : SqlAction
1414
public TableColumn Column { get; private set; }
1515
public SqlExpression DefaultValue { get; private set; }
1616

17-
internal override object Clone(SqlNodeCloneContext context) =>
18-
context.NodeMapping.TryGetValue(this, out var clone)
19-
? clone
20-
: context.NodeMapping[this] = new SqlSetDefault(DefaultValue.Clone(context), Column);
17+
internal override SqlSetDefault Clone(SqlNodeCloneContext context) =>
18+
context.GetOrAdd(this, static (t, c) =>
19+
new SqlSetDefault(t.DefaultValue.Clone(c), t.Column));
2120

2221
internal SqlSetDefault(SqlExpression defaultValue, TableColumn column)
2322
{

Orm/Xtensive.Orm/Sql/Ddl/SqlAlterDomain.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ public Domain Domain {
2525
}
2626
}
2727

28-
29-
internal override object Clone(SqlNodeCloneContext context) =>
30-
context.NodeMapping.TryGetValue(this, out var clone)
31-
? clone
32-
: context.NodeMapping[this] = new SqlAlterDomain(domain, (SqlAction)action.Clone(context));
28+
internal override SqlAlterDomain Clone(SqlNodeCloneContext context) =>
29+
context.GetOrAdd(this, static (t, c) =>
30+
new SqlAlterDomain(t.domain, (SqlAction)t.action.Clone(c)));
3331

3432
public override void AcceptVisitor(ISqlVisitor visitor)
3533
{

Orm/Xtensive.Orm/Sql/Ddl/SqlAlterPartitionFunction.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ public SqlAlterPartitionFunctionOption Option
3131
set { option = value; }
3232
}
3333

34-
internal override object Clone(SqlNodeCloneContext context) =>
35-
context.NodeMapping.TryGetValue(this, out var clone)
36-
? clone
37-
: context.NodeMapping[this] = new SqlAlterPartitionFunction(partitionFunction, boundary, option);
34+
internal override SqlAlterPartitionFunction Clone(SqlNodeCloneContext context) =>
35+
context.GetOrAdd(this, static (t, c) =>
36+
new SqlAlterPartitionFunction(t.partitionFunction, t.boundary, t.option));
3837

3938
public override void AcceptVisitor(ISqlVisitor visitor)
4039
{

0 commit comments

Comments
 (0)