Skip to content

Commit d3796aa

Browse files
committed
TypeIdRegistry: apply current code formatting rules
1 parent 2b285b9 commit d3796aa

File tree

1 file changed

+16
-38
lines changed

1 file changed

+16
-38
lines changed

Orm/Xtensive.Orm/Orm/Model/TypeIdRegistry.cs

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2014 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2014-2022 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Denis Krjuchkov
55
// Created: 2014.03.13
66

@@ -16,18 +16,18 @@ namespace Xtensive.Orm.Model
1616
[Serializable]
1717
public sealed class TypeIdRegistry : LockableBase
1818
{
19-
private readonly Dictionary<TypeInfo, int> mapping;
20-
private readonly Dictionary<int, TypeInfo> reverseMapping;
19+
private readonly Dictionary<TypeInfo, int> mapping = new();
20+
private readonly Dictionary<int, TypeInfo> reverseMapping = new();
2121

2222
/// <summary>
2323
/// Gets collection of registered types.
2424
/// </summary>
25-
public IEnumerable<TypeInfo> Types { get { return mapping.Keys; } }
25+
public IEnumerable<TypeInfo> Types => mapping.Keys;
2626

2727
/// <summary>
2828
/// Gets collection of registered type identifiers.
2929
/// </summary>
30-
public IEnumerable<int> TypeIdentifiers { get { return reverseMapping.Keys; } }
30+
public IEnumerable<int> TypeIdentifiers => reverseMapping.Keys;
3131

3232
/// <summary>
3333
/// Gets type identifier for the specified <paramref name="type"/>.
@@ -36,13 +36,11 @@ public sealed class TypeIdRegistry : LockableBase
3636
/// <returns>Type identifier for the specified <paramref name="type"/>.</returns>
3737
public int this[TypeInfo type]
3838
{
39-
get
40-
{
39+
get {
4140
ArgumentValidator.EnsureArgumentNotNull(type, "type");
42-
int result;
43-
if (!mapping.TryGetValue(type, out result))
44-
throw new KeyNotFoundException(string.Format(Strings.ExTypeXIsNotRegistered, type.Name));
45-
return result;
41+
return !mapping.TryGetValue(type, out var result)
42+
? throw new KeyNotFoundException(string.Format(Strings.ExTypeXIsNotRegistered, type.Name))
43+
: result;
4644
}
4745
}
4846

@@ -51,16 +49,10 @@ public int this[TypeInfo type]
5149
/// </summary>
5250
/// <param name="typeId">Type identifier to get type for.</param>
5351
/// <returns>Type for the specified <paramref name="typeId"/>.</returns>
54-
public TypeInfo this[int typeId]
55-
{
56-
get
57-
{
58-
TypeInfo result;
59-
if (!reverseMapping.TryGetValue(typeId, out result))
60-
throw new KeyNotFoundException(string.Format(Strings.ExTypeIdXIsNotRegistered, typeId));
61-
return result;
62-
}
63-
}
52+
public TypeInfo this[int typeId] =>
53+
!reverseMapping.TryGetValue(typeId, out var result)
54+
? throw new KeyNotFoundException(string.Format(Strings.ExTypeIdXIsNotRegistered, typeId))
55+
: result;
6456

6557
/// <summary>
6658
/// Checks if specified <paramref name="type"/> is registered.
@@ -86,10 +78,7 @@ public bool Contains(TypeInfo type)
8678
public int GetTypeId(TypeInfo type)
8779
{
8880
ArgumentValidator.EnsureArgumentNotNull(type, "type");
89-
int result;
90-
if (!mapping.TryGetValue(type, out result))
91-
return TypeInfo.NoTypeId;
92-
return result;
81+
return !mapping.TryGetValue(type, out var result) ? TypeInfo.NoTypeId : result;
9382
}
9483

9584
/// <summary>
@@ -117,16 +106,5 @@ public void Register(int typeId, TypeInfo type)
117106
mapping[type] = typeId;
118107
reverseMapping[typeId] = type;
119108
}
120-
121-
// Constructors
122-
123-
/// <summary>
124-
/// Initializes new instance of this type.
125-
/// </summary>
126-
public TypeIdRegistry()
127-
{
128-
mapping = new Dictionary<TypeInfo, int>();
129-
reverseMapping = new Dictionary<int, TypeInfo>();
130-
}
131109
}
132110
}

0 commit comments

Comments
 (0)