Skip to content

Commit

Permalink
Switch usage of deprecated Castle.Core.Pair to System.Tuple
Browse files Browse the repository at this point in the history
castleproject#612 - Updating Windsor to support Castle.Core@5.0.0 and modern TFMs
  • Loading branch information
Jevonius committed May 14, 2022
1 parent 3c53771 commit a61f16a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace Castle.MicroKernel.SubSystems.Conversion
public class DefaultConversionManager : AbstractSubSystem, IConversionManager, ITypeConverterContext
{
[ThreadStatic]
private static Stack<Pair<ComponentModel,CreationContext>> slot;
private static Stack<Tuple<ComponentModel,CreationContext>> slot;
private readonly IList<ITypeConverter> converters = new List<ITypeConverter>();
private readonly IList<ITypeConverter> standAloneConverters = new List<ITypeConverter>();

Expand Down Expand Up @@ -146,7 +146,7 @@ IKernelInternal ITypeConverterContext.Kernel

public void Push(ComponentModel model, CreationContext context)
{
CurrentStack.Push(new Pair<ComponentModel, CreationContext>(model, context));
CurrentStack.Push(new Tuple<ComponentModel, CreationContext>(model, context));
}

public void Pop()
Expand All @@ -163,7 +163,7 @@ public ComponentModel CurrentModel
return null;
}

return CurrentStack.Peek().First;
return CurrentStack.Peek().Item1;
}
}

Expand All @@ -176,7 +176,7 @@ public CreationContext CurrentCreationContext
return null;
}

return CurrentStack.Peek().Second;
return CurrentStack.Peek().Item2;
}
}

Expand All @@ -185,13 +185,13 @@ public ITypeConverter Composition
get { return this; }
}

private Stack<Pair<ComponentModel, CreationContext>> CurrentStack
private Stack<Tuple<ComponentModel, CreationContext>> CurrentStack
{
get
{
if (slot == null)
{
slot = new Stack<Pair<ComponentModel, CreationContext>>();
slot = new Stack<Tuple<ComponentModel, CreationContext>>();
}

return slot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ public string GetDetails(DependencyDuplicate duplicates)
return details.ToString();
}

public Pair<IHandler, DependencyDuplicate[]>[] Inspect()
public Tuple<IHandler, DependencyDuplicate[]>[] Inspect()
{
var allHandlers = kernel.GetAssignableHandlers(typeof(object));
var result = new List<Pair<IHandler, DependencyDuplicate[]>>();
var result = new List<Tuple<IHandler, DependencyDuplicate[]>>();
foreach (var handler in allHandlers)
{
var duplicateDependencies = FindDuplicateDependenciesFor(handler);
if (duplicateDependencies.Length > 0)
{
result.Add(new Pair<IHandler, DependencyDuplicate[]>(handler, duplicateDependencies));
result.Add(new Tuple<IHandler, DependencyDuplicate[]>(handler, duplicateDependencies));
}
}
return result.ToArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public override void Init(IKernel kernel, IDiagnosticsHost diagnosticsHost)
diagnosticsHost.AddDiagnostic<IDuplicatedDependenciesDiagnostic>(diagnostic);
}

private ComponentDebuggerView[] BuildItems(Pair<IHandler, DependencyDuplicate[]>[] results)
private ComponentDebuggerView[] BuildItems(Tuple<IHandler, DependencyDuplicate[]>[] results)
{
return results.ConvertAll(ComponentWithDuplicateDependenciesView);
}

private ComponentDebuggerView ComponentWithDuplicateDependenciesView(Pair<IHandler, DependencyDuplicate[]> input)
private ComponentDebuggerView ComponentWithDuplicateDependenciesView(Tuple<IHandler, DependencyDuplicate[]> input)
{
var handler = input.First;
var mismatches = input.Second;
var handler = input.Item1;
var mismatches = input.Item2;
var items = mismatches.ConvertAll(MismatchView);
Array.Sort(items, (c1, c2) => c1.Name.CompareTo(c2.Name));
return ComponentDebuggerView.BuildRawFor(handler, "Count = " + mismatches.Length, items);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@

namespace Castle.Windsor.Diagnostics
{
using Castle.Core;
using System;

using Castle.MicroKernel;

/// <summary>
/// Collects dependencies that are duplicated between constructors and properties.
/// </summary>
public interface IDuplicatedDependenciesDiagnostic : IDiagnostic<Pair<IHandler, DependencyDuplicate[]>[]>
public interface IDuplicatedDependenciesDiagnostic : IDiagnostic<Tuple<IHandler, DependencyDuplicate[]>[]>
{
}
}

0 comments on commit a61f16a

Please sign in to comment.