Skip to content

Commit dd5f3af

Browse files
committed
Simplify Provider class code
1 parent 435d1d3 commit dd5f3af

1 file changed

Lines changed: 9 additions & 20 deletions

File tree

Orm/Xtensive.Orm/Orm/Rse/Providers/Provider.cs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2008-2020 Xtensive LLC.
1+
// Copyright (C) 2008-2022 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Alexey Kochetov
@@ -23,36 +23,23 @@ public abstract class Provider
2323
private const string ToString_Parameters = " ({0})";
2424
private const int ToString_IndentSize = 2;
2525

26-
private Provider[] sources;
27-
2826
/// <summary>
2927
/// Gets <see cref="ProviderType"/> of the current instance.
3028
/// </summary>
31-
public ProviderType Type { get; private set; }
29+
public ProviderType Type { get; }
3230

3331
/// <summary>
3432
/// Gets or sets the source providers
3533
/// "consumed" by this provider to produce results of current provider.
3634
/// </summary>
37-
public Provider[] Sources {
38-
[DebuggerStepThrough]
39-
get { return sources; }
40-
[DebuggerStepThrough]
41-
private set {
42-
if (sources!=null)
43-
throw Exceptions.AlreadyInitialized("Sources");
44-
sources = value;
45-
}
46-
}
35+
public Provider[] Sources { get; }
4736

4837
/// <summary>
4938
/// Gets or sets the header of the record sequence this provide produces.
5039
/// </summary>
5140
public RecordSetHeader Header { get; }
5241

53-
private string DebuggerDisplayName {
54-
get { return GetType().GetShortName(); }
55-
}
42+
private string DebuggerDisplayName => GetType().GetShortName();
5643

5744
#region ToString method
5845

@@ -67,9 +54,10 @@ public sealed override string ToString()
6754
private void AppendBodyTo(StringBuilder sb, int indent)
6855
{
6956
AppendTitleTo(sb, indent);
70-
indent = indent + ToString_IndentSize;
71-
foreach (var source in Sources)
57+
indent += ToString_IndentSize;
58+
foreach (var source in Sources) {
7259
source.AppendBodyTo(sb, indent);
60+
}
7361
}
7462

7563
private void AppendTitleTo(StringBuilder sb, int indent)
@@ -85,8 +73,9 @@ private string TitleToString()
8573
string parameters = ParametersToString();
8674

8775
sb.Append(providerName);
88-
if (!parameters.IsNullOrEmpty())
76+
if (!parameters.IsNullOrEmpty()) {
8977
sb.AppendFormat(ToString_Parameters, parameters);
78+
}
9079
return sb.ToString();
9180
}
9281

0 commit comments

Comments
 (0)