Skip to content

Commit 92c0394

Browse files
committed
Format source code as preparation to changes; update copyright comments
1 parent ad8e78e commit 92c0394

File tree

16 files changed

+315
-336
lines changed

16 files changed

+315
-336
lines changed

Orm/Xtensive.Orm/Caching/WeakCache.cs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2003-2021 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: Alex Ustinov
55
// Created: 2007.05.28
66

@@ -43,29 +43,33 @@ public class WeakCache<TKey, TItem> :
4343
#region Properites: KeyExtractor, ChainedCache, TrackResurrection, EfficiencyFactor, Count, Size
4444

4545
/// <inheritdoc/>
46-
public Converter<TItem, TKey> KeyExtractor {
46+
public Converter<TItem, TKey> KeyExtractor
47+
{
4748
[DebuggerStepThrough]
4849
get { return keyExtractor; }
4950
}
5051

5152
/// <summary>
5253
/// Gets a value indicating whether this cache tracks resurrection.
5354
/// </summary>
54-
public bool TrackResurrection {
55+
public bool TrackResurrection
56+
{
5557
[DebuggerStepThrough]
5658
get { return trackResurrection; }
5759
}
5860

5961
/// <inheritdoc/>
60-
public int Count {
62+
public int Count
63+
{
6164
[DebuggerStepThrough]
6265
get { return items.Count; }
6366
}
6467

6568
#endregion
6669

6770
/// <inheritdoc/>
68-
public TItem this[TKey key, bool markAsHit] {
71+
public TItem this[TKey key, bool markAsHit]
72+
{
6973
get {
7074
TItem item;
7175
if (TryGetItem(key, markAsHit, out item))
@@ -83,7 +87,7 @@ public virtual bool TryGetItem(TKey key, bool markAsHit, out TItem item)
8387
GCHandle cached;
8488
if (items.TryGetValue(key, out cached)) {
8589
item = (TItem) cached.Target;
86-
if (item!=null)
90+
if (item != null)
8791
return true;
8892
items.Remove(key);
8993
cached.Free();
@@ -125,7 +129,7 @@ public virtual TItem Add(TItem item, bool replaceIfExists)
125129
if (items.TryGetValue(key, out cached)) {
126130
if (!replaceIfExists) {
127131
var cachedItem = (TItem) cached.Target;
128-
if (cachedItem!=null)
132+
if (cachedItem != null)
129133
return cachedItem;
130134
}
131135
items.Remove(key);
@@ -169,7 +173,7 @@ public virtual void Clear()
169173
try {
170174
pair.Value.Free();
171175
}
172-
catch {}
176+
catch { }
173177
}
174178
finally {
175179
items = new Dictionary<TKey, GCHandle>();
@@ -188,7 +192,7 @@ public void Invalidate()
188192
public virtual void CollectGarbage()
189193
{
190194
int count = items.Count;
191-
if (count<=NoGcCount)
195+
if (count <= NoGcCount)
192196
return;
193197

194198
Exception error = null;
@@ -199,7 +203,7 @@ public virtual void CollectGarbage()
199203
foreach (var pair in items) {
200204
var cached = pair.Value;
201205
var item = cached.Target;
202-
if (item!=null)
206+
if (item != null)
203207
newItems.Add(pair.Key, cached);
204208
else
205209
cached.Free();
@@ -217,7 +221,7 @@ public virtual void CollectGarbage()
217221
// Logging
218222
if (CoreLog.IsLogged(LogLevel.Debug)) {
219223
CoreLog.Debug("WeakCache.CollectGarbage: removed: {0} from {1}", removedCount, count);
220-
if (error!=null)
224+
if (error != null)
221225
CoreLog.Debug(error, "Caught at WeakCache.CollectGarbage");
222226
}
223227
}
@@ -239,7 +243,7 @@ public virtual IEnumerator<TItem> GetEnumerator()
239243
{
240244
foreach (var pair in items) {
241245
var item = ExtractTarget(pair.Value);
242-
if (item!=null)
246+
if (item != null)
243247
yield return item;
244248
}
245249
}
@@ -290,7 +294,7 @@ public WeakCache(bool trackResurrection, Converter<TItem, TKey> keyExtractor)
290294
[SecuritySafeCritical]
291295
protected virtual void Dispose(bool disposing)
292296
{
293-
if (items!=null) {
297+
if (items != null) {
294298
try {
295299
Clear();
296300
}

Orm/Xtensive.Orm/Collections/TypeRegistry.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2003-2021 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: Dmitri Maximov
55
// Created: 2007.08.03
66

@@ -37,7 +37,7 @@ public class TypeRegistry : LockableBase,
3737
/// <summary>
3838
/// Gets assemblies containing registered types.
3939
/// </summary>
40-
public Set<Assembly> Assemblies{ get { return assemblies; } }
40+
public Set<Assembly> Assemblies { get { return assemblies; } }
4141

4242
/// <summary>
4343
/// Determines whether the specified <see cref="Type"/> is contained in this instance.
@@ -74,7 +74,7 @@ public void Register(Type type)
7474
/// Search is restricted by assembly only.
7575
/// </summary>
7676
/// <param name="assembly">Assembly to search for types.</param>
77-
/// <exception cref="InvalidOperationException">When <see cref="Assembly.GetTypes()"/>
77+
/// <exception cref="InvalidOperationException">When <see cref="Assembly.GetTypes()"/>
7878
/// method call has thrown an exception or if no suitable types were found.</exception>
7979
/// <exception cref="ArgumentNullException">When <paramref name="assembly"/> is null.</exception>
8080
public void Register(Assembly assembly)
@@ -90,9 +90,9 @@ public void Register(Assembly assembly)
9090
/// </summary>
9191
/// <param name="assembly">Assembly to search for types.</param>
9292
/// <param name="namespace">Namespace to search for types.</param>
93-
/// <exception cref="InvalidOperationException">When <see cref="Assembly.GetTypes()"/>
93+
/// <exception cref="InvalidOperationException">When <see cref="Assembly.GetTypes()"/>
9494
/// method call has thrown an exception or if no suitable types were found.</exception>
95-
/// <exception cref="ArgumentNullException">When <paramref name="assembly"/> is null
95+
/// <exception cref="ArgumentNullException">When <paramref name="assembly"/> is null
9696
/// or <paramref name="namespace"/> is empty string.</exception>
9797
public void Register(Assembly assembly, string @namespace)
9898
{
@@ -132,7 +132,7 @@ private void ProcessPendingActions()
132132
actions.Clear();
133133
foreach (var action in oldActions)
134134
processor.Process(this, action);
135-
if (actions.Count==0)
135+
if (actions.Count == 0)
136136
break;
137137
}
138138
}
@@ -182,7 +182,8 @@ IEnumerator IEnumerable.GetEnumerator()
182182
/// <summary>
183183
/// Gets the number of types registered in this instance.
184184
/// </summary>
185-
public int Count {
185+
public int Count
186+
{
186187
get {
187188
ProcessPendingActions();
188189
return types.Count;

Orm/Xtensive.Orm/Core/Pair{TFirst,TSecond}.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2003-2021 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: Alex Ustinov
55
// Created: 2007.06.01
66

@@ -17,7 +17,7 @@ namespace Xtensive.Core
1717
/// <typeparam name="TSecond">The <see cref="Type"/> of second value.</typeparam>
1818
[Serializable]
1919
[DebuggerDisplay("{First}, {Second}")]
20-
public readonly struct Pair<TFirst, TSecond> :
20+
public readonly struct Pair<TFirst, TSecond> :
2121
IComparable<Pair<TFirst, TSecond>>,
2222
IEquatable<Pair<TFirst, TSecond>>
2323
{
@@ -44,7 +44,7 @@ public bool Equals(Pair<TFirst, TSecond> other)
4444
public int CompareTo(Pair<TFirst, TSecond> other)
4545
{
4646
int result = AdvancedComparerStruct<TFirst>.System.Compare(First, other.First);
47-
if (result!=0)
47+
if (result != 0)
4848
return result;
4949
return AdvancedComparerStruct<TSecond>.System.Compare(Second, other.Second);
5050
}
@@ -56,7 +56,7 @@ public int CompareTo(Pair<TFirst, TSecond> other)
5656
/// <inheritdoc/>
5757
public override bool Equals(object obj)
5858
{
59-
if (obj.GetType()!=typeof (Pair<TFirst, TSecond>))
59+
if (obj.GetType() != typeof(Pair<TFirst, TSecond>))
6060
return false;
6161
return Equals((Pair<TFirst, TSecond>) obj);
6262
}

Orm/Xtensive.Orm/IoC/Internals/DefaultServiceContainer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2010-2021 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: Alex Yakunin
55
// Created: 2010.01.30
66

@@ -17,7 +17,7 @@ namespace Xtensive.IoC
1717
{
1818
internal sealed class DefaultServiceContainer : ServiceContainerBase
1919
{
20-
ThreadSafeDictionary<Assembly, IServiceContainer> containers =
20+
ThreadSafeDictionary<Assembly, IServiceContainer> containers =
2121
ThreadSafeDictionary<Assembly, IServiceContainer>.Create(new object());
2222

2323
protected override IEnumerable<object> HandleGetAll(Type serviceType)

Orm/Xtensive.Orm/IoC/ServiceContainer.cs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2009-2020 Xtensive LLC.
1+
// Copyright (C) 2009-2021 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: Dmitri Maximov
@@ -15,7 +15,7 @@
1515
using Xtensive.IoC.Configuration;
1616
using AttributeSearchOptions = Xtensive.Reflection.AttributeSearchOptions;
1717
using AppConfiguration = System.Configuration.Configuration;
18-
using ConfigurationSection=Xtensive.IoC.Configuration.ConfigurationSection;
18+
using ConfigurationSection = Xtensive.IoC.Configuration.ConfigurationSection;
1919

2020
namespace Xtensive.IoC
2121
{
@@ -25,11 +25,11 @@ namespace Xtensive.IoC
2525
[Serializable]
2626
public class ServiceContainer : ServiceContainerBase
2727
{
28-
private readonly Dictionary<object, List<ServiceRegistration>> types =
28+
private readonly Dictionary<object, List<ServiceRegistration>> types =
2929
new Dictionary<object, List<ServiceRegistration>>();
30-
private readonly Dictionary<ServiceRegistration, object> instances =
30+
private readonly Dictionary<ServiceRegistration, object> instances =
3131
new Dictionary<ServiceRegistration, object>();
32-
private readonly Dictionary<ServiceRegistration, Pair<ConstructorInfo,ParameterInfo[]>> constructorCache =
32+
private readonly Dictionary<ServiceRegistration, Pair<ConstructorInfo, ParameterInfo[]>> constructorCache =
3333
new Dictionary<ServiceRegistration, Pair<ConstructorInfo, ParameterInfo[]>>();
3434
private readonly HashSet<Type> creating = new HashSet<Type>();
3535
private readonly object _lock = new object();
@@ -45,7 +45,7 @@ protected override object HandleGet(Type serviceType, string name)
4545
List<ServiceRegistration> list;
4646
if (!types.TryGetValue(GetKey(serviceType, name), out list))
4747
return null;
48-
if (list.Count==0)
48+
if (list.Count == 0)
4949
return null;
5050
if (list.Count > 1)
5151
throw new AmbiguousMatchException(Strings.ExMultipleServicesMatchToTheSpecifiedArguments);
@@ -75,25 +75,25 @@ protected virtual object CreateInstance(ServiceRegistration serviceInfo)
7575
{
7676
if (creating.Contains(serviceInfo.Type))
7777
throw new ActivationException(Strings.ExRecursiveConstructorParemeterDependencyIsDetected);
78-
Pair<ConstructorInfo,ParameterInfo[]> cachedInfo;
78+
Pair<ConstructorInfo, ParameterInfo[]> cachedInfo;
7979
var mappedType = serviceInfo.MappedType;
8080
if (!constructorCache.TryGetValue(serviceInfo, out cachedInfo)) {
8181
var @ctor = (
8282
from c in mappedType.GetConstructors()
83-
where c.GetAttribute<ServiceConstructorAttribute>(AttributeSearchOptions.InheritNone)!=null
83+
where c.GetAttribute<ServiceConstructorAttribute>(AttributeSearchOptions.InheritNone) != null
8484
select c
8585
).SingleOrDefault();
86-
if (@ctor==null)
86+
if (@ctor == null)
8787
@ctor = mappedType.GetConstructor(ArrayUtils<Type>.EmptyArray);
88-
var @params = @ctor==null ? null : @ctor.GetParameters();
88+
var @params = @ctor == null ? null : @ctor.GetParameters();
8989
cachedInfo = new Pair<ConstructorInfo, ParameterInfo[]>(@ctor, @params);
9090
constructorCache[serviceInfo] = cachedInfo;
9191
}
9292
var cInfo = cachedInfo.First;
93-
if (cInfo==null)
93+
if (cInfo == null)
9494
return null;
9595
var pInfos = cachedInfo.Second;
96-
if (pInfos.Length==0)
96+
if (pInfos.Length == 0)
9797
return Activator.CreateInstance(mappedType);
9898
var args = new object[pInfos.Length];
9999
creating.Add(serviceInfo.Type);
@@ -128,7 +128,7 @@ private IEnumerable<object> GetOrCreateInstances(IEnumerable<ServiceRegistration
128128
continue;
129129
}
130130

131-
if (registration.MappedInstance!=null)
131+
if (registration.MappedInstance != null)
132132
result = registration.MappedInstance;
133133
else
134134
result = CreateInstance(registration);
@@ -207,12 +207,12 @@ public static IServiceContainer Create(Type containerType, object configuration,
207207

208208
var possibleArgs =
209209
Enumerable.Empty<object[]>()
210-
.Append(new[] {configuration, parent})
211-
.Append(new[] {configuration})
212-
.Append(new[] {parent});
210+
.Append(new[] { configuration, parent })
211+
.Append(new[] { configuration })
212+
.Append(new[] { parent });
213213
foreach (var args in possibleArgs) {
214214
var ctor = containerType.GetConstructor(args);
215-
if (ctor!=null)
215+
if (ctor != null)
216216
return (IServiceContainer) ctor.Invoke(args);
217217
}
218218

@@ -270,7 +270,7 @@ public static IServiceContainer Create(ConfigurationSection section, string name
270270
return Create(section, name, null);
271271
}
272272

273-
/// <summary>
273+
/// <summary>
274274
/// Creates <see cref="IServiceContainer"/> by its configuration.
275275
/// </summary>
276276
/// <param name="section">IoC configuration section.</param>
@@ -284,9 +284,9 @@ public static IServiceContainer Create(ConfigurationSection section, string name
284284
if (name.IsNullOrEmpty())
285285
name = string.Empty;
286286

287-
ContainerElement configuration = section==null ? null : section.Containers[name];
287+
ContainerElement configuration = section == null ? null : section.Containers[name];
288288

289-
if (configuration==null)
289+
if (configuration == null)
290290
configuration = new ContainerElement();
291291

292292
var registrations = new List<ServiceRegistration>();
@@ -299,12 +299,12 @@ public static IServiceContainer Create(ConfigurationSection section, string name
299299
foreach (var serviceRegistrationElement in configuration.Explicit)
300300
registrations.Add(serviceRegistrationElement.ToNative());
301301

302-
var currentParent = configuration.Parent.IsNullOrEmpty()
303-
? parent
302+
var currentParent = configuration.Parent.IsNullOrEmpty()
303+
? parent
304304
: Create(section, configuration.Parent, parent);
305-
306-
var containerType = configuration.Type.IsNullOrEmpty() ?
307-
typeof(ServiceContainer) :
305+
306+
var containerType = configuration.Type.IsNullOrEmpty() ?
307+
typeof(ServiceContainer) :
308308
Type.GetType(configuration.Type);
309309
return Create(containerType, registrations, currentParent);
310310
}
@@ -337,7 +337,7 @@ public ServiceContainer(IEnumerable<ServiceRegistration> configuration)
337337
public ServiceContainer(IEnumerable<ServiceRegistration> configuration, IServiceContainer parent)
338338
: base(parent)
339339
{
340-
if (configuration==null)
340+
if (configuration == null)
341341
return;
342342
foreach (var serviceRegistration in configuration)
343343
Register(serviceRegistration);
@@ -351,7 +351,7 @@ public override void Dispose()
351351
foreach (var pair in instances) {
352352
var service = pair.Value;
353353
var disposable = service as IDisposable;
354-
if (disposable!=null)
354+
if (disposable != null)
355355
toDispose.Add(disposable);
356356
}
357357
}

0 commit comments

Comments
 (0)