All unit test classes are now internal; updated copyright statement for the year 2012; added hulls for the upcoming ObservableSet<> and ReadOnlySet<> classes; switched generic parameter naming convention TSomething instead of SomethingType
git-svn-id: file:///srv/devel/repo-conversion/nusu@252 d2e56fa2-650e-0410-a79f-9358c0239efd
This commit is contained in:
parent
61c858cb1c
commit
75552b5150
|
@ -108,6 +108,10 @@
|
||||||
<Compile Include="Source\Collections\ItemEventArgs.Test.cs">
|
<Compile Include="Source\Collections\ItemEventArgs.Test.cs">
|
||||||
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ItemReplaceEventArgs.cs" />
|
||||||
|
<Compile Include="Source\Collections\ItemReplaceEventArgs.Test.cs">
|
||||||
|
<DependentUpon>ItemReplaceEventArgs.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\MultiDictionary.cs" />
|
<Compile Include="Source\Collections\MultiDictionary.cs" />
|
||||||
<Compile Include="Source\Collections\MultiDictionary.ValueCollection.cs">
|
<Compile Include="Source\Collections\MultiDictionary.ValueCollection.cs">
|
||||||
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
||||||
|
@ -130,6 +134,10 @@
|
||||||
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
||||||
<DependentUpon>ObservableList.cs</DependentUpon>
|
<DependentUpon>ObservableList.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ObservableSet.cs" />
|
||||||
|
<Compile Include="Source\Collections\ObservableSet.Test.cs">
|
||||||
|
<DependentUpon>ObservableSet.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\PairPriorityQueue.cs" />
|
<Compile Include="Source\Collections\PairPriorityQueue.cs" />
|
||||||
<Compile Include="Source\Collections\PairPriorityQueue.Test.cs">
|
<Compile Include="Source\Collections\PairPriorityQueue.Test.cs">
|
||||||
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
||||||
|
@ -166,6 +174,10 @@
|
||||||
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
||||||
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ReadOnlySet.cs" />
|
||||||
|
<Compile Include="Source\Collections\ReadOnlySet.Test.cs">
|
||||||
|
<DependentUpon>ReadOnlySet.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\ReverseComparer.cs" />
|
<Compile Include="Source\Collections\ReverseComparer.cs" />
|
||||||
<Compile Include="Source\Collections\ReverseComparer.Test.cs">
|
<Compile Include="Source\Collections\ReverseComparer.Test.cs">
|
||||||
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
||||||
|
|
|
@ -106,12 +106,12 @@
|
||||||
<Compile Include="Source\Cloning\ExpressionTreeCloner.Test.cs">
|
<Compile Include="Source\Cloning\ExpressionTreeCloner.Test.cs">
|
||||||
<DependentUpon>ExpressionTreeCloner.cs</DependentUpon>
|
<DependentUpon>ExpressionTreeCloner.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Source\Cloning\ICloneFactory.cs" />
|
|
||||||
<Compile Include="Source\Cloning\IStateCopier.cs" />
|
<Compile Include="Source\Cloning\IStateCopier.cs" />
|
||||||
<Compile Include="Source\Cloning\ReflectionCloner.cs" />
|
<Compile Include="Source\Cloning\ReflectionCloner.cs" />
|
||||||
<Compile Include="Source\Cloning\ReflectionCloner.Test.cs">
|
<Compile Include="Source\Cloning\ReflectionCloner.Test.cs">
|
||||||
<DependentUpon>ReflectionCloner.cs</DependentUpon>
|
<DependentUpon>ReflectionCloner.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Cloning\ICloneFactory.cs" />
|
||||||
<Compile Include="Source\Cloning\SerializationCloner.cs" />
|
<Compile Include="Source\Cloning\SerializationCloner.cs" />
|
||||||
<Compile Include="Source\Cloning\SerializationCloner.Test.cs">
|
<Compile Include="Source\Cloning\SerializationCloner.Test.cs">
|
||||||
<DependentUpon>SerializationCloner.cs</DependentUpon>
|
<DependentUpon>SerializationCloner.cs</DependentUpon>
|
||||||
|
@ -139,6 +139,10 @@
|
||||||
<Compile Include="Source\Collections\ItemEventArgs.Test.cs">
|
<Compile Include="Source\Collections\ItemEventArgs.Test.cs">
|
||||||
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ItemReplaceEventArgs.cs" />
|
||||||
|
<Compile Include="Source\Collections\ItemReplaceEventArgs.Test.cs">
|
||||||
|
<DependentUpon>ItemReplaceEventArgs.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\MultiDictionary.cs" />
|
<Compile Include="Source\Collections\MultiDictionary.cs" />
|
||||||
<Compile Include="Source\Collections\MultiDictionary.ValueCollection.cs">
|
<Compile Include="Source\Collections\MultiDictionary.ValueCollection.cs">
|
||||||
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
||||||
|
@ -161,6 +165,10 @@
|
||||||
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
||||||
<DependentUpon>ObservableList.cs</DependentUpon>
|
<DependentUpon>ObservableList.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ObservableSet.cs" />
|
||||||
|
<Compile Include="Source\Collections\ObservableSet.Test.cs">
|
||||||
|
<DependentUpon>ObservableSet.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\PairPriorityQueue.cs" />
|
<Compile Include="Source\Collections\PairPriorityQueue.cs" />
|
||||||
<Compile Include="Source\Collections\PairPriorityQueue.Test.cs">
|
<Compile Include="Source\Collections\PairPriorityQueue.Test.cs">
|
||||||
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
||||||
|
@ -197,6 +205,10 @@
|
||||||
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
||||||
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ReadOnlySet.cs" />
|
||||||
|
<Compile Include="Source\Collections\ReadOnlySet.Test.cs">
|
||||||
|
<DependentUpon>ReadOnlySet.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\ReverseComparer.cs" />
|
<Compile Include="Source\Collections\ReverseComparer.cs" />
|
||||||
<Compile Include="Source\Collections\ReverseComparer.Test.cs">
|
<Compile Include="Source\Collections\ReverseComparer.Test.cs">
|
||||||
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
||||||
|
@ -214,34 +226,6 @@
|
||||||
<Compile Include="Source\Semaphore.Test.cs">
|
<Compile Include="Source\Semaphore.Test.cs">
|
||||||
<DependentUpon>Semaphore.cs</DependentUpon>
|
<DependentUpon>Semaphore.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Source\Services\AppDomainTypeLister.cs" />
|
|
||||||
<Compile Include="Source\Services\AppDomainTypeLister.Test.cs">
|
|
||||||
<DependentUpon>AppDomainTypeLister.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\MultiAssemblyTypeLister.cs" />
|
|
||||||
<Compile Include="Source\Services\ExplicitTypeLister.Test.cs">
|
|
||||||
<DependentUpon>ExplicitTypeLister.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\Instancing.cs" />
|
|
||||||
<Compile Include="Source\Services\ITypeLister.cs" />
|
|
||||||
<Compile Include="Source\Services\MultiAssemblyTypeLister.Test.cs">
|
|
||||||
<DependentUpon>MultiAssemblyTypeLister.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\ProgressTracking\IProgressPublishingService.cs" />
|
|
||||||
<Compile Include="Source\Services\ProgressTracking\IProgressCollectingService.cs" />
|
|
||||||
<Compile Include="Source\Services\ProgressTracking\ITrackedProcess.cs" />
|
|
||||||
<Compile Include="Source\Services\ProgressTracking\ProgressTrackingComponent.cs" />
|
|
||||||
<Compile Include="Source\Services\RepositoryTypeLister.cs" />
|
|
||||||
<Compile Include="Source\Services\RepositoryTypeLister.Test.cs">
|
|
||||||
<DependentUpon>RepositoryTypeLister.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\ServiceManager.Analyzer.cs">
|
|
||||||
<DependentUpon>ServiceManager.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\ServiceManager.cs" />
|
|
||||||
<Compile Include="Source\Services\ServiceManager.For.cs">
|
|
||||||
<DependentUpon>ServiceManager.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\IO\PartialStream.cs" />
|
<Compile Include="Source\IO\PartialStream.cs" />
|
||||||
<Compile Include="Source\IO\PartialStream.Test.cs">
|
<Compile Include="Source\IO\PartialStream.Test.cs">
|
||||||
<DependentUpon>PartialStream.cs</DependentUpon>
|
<DependentUpon>PartialStream.cs</DependentUpon>
|
||||||
|
@ -327,10 +311,6 @@
|
||||||
<Compile Include="Source\Plugins\PluginRepository.Test.cs">
|
<Compile Include="Source\Plugins\PluginRepository.Test.cs">
|
||||||
<DependentUpon>PluginRepository.cs</DependentUpon>
|
<DependentUpon>PluginRepository.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Source\Services\ServiceManager.Test.cs">
|
|
||||||
<DependentUpon>ServiceManager.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\ExplicitTypeLister.cs" />
|
|
||||||
<Compile Include="Source\Shared.cs" />
|
<Compile Include="Source\Shared.cs" />
|
||||||
<Compile Include="Source\Shared.Test.cs">
|
<Compile Include="Source\Shared.Test.cs">
|
||||||
<DependentUpon>Shared.cs</DependentUpon>
|
<DependentUpon>Shared.cs</DependentUpon>
|
||||||
|
|
|
@ -117,12 +117,12 @@
|
||||||
<Compile Include="Source\Cloning\ExpressionTreeCloner.Test.cs">
|
<Compile Include="Source\Cloning\ExpressionTreeCloner.Test.cs">
|
||||||
<DependentUpon>ExpressionTreeCloner.cs</DependentUpon>
|
<DependentUpon>ExpressionTreeCloner.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Source\Cloning\ICloneFactory.cs" />
|
|
||||||
<Compile Include="Source\Cloning\IStateCopier.cs" />
|
<Compile Include="Source\Cloning\IStateCopier.cs" />
|
||||||
<Compile Include="Source\Cloning\ReflectionCloner.cs" />
|
<Compile Include="Source\Cloning\ReflectionCloner.cs" />
|
||||||
<Compile Include="Source\Cloning\ReflectionCloner.Test.cs">
|
<Compile Include="Source\Cloning\ReflectionCloner.Test.cs">
|
||||||
<DependentUpon>ReflectionCloner.cs</DependentUpon>
|
<DependentUpon>ReflectionCloner.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Cloning\ICloneFactory.cs" />
|
||||||
<Compile Include="Source\Cloning\SerializationCloner.cs" />
|
<Compile Include="Source\Cloning\SerializationCloner.cs" />
|
||||||
<Compile Include="Source\Cloning\SerializationCloner.Test.cs">
|
<Compile Include="Source\Cloning\SerializationCloner.Test.cs">
|
||||||
<DependentUpon>SerializationCloner.cs</DependentUpon>
|
<DependentUpon>SerializationCloner.cs</DependentUpon>
|
||||||
|
@ -150,6 +150,10 @@
|
||||||
<Compile Include="Source\Collections\ItemEventArgs.Test.cs">
|
<Compile Include="Source\Collections\ItemEventArgs.Test.cs">
|
||||||
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ItemReplaceEventArgs.cs" />
|
||||||
|
<Compile Include="Source\Collections\ItemReplaceEventArgs.Test.cs">
|
||||||
|
<DependentUpon>ItemReplaceEventArgs.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\MultiDictionary.cs" />
|
<Compile Include="Source\Collections\MultiDictionary.cs" />
|
||||||
<Compile Include="Source\Collections\MultiDictionary.ValueCollection.cs">
|
<Compile Include="Source\Collections\MultiDictionary.ValueCollection.cs">
|
||||||
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
||||||
|
@ -172,6 +176,10 @@
|
||||||
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
||||||
<DependentUpon>ObservableList.cs</DependentUpon>
|
<DependentUpon>ObservableList.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ObservableSet.cs" />
|
||||||
|
<Compile Include="Source\Collections\ObservableSet.Test.cs">
|
||||||
|
<DependentUpon>ObservableSet.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\PairPriorityQueue.cs" />
|
<Compile Include="Source\Collections\PairPriorityQueue.cs" />
|
||||||
<Compile Include="Source\Collections\PairPriorityQueue.Test.cs">
|
<Compile Include="Source\Collections\PairPriorityQueue.Test.cs">
|
||||||
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
||||||
|
@ -208,6 +216,10 @@
|
||||||
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
||||||
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Source\Collections\ReadOnlySet.cs" />
|
||||||
|
<Compile Include="Source\Collections\ReadOnlySet.Test.cs">
|
||||||
|
<DependentUpon>ReadOnlySet.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Source\Collections\ReverseComparer.cs" />
|
<Compile Include="Source\Collections\ReverseComparer.cs" />
|
||||||
<Compile Include="Source\Collections\ReverseComparer.Test.cs">
|
<Compile Include="Source\Collections\ReverseComparer.Test.cs">
|
||||||
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
||||||
|
@ -225,34 +237,6 @@
|
||||||
<Compile Include="Source\Semaphore.Test.cs">
|
<Compile Include="Source\Semaphore.Test.cs">
|
||||||
<DependentUpon>Semaphore.cs</DependentUpon>
|
<DependentUpon>Semaphore.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Source\Services\AppDomainTypeLister.cs" />
|
|
||||||
<Compile Include="Source\Services\AppDomainTypeLister.Test.cs">
|
|
||||||
<DependentUpon>AppDomainTypeLister.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\MultiAssemblyTypeLister.cs" />
|
|
||||||
<Compile Include="Source\Services\ExplicitTypeLister.Test.cs">
|
|
||||||
<DependentUpon>ExplicitTypeLister.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\Instancing.cs" />
|
|
||||||
<Compile Include="Source\Services\ITypeLister.cs" />
|
|
||||||
<Compile Include="Source\Services\MultiAssemblyTypeLister.Test.cs">
|
|
||||||
<DependentUpon>MultiAssemblyTypeLister.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\ProgressTracking\IProgressPublishingService.cs" />
|
|
||||||
<Compile Include="Source\Services\ProgressTracking\IProgressCollectingService.cs" />
|
|
||||||
<Compile Include="Source\Services\ProgressTracking\ITrackedProcess.cs" />
|
|
||||||
<Compile Include="Source\Services\ProgressTracking\ProgressTrackingComponent.cs" />
|
|
||||||
<Compile Include="Source\Services\RepositoryTypeLister.cs" />
|
|
||||||
<Compile Include="Source\Services\RepositoryTypeLister.Test.cs">
|
|
||||||
<DependentUpon>RepositoryTypeLister.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\ServiceManager.Analyzer.cs">
|
|
||||||
<DependentUpon>ServiceManager.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\ServiceManager.cs" />
|
|
||||||
<Compile Include="Source\Services\ServiceManager.For.cs">
|
|
||||||
<DependentUpon>ServiceManager.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\IO\PartialStream.cs" />
|
<Compile Include="Source\IO\PartialStream.cs" />
|
||||||
<Compile Include="Source\IO\PartialStream.Test.cs">
|
<Compile Include="Source\IO\PartialStream.Test.cs">
|
||||||
<DependentUpon>PartialStream.cs</DependentUpon>
|
<DependentUpon>PartialStream.cs</DependentUpon>
|
||||||
|
@ -338,10 +322,6 @@
|
||||||
<Compile Include="Source\Plugins\PluginRepository.Test.cs">
|
<Compile Include="Source\Plugins\PluginRepository.Test.cs">
|
||||||
<DependentUpon>PluginRepository.cs</DependentUpon>
|
<DependentUpon>PluginRepository.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Source\Services\ServiceManager.Test.cs">
|
|
||||||
<DependentUpon>ServiceManager.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Source\Services\ExplicitTypeLister.cs" />
|
|
||||||
<Compile Include="Source\Shared.cs" />
|
<Compile Include="Source\Shared.cs" />
|
||||||
<Compile Include="Source\Shared.Test.cs">
|
<Compile Include="Source\Shared.Test.cs">
|
||||||
<DependentUpon>Shared.cs</DependentUpon>
|
<DependentUpon>Shared.cs</DependentUpon>
|
||||||
|
@ -374,16 +354,16 @@
|
||||||
<DependentUpon>XmlHelper.cs</DependentUpon>
|
<DependentUpon>XmlHelper.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Content Include="Documents\CommandLine.txt" />
|
|
||||||
<Content Include="Documents\Nuclex.Support.txt" />
|
|
||||||
<Content Include="Documents\Request Framework.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\Foundation.snk">
|
<None Include="..\Foundation.snk">
|
||||||
<Link>Foundation.snk</Link>
|
<Link>Foundation.snk</Link>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Documents\CommandLine.txt" />
|
||||||
|
<Content Include="Documents\Nuclex.Support.txt" />
|
||||||
|
<Content Include="Documents\Request Framework.txt" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||||
<!--
|
<!--
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
/// <summary>Unit Test for the CPU core-affine thread pool</summary>
|
/// <summary>Unit Test for the CPU core-affine thread pool</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class AffineThreadPoolTest {
|
internal class AffineThreadPoolTest {
|
||||||
|
|
||||||
#region class TestTask
|
#region class TestTask
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -574,6 +574,18 @@ namespace Nuclex.Support.Cloning {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Useless method that avoids a compile warnings due to unused fields
|
||||||
|
/// </summary>
|
||||||
|
protected void AvoidCompilerWarnings() {
|
||||||
|
var reference = new HierarchicalReferenceType() {
|
||||||
|
AlwaysNullField = new TestReferenceType()
|
||||||
|
};
|
||||||
|
var value = new HierarchicalValueType() {
|
||||||
|
AlwaysNullField = new TestReferenceType()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Nuclex.Support.Cloning
|
} // namespace Nuclex.Support.Cloning
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -67,6 +67,18 @@ namespace Nuclex.Support.Cloning {
|
||||||
Assert.AreEqual(4, fieldInfos.Length);
|
Assert.AreEqual(4, fieldInfos.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Useless test that avoids a compile warning about unused fields
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void AvoidCompilerWarnings() {
|
||||||
|
var derived = new Derived() {
|
||||||
|
PublicBaseField = 123,
|
||||||
|
PublicBaseProperty = 321,
|
||||||
|
PublicDerivedField = 456
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Nuclex.Support.Cloning
|
} // namespace Nuclex.Support.Cloning
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -24,15 +24,15 @@ using System.Collections;
|
||||||
|
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
partial class Deque<ItemType> {
|
partial class Deque<TItem> {
|
||||||
|
|
||||||
/// <summary>Inserts an item at the beginning of the double-ended queue</summary>
|
/// <summary>Inserts an item at the beginning of the double-ended queue</summary>
|
||||||
/// <param name="item">Item that will be inserted into the queue</param>
|
/// <param name="item">Item that will be inserted into the queue</param>
|
||||||
public void AddFirst(ItemType item) {
|
public void AddFirst(TItem item) {
|
||||||
if(this.firstBlockStartIndex > 0) {
|
if(this.firstBlockStartIndex > 0) {
|
||||||
--this.firstBlockStartIndex;
|
--this.firstBlockStartIndex;
|
||||||
} else { // Need to allocate a new block
|
} else { // Need to allocate a new block
|
||||||
this.blocks.Insert(0, new ItemType[this.blockSize]);
|
this.blocks.Insert(0, new TItem[this.blockSize]);
|
||||||
this.firstBlockStartIndex = this.blockSize - 1;
|
this.firstBlockStartIndex = this.blockSize - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Appends an item to the end of the double-ended queue</summary>
|
/// <summary>Appends an item to the end of the double-ended queue</summary>
|
||||||
/// <param name="item">Item that will be appended to the queue</param>
|
/// <param name="item">Item that will be appended to the queue</param>
|
||||||
public void AddLast(ItemType item) {
|
public void AddLast(TItem item) {
|
||||||
if(this.lastBlockEndIndex < this.blockSize) {
|
if(this.lastBlockEndIndex < this.blockSize) {
|
||||||
++this.lastBlockEndIndex;
|
++this.lastBlockEndIndex;
|
||||||
} else { // Need to allocate a new block
|
} else { // Need to allocate a new block
|
||||||
this.blocks.Add(new ItemType[this.blockSize]);
|
this.blocks.Add(new TItem[this.blockSize]);
|
||||||
this.lastBlockEndIndex = 1;
|
this.lastBlockEndIndex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Inserts the item at the specified index</summary>
|
/// <summary>Inserts the item at the specified index</summary>
|
||||||
/// <param name="index">Index the item will be inserted at</param>
|
/// <param name="index">Index the item will be inserted at</param>
|
||||||
/// <param name="item">Item that will be inserted</param>
|
/// <param name="item">Item that will be inserted</param>
|
||||||
public void Insert(int index, ItemType item) {
|
public void Insert(int index, TItem item) {
|
||||||
int distanceToRightEnd = this.count - index;
|
int distanceToRightEnd = this.count - index;
|
||||||
if(index < distanceToRightEnd) { // Are we closer to the left end?
|
if(index < distanceToRightEnd) { // Are we closer to the left end?
|
||||||
shiftLeftAndInsert(index, item);
|
shiftLeftAndInsert(index, item);
|
||||||
|
@ -81,7 +81,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index">Index the item will be inserted at</param>
|
/// <param name="index">Index the item will be inserted at</param>
|
||||||
/// <param name="item">Item that will be inserted</param>
|
/// <param name="item">Item that will be inserted</param>
|
||||||
private void shiftLeftAndInsert(int index, ItemType item) {
|
private void shiftLeftAndInsert(int index, TItem item) {
|
||||||
if(index == 0) {
|
if(index == 0) {
|
||||||
AddFirst(item);
|
AddFirst(item);
|
||||||
} else {
|
} else {
|
||||||
|
@ -93,7 +93,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
// If the first block is full, we need to add another block
|
// If the first block is full, we need to add another block
|
||||||
if(this.firstBlockStartIndex == 0) {
|
if(this.firstBlockStartIndex == 0) {
|
||||||
this.blocks.Insert(0, new ItemType[this.blockSize]);
|
this.blocks.Insert(0, new TItem[this.blockSize]);
|
||||||
this.blocks[0][this.blockSize - 1] = this.blocks[1][0];
|
this.blocks[0][this.blockSize - 1] = this.blocks[1][0];
|
||||||
this.firstBlockStartIndex = this.blockSize - 1;
|
this.firstBlockStartIndex = this.blockSize - 1;
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index">Index the item will be inserted at</param>
|
/// <param name="index">Index the item will be inserted at</param>
|
||||||
/// <param name="item">Item that will be inserted</param>
|
/// <param name="item">Item that will be inserted</param>
|
||||||
private void shiftRightAndInsert(int index, ItemType item) {
|
private void shiftRightAndInsert(int index, TItem item) {
|
||||||
if(index == this.count) {
|
if(index == this.count) {
|
||||||
AddLast(item);
|
AddLast(item);
|
||||||
} else {
|
} else {
|
||||||
|
@ -167,7 +167,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
// If the lastmost block is full, we need to add another block
|
// If the lastmost block is full, we need to add another block
|
||||||
if(this.lastBlockEndIndex == this.blockSize) {
|
if(this.lastBlockEndIndex == this.blockSize) {
|
||||||
this.blocks.Add(new ItemType[this.blockSize]);
|
this.blocks.Add(new TItem[this.blockSize]);
|
||||||
this.blocks[lastBlock + 1][0] = this.blocks[lastBlock][this.blockSize - 1];
|
this.blocks[lastBlock + 1][0] = this.blocks[lastBlock][this.blockSize - 1];
|
||||||
this.lastBlockEndIndex = 1;
|
this.lastBlockEndIndex = 1;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -24,7 +24,7 @@ using System.Collections;
|
||||||
|
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
partial class Deque<ItemType> {
|
partial class Deque<TItem> {
|
||||||
|
|
||||||
#region IEnumerable members
|
#region IEnumerable members
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ namespace Nuclex.Support.Collections {
|
||||||
int IList.Add(object value) {
|
int IList.Add(object value) {
|
||||||
verifyCompatibleObject(value);
|
verifyCompatibleObject(value);
|
||||||
|
|
||||||
AddLast((ItemType)value);
|
AddLast((TItem)value);
|
||||||
return this.count - 1;
|
return this.count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="value">Item the deque will be scanned for</param>
|
/// <param name="value">Item the deque will be scanned for</param>
|
||||||
/// <returns>True if the deque contained the specified item</returns>
|
/// <returns>True if the deque contained the specified item</returns>
|
||||||
bool IList.Contains(object value) {
|
bool IList.Contains(object value) {
|
||||||
return isCompatibleObject(value) && Contains((ItemType)value);
|
return isCompatibleObject(value) && Contains((TItem)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Determines the index of the item in the deque</summary>
|
/// <summary>Determines the index of the item in the deque</summary>
|
||||||
|
@ -60,7 +60,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <returns>The index of the specified item in the deque</returns>
|
/// <returns>The index of the specified item in the deque</returns>
|
||||||
int IList.IndexOf(object value) {
|
int IList.IndexOf(object value) {
|
||||||
if(isCompatibleObject(value)) {
|
if(isCompatibleObject(value)) {
|
||||||
return IndexOf((ItemType)value);
|
return IndexOf((TItem)value);
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="value">Item that will be inserted</param>
|
/// <param name="value">Item that will be inserted</param>
|
||||||
void IList.Insert(int index, object value) {
|
void IList.Insert(int index, object value) {
|
||||||
verifyCompatibleObject(value);
|
verifyCompatibleObject(value);
|
||||||
Insert(index, (ItemType)value);
|
Insert(index, (TItem)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Whether the deque has a fixed size</summary>
|
/// <summary>Whether the deque has a fixed size</summary>
|
||||||
|
@ -88,7 +88,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="value">Item that will be removed from the deque</param>
|
/// <param name="value">Item that will be removed from the deque</param>
|
||||||
void IList.Remove(object value) {
|
void IList.Remove(object value) {
|
||||||
if(isCompatibleObject(value)) {
|
if(isCompatibleObject(value)) {
|
||||||
Remove((ItemType)value);
|
Remove((TItem)value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ namespace Nuclex.Support.Collections {
|
||||||
get { return this[index]; }
|
get { return this[index]; }
|
||||||
set {
|
set {
|
||||||
verifyCompatibleObject(value);
|
verifyCompatibleObject(value);
|
||||||
this[index] = (ItemType)value;
|
this[index] = (TItem)value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,12 +109,12 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Adds an item into the deque</summary>
|
/// <summary>Adds an item into the deque</summary>
|
||||||
/// <param name="item">Item that will be added to the deque</param>
|
/// <param name="item">Item that will be added to the deque</param>
|
||||||
void ICollection<ItemType>.Add(ItemType item) {
|
void ICollection<TItem>.Add(TItem item) {
|
||||||
AddLast(item);
|
AddLast(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Whether the collection is read-only</summary>
|
/// <summary>Whether the collection is read-only</summary>
|
||||||
bool ICollection<ItemType>.IsReadOnly {
|
bool ICollection<TItem>.IsReadOnly {
|
||||||
get { return false; }
|
get { return false; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,11 +126,11 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="array">Array the contents of the deque will be copied into</param>
|
/// <param name="array">Array the contents of the deque will be copied into</param>
|
||||||
/// <param name="index">Index at which writing into the array will begin</param>
|
/// <param name="index">Index at which writing into the array will begin</param>
|
||||||
void ICollection.CopyTo(Array array, int index) {
|
void ICollection.CopyTo(Array array, int index) {
|
||||||
if(!(array is ItemType[])) {
|
if(!(array is TItem[])) {
|
||||||
throw new ArgumentException("Incompatible array type", "array");
|
throw new ArgumentException("Incompatible array type", "array");
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyTo((ItemType[])array, index);
|
CopyTo((TItem[])array, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Whether the deque is thread-synchronized</summary>
|
/// <summary>Whether the deque is thread-synchronized</summary>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -24,7 +24,7 @@ using System.Collections;
|
||||||
|
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
partial class Deque<ItemType> {
|
partial class Deque<TItem> {
|
||||||
|
|
||||||
/// <summary>Removes all items from the deque</summary>
|
/// <summary>Removes all items from the deque</summary>
|
||||||
public void Clear() {
|
public void Clear() {
|
||||||
|
@ -33,7 +33,7 @@ namespace Nuclex.Support.Collections {
|
||||||
// Clear the items in the first block to avoid holding on to references
|
// Clear the items in the first block to avoid holding on to references
|
||||||
// in memory unreachable to the user
|
// in memory unreachable to the user
|
||||||
for(int index = this.firstBlockStartIndex; index < this.blockSize; ++index) {
|
for(int index = this.firstBlockStartIndex; index < this.blockSize; ++index) {
|
||||||
this.blocks[0][index] = default(ItemType);
|
this.blocks[0][index] = default(TItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any other blocks
|
// Remove any other blocks
|
||||||
|
@ -45,7 +45,7 @@ namespace Nuclex.Support.Collections {
|
||||||
for(
|
for(
|
||||||
int index = this.firstBlockStartIndex; index < this.lastBlockEndIndex; ++index
|
int index = this.firstBlockStartIndex; index < this.lastBlockEndIndex; ++index
|
||||||
) {
|
) {
|
||||||
this.blocks[0][index] = default(ItemType);
|
this.blocks[0][index] = default(TItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Removes the specified item from the deque</summary>
|
/// <summary>Removes the specified item from the deque</summary>
|
||||||
/// <param name="item">Item that will be removed from the deque</param>
|
/// <param name="item">Item that will be removed from the deque</param>
|
||||||
/// <returns>True if the item was found and removed</returns>
|
/// <returns>True if the item was found and removed</returns>
|
||||||
public bool Remove(ItemType item) {
|
public bool Remove(TItem item) {
|
||||||
int index = IndexOf(item);
|
int index = IndexOf(item);
|
||||||
if(index == -1) {
|
if(index == -1) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -83,7 +83,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
// This is necessary to make sure the deque doesn't hold dead objects alive
|
// This is necessary to make sure the deque doesn't hold dead objects alive
|
||||||
// in unreachable spaces of its memory.
|
// in unreachable spaces of its memory.
|
||||||
this.blocks[0][this.firstBlockStartIndex] = default(ItemType);
|
this.blocks[0][this.firstBlockStartIndex] = default(TItem);
|
||||||
|
|
||||||
// Cut off the item from the first block. If the block became empty and it's
|
// Cut off the item from the first block. If the block became empty and it's
|
||||||
// not the last remaining block, remove it as well.
|
// not the last remaining block, remove it as well.
|
||||||
|
@ -112,7 +112,7 @@ namespace Nuclex.Support.Collections {
|
||||||
// This is necessary to make sure the deque doesn't hold dead objects alive
|
// This is necessary to make sure the deque doesn't hold dead objects alive
|
||||||
// in unreachable spaces of its memory.
|
// in unreachable spaces of its memory.
|
||||||
int lastBlock = this.blocks.Count - 1;
|
int lastBlock = this.blocks.Count - 1;
|
||||||
this.blocks[lastBlock][this.lastBlockEndIndex - 1] = default(ItemType);
|
this.blocks[lastBlock][this.lastBlockEndIndex - 1] = default(TItem);
|
||||||
|
|
||||||
// Cut off the last item in the last block. If the block became empty and it's
|
// Cut off the last item in the last block. If the block became empty and it's
|
||||||
// not the last remaining block, remove it as well.
|
// not the last remaining block, remove it as well.
|
||||||
|
@ -193,7 +193,7 @@ namespace Nuclex.Support.Collections {
|
||||||
this.blocks.RemoveAt(0);
|
this.blocks.RemoveAt(0);
|
||||||
this.firstBlockStartIndex = 0;
|
this.firstBlockStartIndex = 0;
|
||||||
} else {
|
} else {
|
||||||
this.blocks[0][this.firstBlockStartIndex] = default(ItemType);
|
this.blocks[0][this.firstBlockStartIndex] = default(TItem);
|
||||||
++this.firstBlockStartIndex;
|
++this.firstBlockStartIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ namespace Nuclex.Support.Collections {
|
||||||
this.blocks.RemoveAt(lastBlock);
|
this.blocks.RemoveAt(lastBlock);
|
||||||
this.lastBlockEndIndex = this.blockSize;
|
this.lastBlockEndIndex = this.blockSize;
|
||||||
} else {
|
} else {
|
||||||
this.blocks[lastBlock][this.lastBlockEndIndex - 1] = default(ItemType);
|
this.blocks[lastBlock][this.lastBlockEndIndex - 1] = default(TItem);
|
||||||
--this.lastBlockEndIndex;
|
--this.lastBlockEndIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -24,17 +24,17 @@ using System.Collections;
|
||||||
|
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
partial class Deque<ItemType> {
|
partial class Deque<TItem> {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines the index of the first occurence of the specified item in the deque
|
/// Determines the index of the first occurence of the specified item in the deque
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">Item that will be located in the deque</param>
|
/// <param name="item">Item that will be located in the deque</param>
|
||||||
/// <returns>The index of the item or -1 if it wasn't found</returns>
|
/// <returns>The index of the item or -1 if it wasn't found</returns>
|
||||||
public int IndexOf(ItemType item) {
|
public int IndexOf(TItem item) {
|
||||||
if(this.blocks.Count == 1) { // Only one block to scan?
|
if(this.blocks.Count == 1) { // Only one block to scan?
|
||||||
int length = this.lastBlockEndIndex - this.firstBlockStartIndex;
|
int length = this.lastBlockEndIndex - this.firstBlockStartIndex;
|
||||||
int index = Array.IndexOf<ItemType>(
|
int index = Array.IndexOf<TItem>(
|
||||||
this.blocks[0], item, this.firstBlockStartIndex, length
|
this.blocks[0], item, this.firstBlockStartIndex, length
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
// Scan the first block for the item and if found, return the index
|
// Scan the first block for the item and if found, return the index
|
||||||
int length = this.blockSize - this.firstBlockStartIndex;
|
int length = this.blockSize - this.firstBlockStartIndex;
|
||||||
int index = Array.IndexOf<ItemType>(
|
int index = Array.IndexOf<TItem>(
|
||||||
this.blocks[0], item, this.firstBlockStartIndex, length
|
this.blocks[0], item, this.firstBlockStartIndex, length
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
int lastBlock = this.blocks.Count - 1;
|
int lastBlock = this.blocks.Count - 1;
|
||||||
for(int tempIndex = 1; tempIndex < lastBlock; ++tempIndex) {
|
for(int tempIndex = 1; tempIndex < lastBlock; ++tempIndex) {
|
||||||
index = Array.IndexOf<ItemType>(
|
index = Array.IndexOf<TItem>(
|
||||||
this.blocks[tempIndex], item, 0, this.blockSize
|
this.blocks[tempIndex], item, 0, this.blockSize
|
||||||
);
|
);
|
||||||
if(index != -1) {
|
if(index != -1) {
|
||||||
|
@ -69,7 +69,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nothing found, continue the search in the
|
// Nothing found, continue the search in the
|
||||||
index = Array.IndexOf<ItemType>(
|
index = Array.IndexOf<TItem>(
|
||||||
this.blocks[lastBlock], item, 0, this.lastBlockEndIndex
|
this.blocks[lastBlock], item, 0, this.lastBlockEndIndex
|
||||||
);
|
);
|
||||||
if(index == -1) {
|
if(index == -1) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the double ended queue</summary>
|
/// <summary>Unit Test for the double ended queue</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class DequeTest {
|
internal class DequeTest {
|
||||||
|
|
||||||
/// <summary>Verifies that the AddLast() method of the deque is working</summary>
|
/// <summary>Verifies that the AddLast() method of the deque is working</summary>
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -25,7 +25,7 @@ using System.Collections;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>A double-ended queue that allocates memory in blocks</summary>
|
/// <summary>A double-ended queue that allocates memory in blocks</summary>
|
||||||
/// <typeparam name="ItemType">Type of the items being stored in the queue</typeparam>
|
/// <typeparam name="TItem">Type of the items being stored in the queue</typeparam>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// The double-ended queue allows items to be appended to either side of the queue
|
/// The double-ended queue allows items to be appended to either side of the queue
|
||||||
|
@ -38,16 +38,16 @@ namespace Nuclex.Support.Collections {
|
||||||
/// require items to be copied around and it still can be accessed by index.
|
/// require items to be copied around and it still can be accessed by index.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public partial class Deque<ItemType> : IList<ItemType>, IList {
|
public partial class Deque<TItem> : IList<TItem>, IList {
|
||||||
|
|
||||||
#region class Enumerator
|
#region class Enumerator
|
||||||
|
|
||||||
/// <summary>Enumerates over the items in a deque</summary>
|
/// <summary>Enumerates over the items in a deque</summary>
|
||||||
private class Enumerator : IEnumerator<ItemType>, IEnumerator {
|
private class Enumerator : IEnumerator<TItem>, IEnumerator {
|
||||||
|
|
||||||
/// <summary>Initializes a new deque enumerator</summary>
|
/// <summary>Initializes a new deque enumerator</summary>
|
||||||
/// <param name="deque">Deque whose items will be enumerated</param>
|
/// <param name="deque">Deque whose items will be enumerated</param>
|
||||||
public Enumerator(Deque<ItemType> deque) {
|
public Enumerator(Deque<TItem> deque) {
|
||||||
this.deque = deque;
|
this.deque = deque;
|
||||||
this.blockSize = this.deque.blockSize;
|
this.blockSize = this.deque.blockSize;
|
||||||
this.lastBlock = this.deque.blocks.Count - 1;
|
this.lastBlock = this.deque.blocks.Count - 1;
|
||||||
|
@ -63,7 +63,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The item at the enumerator's current position</summary>
|
/// <summary>The item at the enumerator's current position</summary>
|
||||||
public ItemType Current {
|
public TItem Current {
|
||||||
get {
|
get {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
checkVersion();
|
checkVersion();
|
||||||
|
@ -143,7 +143,7 @@ namespace Nuclex.Support.Collections {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>Deque the enumerator belongs to</summary>
|
/// <summary>Deque the enumerator belongs to</summary>
|
||||||
private Deque<ItemType> deque;
|
private Deque<TItem> deque;
|
||||||
/// <summary>Size of the blocks in the deque</summary>
|
/// <summary>Size of the blocks in the deque</summary>
|
||||||
private int blockSize;
|
private int blockSize;
|
||||||
/// <summary>Index of the last block in the deque</summary>
|
/// <summary>Index of the last block in the deque</summary>
|
||||||
|
@ -154,7 +154,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Index of the block the enumerator currently is in</summary>
|
/// <summary>Index of the block the enumerator currently is in</summary>
|
||||||
private int currentBlockIndex;
|
private int currentBlockIndex;
|
||||||
/// <summary>Reference to the block being enumerated</summary>
|
/// <summary>Reference to the block being enumerated</summary>
|
||||||
private ItemType[] currentBlock;
|
private TItem[] currentBlock;
|
||||||
/// <summary>Index in the current block</summary>
|
/// <summary>Index in the current block</summary>
|
||||||
private int subIndex;
|
private int subIndex;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -173,8 +173,8 @@ namespace Nuclex.Support.Collections {
|
||||||
public Deque(int blockSize) {
|
public Deque(int blockSize) {
|
||||||
this.blockSize = blockSize;
|
this.blockSize = blockSize;
|
||||||
|
|
||||||
this.blocks = new List<ItemType[]>();
|
this.blocks = new List<TItem[]>();
|
||||||
this.blocks.Add(new ItemType[this.blockSize]);
|
this.blocks.Add(new TItem[this.blockSize]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Number of items contained in the double ended queue</summary>
|
/// <summary>Number of items contained in the double ended queue</summary>
|
||||||
|
@ -185,7 +185,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Accesses an item by its index</summary>
|
/// <summary>Accesses an item by its index</summary>
|
||||||
/// <param name="index">Index of the item that will be accessed</param>
|
/// <param name="index">Index of the item that will be accessed</param>
|
||||||
/// <returns>The item at the specified index</returns>
|
/// <returns>The item at the specified index</returns>
|
||||||
public ItemType this[int index] {
|
public TItem this[int index] {
|
||||||
get {
|
get {
|
||||||
int blockIndex, subIndex;
|
int blockIndex, subIndex;
|
||||||
findIndex(index, out blockIndex, out subIndex);
|
findIndex(index, out blockIndex, out subIndex);
|
||||||
|
@ -201,7 +201,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The first item in the double-ended queue</summary>
|
/// <summary>The first item in the double-ended queue</summary>
|
||||||
public ItemType First {
|
public TItem First {
|
||||||
get {
|
get {
|
||||||
if (this.count == 0) {
|
if (this.count == 0) {
|
||||||
throw new InvalidOperationException("The deque is empty");
|
throw new InvalidOperationException("The deque is empty");
|
||||||
|
@ -211,7 +211,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The last item in the double-ended queue</summary>
|
/// <summary>The last item in the double-ended queue</summary>
|
||||||
public ItemType Last {
|
public TItem Last {
|
||||||
get {
|
get {
|
||||||
if (this.count == 0) {
|
if (this.count == 0) {
|
||||||
throw new InvalidOperationException("The deque is empty");
|
throw new InvalidOperationException("The deque is empty");
|
||||||
|
@ -223,14 +223,14 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Determines whether the deque contains the specified item</summary>
|
/// <summary>Determines whether the deque contains the specified item</summary>
|
||||||
/// <param name="item">Item the deque will be scanned for</param>
|
/// <param name="item">Item the deque will be scanned for</param>
|
||||||
/// <returns>True if the deque contains the item, false otherwise</returns>
|
/// <returns>True if the deque contains the item, false otherwise</returns>
|
||||||
public bool Contains(ItemType item) {
|
public bool Contains(TItem item) {
|
||||||
return (IndexOf(item) != -1);
|
return (IndexOf(item) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Copies the contents of the deque into an array</summary>
|
/// <summary>Copies the contents of the deque into an array</summary>
|
||||||
/// <param name="array">Array the contents of the deque will be copied into</param>
|
/// <param name="array">Array the contents of the deque will be copied into</param>
|
||||||
/// <param name="arrayIndex">Array index the deque contents will begin at</param>
|
/// <param name="arrayIndex">Array index the deque contents will begin at</param>
|
||||||
public void CopyTo(ItemType[] array, int arrayIndex) {
|
public void CopyTo(TItem[] array, int arrayIndex) {
|
||||||
if (this.count > (array.Length - arrayIndex)) {
|
if (this.count > (array.Length - arrayIndex)) {
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
"Array too small to hold the collection items starting at the specified index"
|
"Array too small to hold the collection items starting at the specified index"
|
||||||
|
@ -280,7 +280,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Obtains a new enumerator for the contents of the deque</summary>
|
/// <summary>Obtains a new enumerator for the contents of the deque</summary>
|
||||||
/// <returns>The new enumerator</returns>
|
/// <returns>The new enumerator</returns>
|
||||||
public IEnumerator<ItemType> GetEnumerator() {
|
public IEnumerator<TItem> GetEnumerator() {
|
||||||
return new Enumerator(this);
|
return new Enumerator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="value">Value that will be checked for compatibility</param>
|
/// <param name="value">Value that will be checked for compatibility</param>
|
||||||
/// <returns>True if the value can be placed in the deque</returns>
|
/// <returns>True if the value can be placed in the deque</returns>
|
||||||
private static bool isCompatibleObject(object value) {
|
private static bool isCompatibleObject(object value) {
|
||||||
return ((value is ItemType) || ((value == null) && !typeof(ItemType).IsValueType));
|
return ((value is TItem) || ((value == null) && !typeof(TItem).IsValueType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Verifies that the provided object matches the deque's type</summary>
|
/// <summary>Verifies that the provided object matches the deque's type</summary>
|
||||||
|
@ -324,7 +324,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Size of a single deque block</summary>
|
/// <summary>Size of a single deque block</summary>
|
||||||
private int blockSize;
|
private int blockSize;
|
||||||
/// <summary>Memory blocks being used to store the deque's data</summary>
|
/// <summary>Memory blocks being used to store the deque's data</summary>
|
||||||
private List<ItemType[]> blocks;
|
private List<TItem[]> blocks;
|
||||||
/// <summary>Starting index of data in the first block</summary>
|
/// <summary>Starting index of data in the first block</summary>
|
||||||
private int firstBlockStartIndex;
|
private int firstBlockStartIndex;
|
||||||
/// <summary>End index of data in the last block</summary>
|
/// <summary>End index of data in the last block</summary>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -25,14 +25,19 @@ using System.Collections.ObjectModel;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Interface for collections that can be observed</summary>
|
/// <summary>Interface for collections that can be observed</summary>
|
||||||
/// <typeparam name="ItemType">Type of items managed in the collection</typeparam>
|
/// <typeparam name="TItem">Type of items managed in the collection</typeparam>
|
||||||
public interface IObservableCollection<ItemType> {
|
public interface IObservableCollection<TItem> {
|
||||||
|
|
||||||
/// <summary>Raised when an item has been added to the collection</summary>
|
/// <summary>Raised when an item has been added to the collection</summary>
|
||||||
event EventHandler<ItemEventArgs<ItemType>> ItemAdded;
|
event EventHandler<ItemEventArgs<TItem>> ItemAdded;
|
||||||
|
|
||||||
/// <summary>Raised when an item is removed from the collection</summary>
|
/// <summary>Raised when an item is removed from the collection</summary>
|
||||||
event EventHandler<ItemEventArgs<ItemType>> ItemRemoved;
|
event EventHandler<ItemEventArgs<TItem>> ItemRemoved;
|
||||||
|
|
||||||
|
#if false
|
||||||
|
/// <summary>Raised when an item is replaced in the collection</summary>
|
||||||
|
event EventHandler<ItemReplaceEventArgs<ItemType>> ItemReplaced;
|
||||||
|
#endif
|
||||||
|
|
||||||
/// <summary>Raised when the collection is about to be cleared</summary>
|
/// <summary>Raised when the collection is about to be cleared</summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,14 +29,14 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the item event argument container</summary>
|
/// <summary>Unit Test for the item event argument container</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ItemEventArgsTest {
|
internal class ItemEventArgsTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests whether an integer argument can be stored in the argument container
|
/// Tests whether an integer argument can be stored in the argument container
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestIntegerArgument() {
|
public void IntegersCanBeCarried() {
|
||||||
ItemEventArgs<int> test = new ItemEventArgs<int>(12345);
|
var test = new ItemEventArgs<int>(12345);
|
||||||
Assert.AreEqual(12345, test.Item);
|
Assert.AreEqual(12345, test.Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Tests whether a string argument can be stored in the argument container
|
/// Tests whether a string argument can be stored in the argument container
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestStringArgument() {
|
public void StringsCanBeCarried() {
|
||||||
ItemEventArgs<string> test = new ItemEventArgs<string>("hello world");
|
var test = new ItemEventArgs<string>("hello world");
|
||||||
Assert.AreEqual("hello world", test.Item);
|
Assert.AreEqual("hello world", test.Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -24,23 +24,23 @@ using System.Collections.Generic;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Arguments class for collections wanting to hand over an item in an event
|
/// Argument container used by collections to notify about changed items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ItemEventArgs<ItemType> : EventArgs {
|
public class ItemEventArgs<TItem> : EventArgs {
|
||||||
|
|
||||||
/// <summary>Initializes a new event arguments supplier</summary>
|
/// <summary>Initializes a new event arguments supplier</summary>
|
||||||
/// <param name="item">Item to be supplied to the event handler</param>
|
/// <param name="item">Item to be supplied to the event handler</param>
|
||||||
public ItemEventArgs(ItemType item) {
|
public ItemEventArgs(TItem item) {
|
||||||
this.item = item;
|
this.item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Obtains the collection item the event arguments are carrying</summary>
|
/// <summary>Obtains the collection item the event arguments are carrying</summary>
|
||||||
public ItemType Item {
|
public TItem Item {
|
||||||
get { return this.item; }
|
get { return this.item; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Item to be passed to the event handler</summary>
|
/// <summary>Item to be passed to the event handler</summary>
|
||||||
private ItemType item;
|
private TItem item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
58
Source/Collections/ItemReplaceEventArgs.Test.cs
Normal file
58
Source/Collections/ItemReplaceEventArgs.Test.cs
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#region CPL License
|
||||||
|
/*
|
||||||
|
Nuclex Framework
|
||||||
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
published by the IBM Corporation; either version 1.0 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
IBM Common Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the IBM Common Public
|
||||||
|
License along with this library
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#if UNITTEST
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
|
/// <summary>Unit Test for the item event argument container</summary>
|
||||||
|
[TestFixture]
|
||||||
|
public class ItemReplaceEventArgsTest {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests whether an integer argument can be stored in the argument container
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void IntegersCanBeCarried() {
|
||||||
|
var test = new ItemReplaceEventArgs<int>(12345, 54321);
|
||||||
|
Assert.AreEqual(12345, test.OldItem);
|
||||||
|
Assert.AreEqual(54321, test.NewItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests whether a string argument can be stored in the argument container
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void StringsCanBeCarried() {
|
||||||
|
var test = new ItemReplaceEventArgs<string>("hello", "world");
|
||||||
|
Assert.AreEqual("hello", test.OldItem);
|
||||||
|
Assert.AreEqual("world", test.NewItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Nuclex.Support.Collections
|
||||||
|
|
||||||
|
#endif // UNITTEST
|
56
Source/Collections/ItemReplaceEventArgs.cs
Normal file
56
Source/Collections/ItemReplaceEventArgs.cs
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
#region CPL License
|
||||||
|
/*
|
||||||
|
Nuclex Framework
|
||||||
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
published by the IBM Corporation; either version 1.0 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
IBM Common Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the IBM Common Public
|
||||||
|
License along with this library
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Argument container used by collections to notify about replaced items
|
||||||
|
/// </summary>
|
||||||
|
public class ItemReplaceEventArgs<TItem> : EventArgs {
|
||||||
|
|
||||||
|
/// <summary>Initializes a new event arguments supplier</summary>
|
||||||
|
/// <param name="oldItem">Item that has been replaced by another item</param>
|
||||||
|
/// <param name="newItem">Replacement item that is now part of the collection</param>
|
||||||
|
public ItemReplaceEventArgs(TItem oldItem, TItem newItem) {
|
||||||
|
this.oldItem = oldItem;
|
||||||
|
this.newItem = newItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Item that has been replaced by another item</summary>
|
||||||
|
public TItem OldItem {
|
||||||
|
get { return this.oldItem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Replacement item that is now part of the collection</summary>
|
||||||
|
public TItem NewItem {
|
||||||
|
get { return this.newItem; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Item that was removed from the collection</summary>
|
||||||
|
private TItem oldItem;
|
||||||
|
/// <summary>Item that was added to the collection</summary>
|
||||||
|
private TItem newItem;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Nuclex.Support.Collections
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit tests for the multi dictionary</summary>
|
/// <summary>Unit tests for the multi dictionary</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class MultiDictionaryTest {
|
internal class MultiDictionaryTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verifies that new instances of the multi dictionary can be created
|
/// Verifies that new instances of the multi dictionary can be created
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the observable collection class</summary>
|
/// <summary>Unit Test for the observable collection class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ObservableCollectionTest {
|
internal class ObservableCollectionTest {
|
||||||
|
|
||||||
#region interface IObservableCollectionSubscriber
|
#region interface IObservableCollectionSubscriber
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -33,7 +33,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the observable dictionary wrapper</summary>
|
/// <summary>Unit Test for the observable dictionary wrapper</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ObservableDictionaryTest {
|
internal class ObservableDictionaryTest {
|
||||||
|
|
||||||
#region interface IObservableDictionarySubscriber
|
#region interface IObservableDictionarySubscriber
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the observable list class</summary>
|
/// <summary>Unit Test for the observable list class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ObservableListTest {
|
internal class ObservableListTest {
|
||||||
|
|
||||||
#region interface IObservableCollectionSubscriber
|
#region interface IObservableCollectionSubscriber
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
43
Source/Collections/ObservableSet.Test.cs
Normal file
43
Source/Collections/ObservableSet.Test.cs
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#region CPL License
|
||||||
|
/*
|
||||||
|
Nuclex Framework
|
||||||
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
published by the IBM Corporation; either version 1.0 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
IBM Common Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the IBM Common Public
|
||||||
|
License along with this library
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#if UNITTEST
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NMock;
|
||||||
|
|
||||||
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
|
#if false
|
||||||
|
/// <summary>Unit Test for the observable set wrapper</summary>
|
||||||
|
[TestFixture]
|
||||||
|
internal class ObservableSetTest {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace Nuclex.Support.Collections
|
||||||
|
|
||||||
|
#endif // UNITTEST
|
33
Source/Collections/ObservableSet.cs
Normal file
33
Source/Collections/ObservableSet.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#region CPL License
|
||||||
|
/*
|
||||||
|
Nuclex Framework
|
||||||
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
published by the IBM Corporation; either version 1.0 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
IBM Common Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the IBM Common Public
|
||||||
|
License along with this library
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
|
#if false
|
||||||
|
public class ObservableSet<TItem> {
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace Nuclex.Support.Collections
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the priority queue class</summary>
|
/// <summary>Unit Test for the priority queue class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PairPriorityQueueTest {
|
internal class PairPriorityQueueTest {
|
||||||
|
|
||||||
/// <summary>Tests to ensure the count property is properly updated</summary>
|
/// <summary>Tests to ensure the count property is properly updated</summary>
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,17 +30,17 @@ namespace Nuclex.Support.Collections {
|
||||||
/// priority data type implements the IComparable interface, the user does not
|
/// priority data type implements the IComparable interface, the user does not
|
||||||
/// even
|
/// even
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class PairPriorityQueue<PriorityType, ItemType>
|
public class PairPriorityQueue<TPriority, TItem>
|
||||||
: ICollection, IEnumerable<PriorityItemPair<PriorityType, ItemType>> {
|
: ICollection, IEnumerable<PriorityItemPair<TPriority, TItem>> {
|
||||||
|
|
||||||
#region class PairComparer
|
#region class PairComparer
|
||||||
|
|
||||||
/// <summary>Compares two priority queue entries based on their priority</summary>
|
/// <summary>Compares two priority queue entries based on their priority</summary>
|
||||||
private class PairComparer : IComparer<PriorityItemPair<PriorityType, ItemType>> {
|
private class PairComparer : IComparer<PriorityItemPair<TPriority, TItem>> {
|
||||||
|
|
||||||
/// <summary>Initializes a new entry comparer</summary>
|
/// <summary>Initializes a new entry comparer</summary>
|
||||||
/// <param name="priorityComparer">Comparer used to compare entry priorities</param>
|
/// <param name="priorityComparer">Comparer used to compare entry priorities</param>
|
||||||
public PairComparer(IComparer<PriorityType> priorityComparer) {
|
public PairComparer(IComparer<TPriority> priorityComparer) {
|
||||||
this.priorityComparer = priorityComparer;
|
this.priorityComparer = priorityComparer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,48 +49,48 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="right">Entry on the right side</param>
|
/// <param name="right">Entry on the right side</param>
|
||||||
/// <returns>The relationship of the two entries</returns>
|
/// <returns>The relationship of the two entries</returns>
|
||||||
public int Compare(
|
public int Compare(
|
||||||
PriorityItemPair<PriorityType, ItemType> left,
|
PriorityItemPair<TPriority, TItem> left,
|
||||||
PriorityItemPair<PriorityType, ItemType> right
|
PriorityItemPair<TPriority, TItem> right
|
||||||
) {
|
) {
|
||||||
return this.priorityComparer.Compare(left.Priority, right.Priority);
|
return this.priorityComparer.Compare(left.Priority, right.Priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Comparer used to compare the priorities of the entries</summary>
|
/// <summary>Comparer used to compare the priorities of the entries</summary>
|
||||||
private IComparer<PriorityType> priorityComparer;
|
private IComparer<TPriority> priorityComparer;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion // class EntryComparer
|
#endregion // class EntryComparer
|
||||||
|
|
||||||
/// <summary>Initializes a new non-intrusive priority queue</summary>
|
/// <summary>Initializes a new non-intrusive priority queue</summary>
|
||||||
public PairPriorityQueue() : this(Comparer<PriorityType>.Default) { }
|
public PairPriorityQueue() : this(Comparer<TPriority>.Default) { }
|
||||||
|
|
||||||
/// <summary>Initializes a new non-intrusive priority queue</summary>
|
/// <summary>Initializes a new non-intrusive priority queue</summary>
|
||||||
/// <param name="priorityComparer">Comparer used to compare the item priorities</param>
|
/// <param name="priorityComparer">Comparer used to compare the item priorities</param>
|
||||||
public PairPriorityQueue(IComparer<PriorityType> priorityComparer) {
|
public PairPriorityQueue(IComparer<TPriority> priorityComparer) {
|
||||||
this.internalQueue = new PriorityQueue<PriorityItemPair<PriorityType, ItemType>>(
|
this.internalQueue = new PriorityQueue<PriorityItemPair<TPriority, TItem>>(
|
||||||
new PairComparer(priorityComparer)
|
new PairComparer(priorityComparer)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Returns the topmost item in the queue without dequeueing it</summary>
|
/// <summary>Returns the topmost item in the queue without dequeueing it</summary>
|
||||||
/// <returns>The topmost item in the queue</returns>
|
/// <returns>The topmost item in the queue</returns>
|
||||||
public PriorityItemPair<PriorityType, ItemType> Peek() {
|
public PriorityItemPair<TPriority, TItem> Peek() {
|
||||||
return this.internalQueue.Peek();
|
return this.internalQueue.Peek();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Takes the item with the highest priority off from the queue</summary>
|
/// <summary>Takes the item with the highest priority off from the queue</summary>
|
||||||
/// <returns>The item with the highest priority in the list</returns>
|
/// <returns>The item with the highest priority in the list</returns>
|
||||||
public PriorityItemPair<PriorityType, ItemType> Dequeue() {
|
public PriorityItemPair<TPriority, TItem> Dequeue() {
|
||||||
return this.internalQueue.Dequeue();
|
return this.internalQueue.Dequeue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Puts an item into the priority queue</summary>
|
/// <summary>Puts an item into the priority queue</summary>
|
||||||
/// <param name="priority">Priority of the item to be queued</param>
|
/// <param name="priority">Priority of the item to be queued</param>
|
||||||
/// <param name="item">Item to be queued</param>
|
/// <param name="item">Item to be queued</param>
|
||||||
public void Enqueue(PriorityType priority, ItemType item) {
|
public void Enqueue(TPriority priority, TItem item) {
|
||||||
this.internalQueue.Enqueue(
|
this.internalQueue.Enqueue(
|
||||||
new PriorityItemPair<PriorityType, ItemType>(priority, item)
|
new PriorityItemPair<TPriority, TItem>(priority, item)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Returns a typesafe enumerator for the priority queue</summary>
|
/// <summary>Returns a typesafe enumerator for the priority queue</summary>
|
||||||
/// <returns>A new enumerator for the priority queue</returns>
|
/// <returns>A new enumerator for the priority queue</returns>
|
||||||
public IEnumerator<PriorityItemPair<PriorityType, ItemType>> GetEnumerator() {
|
public IEnumerator<PriorityItemPair<TPriority, TItem>> GetEnumerator() {
|
||||||
return this.internalQueue.GetEnumerator();
|
return this.internalQueue.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Intrusive priority queue being wrapped by this class</summary>
|
/// <summary>Intrusive priority queue being wrapped by this class</summary>
|
||||||
private PriorityQueue<PriorityItemPair<PriorityType, ItemType>> internalQueue;
|
private PriorityQueue<PriorityItemPair<TPriority, TItem>> internalQueue;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the Parentable class</summary>
|
/// <summary>Unit Test for the Parentable class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ParentableTest {
|
internal class ParentableTest {
|
||||||
|
|
||||||
#region class TestParentable
|
#region class TestParentable
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the Parenting Collection class</summary>
|
/// <summary>Unit Test for the Parenting Collection class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ParentingCollectionTest {
|
internal class ParentingCollectionTest {
|
||||||
|
|
||||||
#region class TestParentable
|
#region class TestParentable
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -32,14 +32,14 @@ namespace Nuclex.Support.Collections {
|
||||||
/// are managed in it. The elements have to derive from the Parentable<>
|
/// are managed in it. The elements have to derive from the Parentable<>
|
||||||
/// base class.
|
/// base class.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <typeparam name="ParentType">Type of the parent object to assign to items</typeparam>
|
/// <typeparam name="TParent">Type of the parent object to assign to items</typeparam>
|
||||||
/// <typeparam name="ItemType">Type of the items being managed in the collection</typeparam>
|
/// <typeparam name="TItem">Type of the items being managed in the collection</typeparam>
|
||||||
public class ParentingCollection<ParentType, ItemType> : Collection<ItemType>
|
public class ParentingCollection<TParent, TItem> : Collection<TItem>
|
||||||
where ItemType : Parentable<ParentType> {
|
where TItem : Parentable<TParent> {
|
||||||
|
|
||||||
/// <summary>Reparents all elements in the collection</summary>
|
/// <summary>Reparents all elements in the collection</summary>
|
||||||
/// <param name="parent">New parent to take ownership of the items</param>
|
/// <param name="parent">New parent to take ownership of the items</param>
|
||||||
protected void Reparent(ParentType parent) {
|
protected void Reparent(TParent parent) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
|
||||||
for(int index = 0; index < Count; ++index)
|
for(int index = 0; index < Count; ++index)
|
||||||
|
@ -49,7 +49,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Clears all elements from the collection</summary>
|
/// <summary>Clears all elements from the collection</summary>
|
||||||
protected override void ClearItems() {
|
protected override void ClearItems() {
|
||||||
for(int index = 0; index < Count; ++index)
|
for(int index = 0; index < Count; ++index)
|
||||||
base[index].SetParent(default(ParentType));
|
base[index].SetParent(default(TParent));
|
||||||
|
|
||||||
base.ClearItems();
|
base.ClearItems();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Inserts a new element into the collection</summary>
|
/// <summary>Inserts a new element into the collection</summary>
|
||||||
/// <param name="index">Index at which to insert the element</param>
|
/// <param name="index">Index at which to insert the element</param>
|
||||||
/// <param name="item">Item to be inserted</param>
|
/// <param name="item">Item to be inserted</param>
|
||||||
protected override void InsertItem(int index, ItemType item) {
|
protected override void InsertItem(int index, TItem item) {
|
||||||
base.InsertItem(index, item);
|
base.InsertItem(index, item);
|
||||||
item.SetParent(this.parent);
|
item.SetParent(this.parent);
|
||||||
}
|
}
|
||||||
|
@ -65,15 +65,15 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Removes an element from the collection</summary>
|
/// <summary>Removes an element from the collection</summary>
|
||||||
/// <param name="index">Index of the element to remove</param>
|
/// <param name="index">Index of the element to remove</param>
|
||||||
protected override void RemoveItem(int index) {
|
protected override void RemoveItem(int index) {
|
||||||
base[index].SetParent(default(ParentType));
|
base[index].SetParent(default(TParent));
|
||||||
base.RemoveItem(index);
|
base.RemoveItem(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Takes over a new element that is directly assigned</summary>
|
/// <summary>Takes over a new element that is directly assigned</summary>
|
||||||
/// <param name="index">Index of the element that was assigned</param>
|
/// <param name="index">Index of the element that was assigned</param>
|
||||||
/// <param name="item">New item</param>
|
/// <param name="item">New item</param>
|
||||||
protected override void SetItem(int index, ItemType item) {
|
protected override void SetItem(int index, TItem item) {
|
||||||
base[index].SetParent(default(ParentType));
|
base[index].SetParent(default(TParent));
|
||||||
base.SetItem(index, item);
|
base.SetItem(index, item);
|
||||||
item.SetParent(this.parent);
|
item.SetParent(this.parent);
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Parent this collection currently belongs to</summary>
|
/// <summary>Parent this collection currently belongs to</summary>
|
||||||
private ParentType parent;
|
private TParent parent;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit tests for the Pool class</summary>
|
/// <summary>Unit tests for the Pool class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PoolTest {
|
internal class PoolTest {
|
||||||
|
|
||||||
#region class TestClass
|
#region class TestClass
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -25,7 +25,7 @@ using System.Text;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Pool that recycles objects in order to avoid garbage build-up</summary>
|
/// <summary>Pool that recycles objects in order to avoid garbage build-up</summary>
|
||||||
/// <typeparam name="ItemType">Type of objects being pooled</typeparam>
|
/// <typeparam name="TItem">Type of objects being pooled</typeparam>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Use this class to recycle objects instead of letting them become garbage,
|
/// Use this class to recycle objects instead of letting them become garbage,
|
||||||
|
@ -45,7 +45,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// automatically call its IRecyclable.Recycle() method.
|
/// automatically call its IRecyclable.Recycle() method.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public class Pool<ItemType> where ItemType : class, new() {
|
public class Pool<TItem> where TItem : class, new() {
|
||||||
|
|
||||||
/// <summary>Default number of recyclable objects the pool will store</summary>
|
/// <summary>Default number of recyclable objects the pool will store</summary>
|
||||||
public const int DefaultPoolSize = 64;
|
public const int DefaultPoolSize = 64;
|
||||||
|
@ -63,12 +63,12 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Returns a new or recycled instance of the types managed by the pool
|
/// Returns a new or recycled instance of the types managed by the pool
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A new or recycled instance</returns>
|
/// <returns>A new or recycled instance</returns>
|
||||||
public ItemType Get() {
|
public TItem Get() {
|
||||||
lock(this) {
|
lock(this) {
|
||||||
if(this.items.Count > 0) {
|
if(this.items.Count > 0) {
|
||||||
return this.items.Dequeue();
|
return this.items.Dequeue();
|
||||||
} else {
|
} else {
|
||||||
return new ItemType();
|
return new TItem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Redeems an instance that is no longer used to be recycled by the pool
|
/// Redeems an instance that is no longer used to be recycled by the pool
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The instance that will be redeemed</param>
|
/// <param name="item">The instance that will be redeemed</param>
|
||||||
public void Redeem(ItemType item) {
|
public void Redeem(TItem item) {
|
||||||
|
|
||||||
// Call Recycle() when the object is redeemed (instead of when it leaves
|
// Call Recycle() when the object is redeemed (instead of when it leaves
|
||||||
// the pool again) in order to eliminate any references the object may hold
|
// the pool again) in order to eliminate any references the object may hold
|
||||||
|
@ -100,7 +100,7 @@ namespace Nuclex.Support.Collections {
|
||||||
get { return this.capacity; }
|
get { return this.capacity; }
|
||||||
set {
|
set {
|
||||||
this.capacity = value;
|
this.capacity = value;
|
||||||
this.items = new Queue<ItemType>(value);
|
this.items = new Queue<TItem>(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="item">
|
/// <param name="item">
|
||||||
/// Object whose Recycle() method will be called if supported by the object
|
/// Object whose Recycle() method will be called if supported by the object
|
||||||
/// </param>
|
/// </param>
|
||||||
private static void callRecycleIfSupported(ItemType item) {
|
private static void callRecycleIfSupported(TItem item) {
|
||||||
IRecyclable recycleable = item as IRecyclable;
|
IRecyclable recycleable = item as IRecyclable;
|
||||||
if(recycleable != null) {
|
if(recycleable != null) {
|
||||||
recycleable.Recycle();
|
recycleable.Recycle();
|
||||||
|
@ -119,7 +119,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Objects being retained for recycling</summary>
|
/// <summary>Objects being retained for recycling</summary>
|
||||||
private Queue<ItemType> items;
|
private Queue<TItem> items;
|
||||||
/// <summary>Capacity of the pool</summary>
|
/// <summary>Capacity of the pool</summary>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
/// Required because the Queue class doesn't allow this value to be retrieved
|
/// Required because the Queue class doesn't allow this value to be retrieved
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the Priority/Item pair class</summary>
|
/// <summary>Unit Test for the Priority/Item pair class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PriorityItemPairTest {
|
internal class PriorityItemPairTest {
|
||||||
|
|
||||||
#region class ToStringNullReturner
|
#region class ToStringNullReturner
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -25,20 +25,20 @@ using System.Text;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>An pair of a priority and an item</summary>
|
/// <summary>An pair of a priority and an item</summary>
|
||||||
public struct PriorityItemPair<PriorityType, ItemType> {
|
public struct PriorityItemPair<TPriority, TItem> {
|
||||||
|
|
||||||
/// <summary>Initializes a new priority / item pair</summary>
|
/// <summary>Initializes a new priority / item pair</summary>
|
||||||
/// <param name="priority">Priority of the item in the pair</param>
|
/// <param name="priority">Priority of the item in the pair</param>
|
||||||
/// <param name="item">Item to be stored in the pair</param>
|
/// <param name="item">Item to be stored in the pair</param>
|
||||||
public PriorityItemPair(PriorityType priority, ItemType item) {
|
public PriorityItemPair(TPriority priority, TItem item) {
|
||||||
this.Priority = priority;
|
this.Priority = priority;
|
||||||
this.Item = item;
|
this.Item = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Priority assigned to this priority / item pair</summary>
|
/// <summary>Priority assigned to this priority / item pair</summary>
|
||||||
public PriorityType Priority;
|
public TPriority Priority;
|
||||||
/// <summary>Item contained in this priority / item pair</summary>
|
/// <summary>Item contained in this priority / item pair</summary>
|
||||||
public ItemType Item;
|
public TItem Item;
|
||||||
|
|
||||||
/// <summary>Converts the priority / item pair into a string</summary>
|
/// <summary>Converts the priority / item pair into a string</summary>
|
||||||
/// <returns>A string describing the priority / item pair</returns>
|
/// <returns>A string describing the priority / item pair</returns>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the priority queue class</summary>
|
/// <summary>Unit Test for the priority queue class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PriorityQueueTest {
|
internal class PriorityQueueTest {
|
||||||
|
|
||||||
#region class FloatComparer
|
#region class FloatComparer
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -25,16 +25,16 @@ using System.Collections;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Queue that dequeues items in order of their priority</summary>
|
/// <summary>Queue that dequeues items in order of their priority</summary>
|
||||||
public class PriorityQueue<ItemType> : ICollection, IEnumerable<ItemType> {
|
public class PriorityQueue<TItem> : ICollection, IEnumerable<TItem> {
|
||||||
|
|
||||||
#region class Enumerator
|
#region class Enumerator
|
||||||
|
|
||||||
/// <summary>Enumerates all items contained in a priority queue</summary>
|
/// <summary>Enumerates all items contained in a priority queue</summary>
|
||||||
private class Enumerator : IEnumerator<ItemType> {
|
private class Enumerator : IEnumerator<TItem> {
|
||||||
|
|
||||||
/// <summary>Initializes a new priority queue enumerator</summary>
|
/// <summary>Initializes a new priority queue enumerator</summary>
|
||||||
/// <param name="priorityQueue">Priority queue to be enumerated</param>
|
/// <param name="priorityQueue">Priority queue to be enumerated</param>
|
||||||
public Enumerator(PriorityQueue<ItemType> priorityQueue) {
|
public Enumerator(PriorityQueue<TItem> priorityQueue) {
|
||||||
this.priorityQueue = priorityQueue;
|
this.priorityQueue = priorityQueue;
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>The current item being enumerated</summary>
|
/// <summary>The current item being enumerated</summary>
|
||||||
ItemType IEnumerator<ItemType>.Current {
|
TItem IEnumerator<TItem>.Current {
|
||||||
get {
|
get {
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
checkVersion();
|
checkVersion();
|
||||||
|
@ -95,7 +95,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Index of the current item in the priority queue</summary>
|
/// <summary>Index of the current item in the priority queue</summary>
|
||||||
private int index;
|
private int index;
|
||||||
/// <summary>The priority queue whose items this instance enumerates</summary>
|
/// <summary>The priority queue whose items this instance enumerates</summary>
|
||||||
private PriorityQueue<ItemType> priorityQueue;
|
private PriorityQueue<TItem> priorityQueue;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
/// <summary>Expected version of the priority queue</summary>
|
/// <summary>Expected version of the priority queue</summary>
|
||||||
private int expectedVersion;
|
private int expectedVersion;
|
||||||
|
@ -108,19 +108,19 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new priority queue using IComparable for comparing items
|
/// Initializes a new priority queue using IComparable for comparing items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PriorityQueue() : this(Comparer<ItemType>.Default) { }
|
public PriorityQueue() : this(Comparer<TItem>.Default) { }
|
||||||
|
|
||||||
/// <summary>Initializes a new priority queue</summary>
|
/// <summary>Initializes a new priority queue</summary>
|
||||||
/// <param name="comparer">Comparer to use for ordering the items</param>
|
/// <param name="comparer">Comparer to use for ordering the items</param>
|
||||||
public PriorityQueue(IComparer<ItemType> comparer) {
|
public PriorityQueue(IComparer<TItem> comparer) {
|
||||||
this.comparer = comparer;
|
this.comparer = comparer;
|
||||||
this.capacity = 15; // 15 is equal to 4 complete levels
|
this.capacity = 15; // 15 is equal to 4 complete levels
|
||||||
this.heap = new ItemType[this.capacity];
|
this.heap = new TItem[this.capacity];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Returns the topmost item in the queue without dequeueing it</summary>
|
/// <summary>Returns the topmost item in the queue without dequeueing it</summary>
|
||||||
/// <returns>The topmost item in the queue</returns>
|
/// <returns>The topmost item in the queue</returns>
|
||||||
public ItemType Peek() {
|
public TItem Peek() {
|
||||||
if(this.count == 0) {
|
if(this.count == 0) {
|
||||||
throw new InvalidOperationException("No items queued");
|
throw new InvalidOperationException("No items queued");
|
||||||
}
|
}
|
||||||
|
@ -131,12 +131,12 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Takes the item with the highest priority off from the queue</summary>
|
/// <summary>Takes the item with the highest priority off from the queue</summary>
|
||||||
/// <returns>The item with the highest priority in the list</returns>
|
/// <returns>The item with the highest priority in the list</returns>
|
||||||
/// <exception cref="InvalidOperationException">When the queue is empty</exception>
|
/// <exception cref="InvalidOperationException">When the queue is empty</exception>
|
||||||
public ItemType Dequeue() {
|
public TItem Dequeue() {
|
||||||
if(this.count == 0) {
|
if(this.count == 0) {
|
||||||
throw new InvalidOperationException("No items available to dequeue");
|
throw new InvalidOperationException("No items available to dequeue");
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemType result = this.heap[0];
|
TItem result = this.heap[0];
|
||||||
--this.count;
|
--this.count;
|
||||||
trickleDown(0, this.heap[this.count]);
|
trickleDown(0, this.heap[this.count]);
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
@ -147,7 +147,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Puts an item into the priority queue</summary>
|
/// <summary>Puts an item into the priority queue</summary>
|
||||||
/// <param name="item">Item to be queued</param>
|
/// <param name="item">Item to be queued</param>
|
||||||
public void Enqueue(ItemType item) {
|
public void Enqueue(TItem item) {
|
||||||
if(this.count == capacity)
|
if(this.count == capacity)
|
||||||
growHeap();
|
growHeap();
|
||||||
|
|
||||||
|
@ -194,14 +194,14 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Returns a typesafe enumerator for the priority queue</summary>
|
/// <summary>Returns a typesafe enumerator for the priority queue</summary>
|
||||||
/// <returns>A new enumerator for the priority queue</returns>
|
/// <returns>A new enumerator for the priority queue</returns>
|
||||||
public IEnumerator<ItemType> GetEnumerator() {
|
public IEnumerator<TItem> GetEnumerator() {
|
||||||
return new Enumerator(this);
|
return new Enumerator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Moves an item upwards in the heap tree</summary>
|
/// <summary>Moves an item upwards in the heap tree</summary>
|
||||||
/// <param name="index">Index of the item to be moved</param>
|
/// <param name="index">Index of the item to be moved</param>
|
||||||
/// <param name="item">Item to be moved</param>
|
/// <param name="item">Item to be moved</param>
|
||||||
private void bubbleUp(int index, ItemType item) {
|
private void bubbleUp(int index, TItem item) {
|
||||||
int parent = getParent(index);
|
int parent = getParent(index);
|
||||||
|
|
||||||
// Note: (index > 0) means there is a parent
|
// Note: (index > 0) means there is a parent
|
||||||
|
@ -217,7 +217,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Move the item downwards in the heap tree</summary>
|
/// <summary>Move the item downwards in the heap tree</summary>
|
||||||
/// <param name="index">Index of the item to be moved</param>
|
/// <param name="index">Index of the item to be moved</param>
|
||||||
/// <param name="item">Item to be moved</param>
|
/// <param name="item">Item to be moved</param>
|
||||||
private void trickleDown(int index, ItemType item) {
|
private void trickleDown(int index, TItem item) {
|
||||||
int child = getLeftChild(index);
|
int child = getLeftChild(index);
|
||||||
|
|
||||||
while(child < this.count) {
|
while(child < this.count) {
|
||||||
|
@ -256,7 +256,7 @@ namespace Nuclex.Support.Collections {
|
||||||
private void growHeap() {
|
private void growHeap() {
|
||||||
this.capacity = (capacity * 2) + 1;
|
this.capacity = (capacity * 2) + 1;
|
||||||
|
|
||||||
ItemType[] newHeap = new ItemType[this.capacity];
|
TItem[] newHeap = new TItem[this.capacity];
|
||||||
Array.Copy(this.heap, 0, newHeap, 0, this.count);
|
Array.Copy(this.heap, 0, newHeap, 0, this.count);
|
||||||
this.heap = newHeap;
|
this.heap = newHeap;
|
||||||
}
|
}
|
||||||
|
@ -268,13 +268,13 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Comparer used to order the items in the priority queue</summary>
|
/// <summary>Comparer used to order the items in the priority queue</summary>
|
||||||
private IComparer<ItemType> comparer;
|
private IComparer<TItem> comparer;
|
||||||
/// <summary>Total number of items in the priority queue</summary>
|
/// <summary>Total number of items in the priority queue</summary>
|
||||||
private int count;
|
private int count;
|
||||||
/// <summary>Available space in the priority queue</summary>
|
/// <summary>Available space in the priority queue</summary>
|
||||||
private int capacity;
|
private int capacity;
|
||||||
/// <summary>Tree containing the items in the priority queue</summary>
|
/// <summary>Tree containing the items in the priority queue</summary>
|
||||||
private ItemType[] heap;
|
private TItem[] heap;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
/// <summary>Incremented whenever the priority queue is modified</summary>
|
/// <summary>Incremented whenever the priority queue is modified</summary>
|
||||||
private int version;
|
private int version;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the read only collection wrapper</summary>
|
/// <summary>Unit Test for the read only collection wrapper</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ReadOnlyCollectionTest {
|
internal class ReadOnlyCollectionTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verifies that the copy constructor of the read only collection works
|
/// Verifies that the copy constructor of the read only collection works
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -25,14 +25,14 @@ using System.Collections.Generic;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Wraps a Collection and prevents users from modifying it</summary>
|
/// <summary>Wraps a Collection and prevents users from modifying it</summary>
|
||||||
/// <typeparam name="ItemType">Type of items to manage in the Collection</typeparam>
|
/// <typeparam name="TItem">Type of items to manage in the Collection</typeparam>
|
||||||
public class ReadOnlyCollection<ItemType> :
|
public class ReadOnlyCollection<TItem> :
|
||||||
ICollection<ItemType>,
|
ICollection<TItem>,
|
||||||
ICollection {
|
ICollection {
|
||||||
|
|
||||||
/// <summary>Initializes a new read-only Collection wrapper</summary>
|
/// <summary>Initializes a new read-only Collection wrapper</summary>
|
||||||
/// <param name="collection">Collection that will be wrapped</param>
|
/// <param name="collection">Collection that will be wrapped</param>
|
||||||
public ReadOnlyCollection(ICollection<ItemType> collection) {
|
public ReadOnlyCollection(ICollection<TItem> collection) {
|
||||||
this.typedCollection = collection;
|
this.typedCollection = collection;
|
||||||
this.objectCollection = (collection as ICollection);
|
this.objectCollection = (collection as ICollection);
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Determines whether the List contains the specified item</summary>
|
/// <summary>Determines whether the List contains the specified item</summary>
|
||||||
/// <param name="item">Item that will be checked for</param>
|
/// <param name="item">Item that will be checked for</param>
|
||||||
/// <returns>True if the specified item is contained in the List</returns>
|
/// <returns>True if the specified item is contained in the List</returns>
|
||||||
public bool Contains(ItemType item) {
|
public bool Contains(TItem item) {
|
||||||
return this.typedCollection.Contains(item);
|
return this.typedCollection.Contains(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="arrayIndex">
|
/// <param name="arrayIndex">
|
||||||
/// Starting index at which to begin filling the destination array
|
/// Starting index at which to begin filling the destination array
|
||||||
/// </param>
|
/// </param>
|
||||||
public void CopyTo(ItemType[] array, int arrayIndex) {
|
public void CopyTo(TItem[] array, int arrayIndex) {
|
||||||
this.typedCollection.CopyTo(array, arrayIndex);
|
this.typedCollection.CopyTo(array, arrayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Returns a new enumerator over the contents of the List</summary>
|
/// <summary>Returns a new enumerator over the contents of the List</summary>
|
||||||
/// <returns>The new List contents enumerator</returns>
|
/// <returns>The new List contents enumerator</returns>
|
||||||
public IEnumerator<ItemType> GetEnumerator() {
|
public IEnumerator<TItem> GetEnumerator() {
|
||||||
return this.typedCollection.GetEnumerator();
|
return this.typedCollection.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,14 +73,14 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Adds an item to the end of the List</summary>
|
/// <summary>Adds an item to the end of the List</summary>
|
||||||
/// <param name="item">Item that will be added to the List</param>
|
/// <param name="item">Item that will be added to the List</param>
|
||||||
void ICollection<ItemType>.Add(ItemType item) {
|
void ICollection<TItem>.Add(TItem item) {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
"Adding items is not supported by the read-only List"
|
"Adding items is not supported by the read-only List"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Removes all items from the List</summary>
|
/// <summary>Removes all items from the List</summary>
|
||||||
void ICollection<ItemType>.Clear() {
|
void ICollection<TItem>.Clear() {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
"Clearing is not supported by the read-only List"
|
"Clearing is not supported by the read-only List"
|
||||||
);
|
);
|
||||||
|
@ -89,7 +89,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Removes the specified item from the List</summary>
|
/// <summary>Removes the specified item from the List</summary>
|
||||||
/// <param name="item">Item that will be removed from the List</param>
|
/// <param name="item">Item that will be removed from the List</param>
|
||||||
/// <returns>True of the specified item was found in the List and removed</returns>
|
/// <returns>True of the specified item was found in the List and removed</returns>
|
||||||
bool ICollection<ItemType>.Remove(ItemType item) {
|
bool ICollection<TItem>.Remove(TItem item) {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
"Removing items is not supported by the read-only List"
|
"Removing items is not supported by the read-only List"
|
||||||
);
|
);
|
||||||
|
@ -131,7 +131,7 @@ namespace Nuclex.Support.Collections {
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>The wrapped Collection under its type-safe interface</summary>
|
/// <summary>The wrapped Collection under its type-safe interface</summary>
|
||||||
private ICollection<ItemType> typedCollection;
|
private ICollection<TItem> typedCollection;
|
||||||
/// <summary>The wrapped Collection under its object interface</summary>
|
/// <summary>The wrapped Collection under its object interface</summary>
|
||||||
private ICollection objectCollection;
|
private ICollection objectCollection;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -32,7 +32,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the read only dictionary wrapper</summary>
|
/// <summary>Unit Test for the read only dictionary wrapper</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ReadOnlyDictionaryTest {
|
internal class ReadOnlyDictionaryTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verifies that the copy constructor of the read only dictionary works
|
/// Verifies that the copy constructor of the read only dictionary works
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the read only list wrapper</summary>
|
/// <summary>Unit Test for the read only list wrapper</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ReadOnlyListTest {
|
internal class ReadOnlyListTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verifies that the copy constructor of the read only list works
|
/// Verifies that the copy constructor of the read only list works
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -25,14 +25,12 @@ using System.Collections.Generic;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Wraps a List and prevents users from modifying it</summary>
|
/// <summary>Wraps a List and prevents users from modifying it</summary>
|
||||||
/// <typeparam name="ItemType">Type of items to manage in the List</typeparam>
|
/// <typeparam name="TItem">Type of items to manage in the List</typeparam>
|
||||||
public class ReadOnlyList<ItemType> :
|
public class ReadOnlyList<TItem> : IList<TItem>, IList {
|
||||||
IList<ItemType>,
|
|
||||||
IList {
|
|
||||||
|
|
||||||
/// <summary>Initializes a new read-only List wrapper</summary>
|
/// <summary>Initializes a new read-only List wrapper</summary>
|
||||||
/// <param name="list">List that will be wrapped</param>
|
/// <param name="list">List that will be wrapped</param>
|
||||||
public ReadOnlyList(IList<ItemType> list) {
|
public ReadOnlyList(IList<TItem> list) {
|
||||||
this.typedList = list;
|
this.typedList = list;
|
||||||
this.objectList = (list as IList);
|
this.objectList = (list as IList);
|
||||||
}
|
}
|
||||||
|
@ -40,20 +38,20 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Retrieves the index of an item within the List</summary>
|
/// <summary>Retrieves the index of an item within the List</summary>
|
||||||
/// <param name="item">Item whose index will be returned</param>
|
/// <param name="item">Item whose index will be returned</param>
|
||||||
/// <returns>The zero-based index of the specified item in the List</returns>
|
/// <returns>The zero-based index of the specified item in the List</returns>
|
||||||
public int IndexOf(ItemType item) {
|
public int IndexOf(TItem item) {
|
||||||
return this.typedList.IndexOf(item);
|
return this.typedList.IndexOf(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Accesses the List item with the specified index</summary>
|
/// <summary>Accesses the List item with the specified index</summary>
|
||||||
/// <param name="index">Zero-based index of the List item that will be accessed</param>
|
/// <param name="index">Zero-based index of the List item that will be accessed</param>
|
||||||
public ItemType this[int index] {
|
public TItem this[int index] {
|
||||||
get { return this.typedList[index]; }
|
get { return this.typedList[index]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Determines whether the List contains the specified item</summary>
|
/// <summary>Determines whether the List contains the specified item</summary>
|
||||||
/// <param name="item">Item that will be checked for</param>
|
/// <param name="item">Item that will be checked for</param>
|
||||||
/// <returns>True if the specified item is contained in the List</returns>
|
/// <returns>True if the specified item is contained in the List</returns>
|
||||||
public bool Contains(ItemType item) {
|
public bool Contains(TItem item) {
|
||||||
return this.typedList.Contains(item);
|
return this.typedList.Contains(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +60,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <param name="arrayIndex">
|
/// <param name="arrayIndex">
|
||||||
/// Starting index at which to begin filling the destination array
|
/// Starting index at which to begin filling the destination array
|
||||||
/// </param>
|
/// </param>
|
||||||
public void CopyTo(ItemType[] array, int arrayIndex) {
|
public void CopyTo(TItem[] array, int arrayIndex) {
|
||||||
this.typedList.CopyTo(array, arrayIndex);
|
this.typedList.CopyTo(array, arrayIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +76,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Returns a new enumerator over the contents of the List</summary>
|
/// <summary>Returns a new enumerator over the contents of the List</summary>
|
||||||
/// <returns>The new List contents enumerator</returns>
|
/// <returns>The new List contents enumerator</returns>
|
||||||
public IEnumerator<ItemType> GetEnumerator() {
|
public IEnumerator<TItem> GetEnumerator() {
|
||||||
return this.typedList.GetEnumerator();
|
return this.typedList.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +85,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Inserts an item into the List</summary>
|
/// <summary>Inserts an item into the List</summary>
|
||||||
/// <param name="index">Zero-based index before which the item will be inserted</param>
|
/// <param name="index">Zero-based index before which the item will be inserted</param>
|
||||||
/// <param name="item">Item that will be inserted into the List</param>
|
/// <param name="item">Item that will be inserted into the List</param>
|
||||||
void IList<ItemType>.Insert(int index, ItemType item) {
|
void IList<TItem>.Insert(int index, TItem item) {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
"Inserting items is not supported by the read-only List"
|
"Inserting items is not supported by the read-only List"
|
||||||
);
|
);
|
||||||
|
@ -95,7 +93,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Removes an item from the list</summary>
|
/// <summary>Removes an item from the list</summary>
|
||||||
/// <param name="index">Zero-based index of the item that will be removed</param>
|
/// <param name="index">Zero-based index of the item that will be removed</param>
|
||||||
void IList<ItemType>.RemoveAt(int index) {
|
void IList<TItem>.RemoveAt(int index) {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
"Removing items is not supported by the read-only List"
|
"Removing items is not supported by the read-only List"
|
||||||
);
|
);
|
||||||
|
@ -103,7 +101,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Accesses the List item with the specified index</summary>
|
/// <summary>Accesses the List item with the specified index</summary>
|
||||||
/// <param name="index">Zero-based index of the List item that will be accessed</param>
|
/// <param name="index">Zero-based index of the List item that will be accessed</param>
|
||||||
ItemType IList<ItemType>.this[int index] {
|
TItem IList<TItem>.this[int index] {
|
||||||
get { return this.typedList[index]; }
|
get { return this.typedList[index]; }
|
||||||
set {
|
set {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
|
@ -118,14 +116,14 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Adds an item to the end of the List</summary>
|
/// <summary>Adds an item to the end of the List</summary>
|
||||||
/// <param name="item">Item that will be added to the List</param>
|
/// <param name="item">Item that will be added to the List</param>
|
||||||
void ICollection<ItemType>.Add(ItemType item) {
|
void ICollection<TItem>.Add(TItem item) {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
"Adding items is not supported by the read-only List"
|
"Adding items is not supported by the read-only List"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Removes all items from the List</summary>
|
/// <summary>Removes all items from the List</summary>
|
||||||
void ICollection<ItemType>.Clear() {
|
void ICollection<TItem>.Clear() {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
"Clearing is not supported by the read-only List"
|
"Clearing is not supported by the read-only List"
|
||||||
);
|
);
|
||||||
|
@ -134,7 +132,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>Removes the specified item from the List</summary>
|
/// <summary>Removes the specified item from the List</summary>
|
||||||
/// <param name="item">Item that will be removed from the List</param>
|
/// <param name="item">Item that will be removed from the List</param>
|
||||||
/// <returns>True of the specified item was found in the List and removed</returns>
|
/// <returns>True of the specified item was found in the List and removed</returns>
|
||||||
bool ICollection<ItemType>.Remove(ItemType item) {
|
bool ICollection<TItem>.Remove(TItem item) {
|
||||||
throw new NotSupportedException(
|
throw new NotSupportedException(
|
||||||
"Removing items is not supported by the read-only List"
|
"Removing items is not supported by the read-only List"
|
||||||
);
|
);
|
||||||
|
@ -251,7 +249,7 @@ namespace Nuclex.Support.Collections {
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>The wrapped List under its type-safe interface</summary>
|
/// <summary>The wrapped List under its type-safe interface</summary>
|
||||||
private IList<ItemType> typedList;
|
private IList<TItem> typedList;
|
||||||
/// <summary>The wrapped List under its object interface</summary>
|
/// <summary>The wrapped List under its object interface</summary>
|
||||||
private IList objectList;
|
private IList objectList;
|
||||||
|
|
||||||
|
|
9
Source/Collections/ReadOnlySet.Test.cs
Normal file
9
Source/Collections/ReadOnlySet.Test.cs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Nuclex.Support.Source.Collections {
|
||||||
|
class ReadOnlySet {
|
||||||
|
}
|
||||||
|
}
|
267
Source/Collections/ReadOnlySet.cs
Normal file
267
Source/Collections/ReadOnlySet.cs
Normal file
|
@ -0,0 +1,267 @@
|
||||||
|
#region CPL License
|
||||||
|
/*
|
||||||
|
Nuclex Framework
|
||||||
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
published by the IBM Corporation; either version 1.0 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
IBM Common Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the IBM Common Public
|
||||||
|
License along with this library
|
||||||
|
*/
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
|
#if false
|
||||||
|
/// <summary>Wraps a List and prevents users from modifying it</summary>
|
||||||
|
/// <typeparam name="TItem">Type of items to manage in the List</typeparam>
|
||||||
|
#if !NO_SERIALIZATION
|
||||||
|
[Serializable]
|
||||||
|
#endif
|
||||||
|
public class ReadOnlySet<TItem> :
|
||||||
|
#if !NO_SERIALIZATION
|
||||||
|
ISerializable,
|
||||||
|
IDeserializationCallback,
|
||||||
|
#endif
|
||||||
|
ISet<TItem>,
|
||||||
|
ICollection<TItem> {
|
||||||
|
|
||||||
|
/// <summary>Initializes a new read-only List wrapper</summary>
|
||||||
|
/// <param name="list">List that will be wrapped</param>
|
||||||
|
public ReadOnlySet(ISet<TItem> list) {
|
||||||
|
this.typedList = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Retrieves the index of an item within the List</summary>
|
||||||
|
/// <param name="item">Item whose index will be returned</param>
|
||||||
|
/// <returns>The zero-based index of the specified item in the List</returns>
|
||||||
|
public int IndexOf(TItem item) {
|
||||||
|
return this.typedList.IndexOf(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Accesses the List item with the specified index</summary>
|
||||||
|
/// <param name="index">Zero-based index of the List item that will be accessed</param>
|
||||||
|
public TItem this[int index] {
|
||||||
|
get { return this.typedList[index]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Determines whether the List contains the specified item</summary>
|
||||||
|
/// <param name="item">Item that will be checked for</param>
|
||||||
|
/// <returns>True if the specified item is contained in the List</returns>
|
||||||
|
public bool Contains(TItem item) {
|
||||||
|
return this.typedList.Contains(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Copies the contents of the List into an array</summary>
|
||||||
|
/// <param name="array">Array the List will be copied into</param>
|
||||||
|
/// <param name="arrayIndex">
|
||||||
|
/// Starting index at which to begin filling the destination array
|
||||||
|
/// </param>
|
||||||
|
public void CopyTo(TItem[] array, int arrayIndex) {
|
||||||
|
this.typedList.CopyTo(array, arrayIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>The number of items current contained in the List</summary>
|
||||||
|
public int Count {
|
||||||
|
get { return this.typedList.Count; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Whether the List is write-protected</summary>
|
||||||
|
public bool IsReadOnly {
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Returns a new enumerator over the contents of the List</summary>
|
||||||
|
/// <returns>The new List contents enumerator</returns>
|
||||||
|
public IEnumerator<TItem> GetEnumerator() {
|
||||||
|
return this.typedList.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IList<> implementation
|
||||||
|
|
||||||
|
/// <summary>Inserts an item into the List</summary>
|
||||||
|
/// <param name="index">Zero-based index before which the item will be inserted</param>
|
||||||
|
/// <param name="item">Item that will be inserted into the List</param>
|
||||||
|
void IList<TItem>.Insert(int index, TItem item) {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Inserting items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Removes an item from the list</summary>
|
||||||
|
/// <param name="index">Zero-based index of the item that will be removed</param>
|
||||||
|
void IList<TItem>.RemoveAt(int index) {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Removing items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Accesses the List item with the specified index</summary>
|
||||||
|
/// <param name="index">Zero-based index of the List item that will be accessed</param>
|
||||||
|
TItem IList<ItemType>.this[int index] {
|
||||||
|
get { return this.typedList[index]; }
|
||||||
|
set {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Assigning items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ICollection<> implementation
|
||||||
|
|
||||||
|
/// <summary>Adds an item to the end of the List</summary>
|
||||||
|
/// <param name="item">Item that will be added to the List</param>
|
||||||
|
void ICollection<TItem>.Add(TItem item) {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Adding items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Removes all items from the List</summary>
|
||||||
|
void ICollection<TItem>.Clear() {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Clearing is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Removes the specified item from the List</summary>
|
||||||
|
/// <param name="item">Item that will be removed from the List</param>
|
||||||
|
/// <returns>True of the specified item was found in the List and removed</returns>
|
||||||
|
bool ICollection<TItem>.Remove(TItem item) {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Removing items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IEnumerable implementation
|
||||||
|
|
||||||
|
/// <summary>Returns a new enumerator over the contents of the List</summary>
|
||||||
|
/// <returns>The new List contents enumerator</returns>
|
||||||
|
IEnumerator IEnumerable.GetEnumerator() {
|
||||||
|
return this.objectList.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IList implementation
|
||||||
|
|
||||||
|
/// <summary>Removes all items from the List</summary>
|
||||||
|
void IList.Clear() {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Clearing is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Adds an item to the end of the List</summary>
|
||||||
|
/// <param name="value">Item that will be added to the List</param>
|
||||||
|
int IList.Add(object value) {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Adding items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Determines whether the List contains the specified item</summary>
|
||||||
|
/// <param name="value">Item that will be checked for</param>
|
||||||
|
/// <returns>True if the specified item is contained in the List</returns>
|
||||||
|
bool IList.Contains(object value) {
|
||||||
|
return this.objectList.Contains(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Retrieves the index of an item within the List</summary>
|
||||||
|
/// <param name="value">Item whose index will be returned</param>
|
||||||
|
/// <returns>The zero-based index of the specified item in the List</returns>
|
||||||
|
int IList.IndexOf(object value) {
|
||||||
|
return this.objectList.IndexOf(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Inserts an item into the List</summary>
|
||||||
|
/// <param name="index">Zero-based index before which the item will be inserted</param>
|
||||||
|
/// <param name="value">Item that will be inserted into the List</param>
|
||||||
|
void IList.Insert(int index, object value) {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Inserting items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Whether the size of the List is fixed</summary>
|
||||||
|
bool IList.IsFixedSize {
|
||||||
|
get { return this.objectList.IsFixedSize; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Removes the specified item from the List</summary>
|
||||||
|
/// <param name="value">Item that will be removed from the List</param>
|
||||||
|
/// <returns>True of the specified item was found in the List and removed</returns>
|
||||||
|
void IList.Remove(object value) {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Removing items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Removes an item from the list</summary>
|
||||||
|
/// <param name="index">Zero-based index of the item that will be removed</param>
|
||||||
|
void IList.RemoveAt(int index) {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Removing items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Accesses the List item with the specified index</summary>
|
||||||
|
/// <param name="index">Zero-based index of the List item that will be accessed</param>
|
||||||
|
object IList.this[int index] {
|
||||||
|
get { return this.objectList[index]; }
|
||||||
|
set {
|
||||||
|
throw new NotSupportedException(
|
||||||
|
"Assigning items is not supported by the read-only List"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region ICollection implementation
|
||||||
|
|
||||||
|
/// <summary>Copies the contents of the List into an array</summary>
|
||||||
|
/// <param name="array">Array the List will be copied into</param>
|
||||||
|
/// <param name="index">
|
||||||
|
/// Starting index at which to begin filling the destination array
|
||||||
|
/// </param>
|
||||||
|
void ICollection.CopyTo(Array array, int index) {
|
||||||
|
this.objectList.CopyTo(array, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Whether the List is synchronized for multi-threaded usage</summary>
|
||||||
|
bool ICollection.IsSynchronized {
|
||||||
|
get { return this.objectList.IsSynchronized; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>Synchronization root on which the List locks</summary>
|
||||||
|
object ICollection.SyncRoot {
|
||||||
|
get { return this.objectList.SyncRoot; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>The wrapped List under its type-safe interface</summary>
|
||||||
|
private ISet<TItem> typedList;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} // namespace Nuclex.Support.Collections
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the ReverseComparer helper class</summary>
|
/// <summary>Unit Test for the ReverseComparer helper class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ReverseComparerTest {
|
internal class ReverseComparerTest {
|
||||||
|
|
||||||
#region class FortyTwoComparer
|
#region class FortyTwoComparer
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,11 +29,9 @@ namespace Nuclex.Support.Collections {
|
||||||
// Shows the niceties of having to support languages without generics and using
|
// Shows the niceties of having to support languages without generics and using
|
||||||
// an inferior design to make collections "more convenient" for the user :/
|
// an inferior design to make collections "more convenient" for the user :/
|
||||||
|
|
||||||
partial class TransformingReadOnlyCollection<
|
partial class TransformingReadOnlyCollection<TContainedItem, TExposedItem> {
|
||||||
ContainedItemType, ExposedItemType
|
|
||||||
> {
|
|
||||||
|
|
||||||
#region IList<ExposedItemType> Members
|
#region IList<TExposedItem> Members
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Inserts an item to the TransformingReadOnlyCollection at the specified index.
|
/// Inserts an item to the TransformingReadOnlyCollection at the specified index.
|
||||||
|
@ -50,7 +48,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||||
/// index is not a valid index in the TransformingReadOnlyCollection.
|
/// index is not a valid index in the TransformingReadOnlyCollection.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
void IList<ExposedItemType>.Insert(int index, ExposedItemType item) {
|
void IList<TExposedItem>.Insert(int index, TExposedItem item) {
|
||||||
throw new NotSupportedException("The collection is ready-only");
|
throw new NotSupportedException("The collection is ready-only");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +62,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||||
/// Index is not a valid index in the TransformingReadOnlyCollection.
|
/// Index is not a valid index in the TransformingReadOnlyCollection.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
void IList<ExposedItemType>.RemoveAt(int index) {
|
void IList<TExposedItem>.RemoveAt(int index) {
|
||||||
throw new NotSupportedException("The collection is ready-only");
|
throw new NotSupportedException("The collection is ready-only");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +75,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <exception cref="System.NotSupportedException">
|
/// <exception cref="System.NotSupportedException">
|
||||||
/// The property is set and the TransformingReadOnlyCollection is read-only
|
/// The property is set and the TransformingReadOnlyCollection is read-only
|
||||||
/// </exception>
|
/// </exception>
|
||||||
ExposedItemType IList<ExposedItemType>.this[int index] {
|
TExposedItem IList<TExposedItem>.this[int index] {
|
||||||
get {
|
get {
|
||||||
return this[index];
|
return this[index];
|
||||||
}
|
}
|
||||||
|
@ -88,14 +86,14 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ICollection<ExposedItemType> Members
|
#region ICollection<TExposedItem> Members
|
||||||
|
|
||||||
/// <summary>Adds an item to the TransformingReadOnlyCollection.</summary>
|
/// <summary>Adds an item to the TransformingReadOnlyCollection.</summary>
|
||||||
/// <param name="item">The object to add to the TransformingReadOnlyCollection</param>
|
/// <param name="item">The object to add to the TransformingReadOnlyCollection</param>
|
||||||
/// <exception cref="System.NotSupportedException">
|
/// <exception cref="System.NotSupportedException">
|
||||||
/// The TransformingReadOnlyCollection is read-only.
|
/// The TransformingReadOnlyCollection is read-only.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
void ICollection<ExposedItemType>.Add(ExposedItemType item) {
|
void ICollection<TExposedItem>.Add(TExposedItem item) {
|
||||||
throw new NotSupportedException("The collection is ready-only");
|
throw new NotSupportedException("The collection is ready-only");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +101,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <exception cref="System.NotSupportedException">
|
/// <exception cref="System.NotSupportedException">
|
||||||
/// The TransformingReadOnlyCollection is read-only.
|
/// The TransformingReadOnlyCollection is read-only.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
void ICollection<ExposedItemType>.Clear() {
|
void ICollection<TExposedItem>.Clear() {
|
||||||
throw new NotSupportedException("The collection is ready-only");
|
throw new NotSupportedException("The collection is ready-only");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +120,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <exception cref="System.NotSupportedException">
|
/// <exception cref="System.NotSupportedException">
|
||||||
/// The TransformingReadOnlyCollection is read-only.
|
/// The TransformingReadOnlyCollection is read-only.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
bool ICollection<ExposedItemType>.Remove(ExposedItemType item) {
|
bool ICollection<TExposedItem>.Remove(TExposedItem item) {
|
||||||
throw new NotSupportedException("The collection is ready-only");
|
throw new NotSupportedException("The collection is ready-only");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +173,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// otherwise, false.
|
/// otherwise, false.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
bool IList.Contains(object value) {
|
bool IList.Contains(object value) {
|
||||||
return Contains((ExposedItemType)value);
|
return Contains((TExposedItem)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -188,7 +186,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// The index of value if found in the list; otherwise, -1.
|
/// The index of value if found in the list; otherwise, -1.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
int IList.IndexOf(object value) {
|
int IList.IndexOf(object value) {
|
||||||
return IndexOf((ExposedItemType)value);
|
return IndexOf((TExposedItem)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -301,7 +299,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// automatically to the type of the destination array.
|
/// automatically to the type of the destination array.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
void ICollection.CopyTo(Array array, int index) {
|
void ICollection.CopyTo(Array array, int index) {
|
||||||
CopyTo((ExposedItemType[])array, index);
|
CopyTo((TExposedItem[])array, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -31,7 +31,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the transforming read only collection wrapper</summary>
|
/// <summary>Unit Test for the transforming read only collection wrapper</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TransformingReadOnlyCollectionTest {
|
internal class TransformingReadOnlyCollectionTest {
|
||||||
|
|
||||||
#region class StringTransformer
|
#region class StringTransformer
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -26,10 +26,10 @@ using System.Collections.ObjectModel;
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Collection that transforms the contents of another collection.</summary>
|
/// <summary>Collection that transforms the contents of another collection.</summary>
|
||||||
/// <typeparam name="ContainedItemType">
|
/// <typeparam name="TContainedItem">
|
||||||
/// Type of the items contained in the wrapped collection.
|
/// Type of the items contained in the wrapped collection.
|
||||||
/// </typeparam>
|
/// </typeparam>
|
||||||
/// <typeparam name="ExposedItemType">
|
/// <typeparam name="TExposedItem">
|
||||||
/// Type this collection exposes its items as.
|
/// Type this collection exposes its items as.
|
||||||
/// </typeparam>
|
/// </typeparam>
|
||||||
/// <remarks>
|
/// <remarks>
|
||||||
|
@ -49,8 +49,8 @@ namespace Nuclex.Support.Collections {
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public abstract partial class TransformingReadOnlyCollection<
|
public abstract partial class TransformingReadOnlyCollection<
|
||||||
ContainedItemType, ExposedItemType
|
TContainedItem, TExposedItem
|
||||||
> : IList<ExposedItemType>, IList {
|
> : IList<TExposedItem>, IList {
|
||||||
|
|
||||||
#region class TransformingEnumerator
|
#region class TransformingEnumerator
|
||||||
|
|
||||||
|
@ -58,14 +58,14 @@ namespace Nuclex.Support.Collections {
|
||||||
/// An enumerator that transforms the items returned by an enumerator of the
|
/// An enumerator that transforms the items returned by an enumerator of the
|
||||||
/// wrapped collection into the exposed type on-the-fly.
|
/// wrapped collection into the exposed type on-the-fly.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class TransformingEnumerator : IEnumerator<ExposedItemType> {
|
private class TransformingEnumerator : IEnumerator<TExposedItem> {
|
||||||
|
|
||||||
/// <summary>Initializes a new transforming enumerator</summary>
|
/// <summary>Initializes a new transforming enumerator</summary>
|
||||||
/// <param name="transformer">Owner; used to invoke the Transform() method</param>
|
/// <param name="transformer">Owner; used to invoke the Transform() method</param>
|
||||||
/// <param name="containedTypeEnumerator">Enumerator of the wrapped collection</param>
|
/// <param name="containedTypeEnumerator">Enumerator of the wrapped collection</param>
|
||||||
public TransformingEnumerator(
|
public TransformingEnumerator(
|
||||||
TransformingReadOnlyCollection<ContainedItemType, ExposedItemType> transformer,
|
TransformingReadOnlyCollection<TContainedItem, TExposedItem> transformer,
|
||||||
IEnumerator<ContainedItemType> containedTypeEnumerator
|
IEnumerator<TContainedItem> containedTypeEnumerator
|
||||||
) {
|
) {
|
||||||
this.transformer = transformer;
|
this.transformer = transformer;
|
||||||
this.containedTypeEnumerator = containedTypeEnumerator;
|
this.containedTypeEnumerator = containedTypeEnumerator;
|
||||||
|
@ -79,7 +79,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The element in the collection at the current position of the enumerator.
|
/// The element in the collection at the current position of the enumerator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ExposedItemType Current {
|
public TExposedItem Current {
|
||||||
get {
|
get {
|
||||||
return this.transformer.Transform(this.containedTypeEnumerator.Current);
|
return this.transformer.Transform(this.containedTypeEnumerator.Current);
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Collection that owns this enumerator; required to invoke the item
|
/// Collection that owns this enumerator; required to invoke the item
|
||||||
/// transformation method.
|
/// transformation method.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private TransformingReadOnlyCollection<ContainedItemType, ExposedItemType> transformer;
|
private TransformingReadOnlyCollection<TContainedItem, TExposedItem> transformer;
|
||||||
/// <summary>An enumerator from the wrapped collection</summary>
|
/// <summary>An enumerator from the wrapped collection</summary>
|
||||||
private IEnumerator<ContainedItemType> containedTypeEnumerator;
|
private IEnumerator<TContainedItem> containedTypeEnumerator;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Internal list of items that are transformed into the exposed type when
|
/// Internal list of items that are transformed into the exposed type when
|
||||||
/// accessed through the TransformingReadOnlyCollection.
|
/// accessed through the TransformingReadOnlyCollection.
|
||||||
/// </param>
|
/// </param>
|
||||||
public TransformingReadOnlyCollection(IList<ContainedItemType> items) {
|
public TransformingReadOnlyCollection(IList<TContainedItem> items) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// looking for. It is recommended to provide a custom implementation of
|
/// looking for. It is recommended to provide a custom implementation of
|
||||||
/// this method, if possible.
|
/// this method, if possible.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public virtual bool Contains(ExposedItemType item) {
|
public virtual bool Contains(TExposedItem item) {
|
||||||
return (IndexOf(item) != -1);
|
return (IndexOf(item) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +180,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <exception cref="System.ArgumentNullException">
|
/// <exception cref="System.ArgumentNullException">
|
||||||
/// Array is null.
|
/// Array is null.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public void CopyTo(ExposedItemType[] array, int index) {
|
public void CopyTo(TExposedItem[] array, int index) {
|
||||||
if(this.items.Count > (array.Length - index)) {
|
if(this.items.Count > (array.Length - index)) {
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
"Array too small to fit the collection items starting at the specified index"
|
"Array too small to fit the collection items starting at the specified index"
|
||||||
|
@ -198,7 +198,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// An enumerator or the TransformingReadOnlyCollection.
|
/// An enumerator or the TransformingReadOnlyCollection.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public IEnumerator<ExposedItemType> GetEnumerator() {
|
public IEnumerator<TExposedItem> GetEnumerator() {
|
||||||
return new TransformingEnumerator(this, this.items.GetEnumerator());
|
return new TransformingEnumerator(this, this.items.GetEnumerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// looking for. It is recommended to provide a custom implementation of
|
/// looking for. It is recommended to provide a custom implementation of
|
||||||
/// this method, if possible.
|
/// this method, if possible.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public int IndexOf(ExposedItemType item) {
|
public int IndexOf(TExposedItem item) {
|
||||||
|
|
||||||
if(item == null) {
|
if(item == null) {
|
||||||
|
|
||||||
|
@ -233,9 +233,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
EqualityComparer<ExposedItemType> comparer =
|
var comparer = EqualityComparer<TExposedItem>.Default;
|
||||||
EqualityComparer<ExposedItemType>.Default;
|
|
||||||
|
|
||||||
for(int index = 0; index < this.items.Count; ++index) {
|
for(int index = 0; index < this.items.Count; ++index) {
|
||||||
if(comparer.Equals(Transform(this.items[index]), item)) {
|
if(comparer.Equals(Transform(this.items[index]), item)) {
|
||||||
return index;
|
return index;
|
||||||
|
@ -262,7 +260,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Index is less than zero or index is equal to or greater than
|
/// Index is less than zero or index is equal to or greater than
|
||||||
/// TransformingReadOnlyCollection.Count.
|
/// TransformingReadOnlyCollection.Count.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public ExposedItemType this[int index] {
|
public TExposedItem this[int index] {
|
||||||
get { return Transform(this.items[index]); }
|
get { return Transform(this.items[index]); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,10 +278,10 @@ namespace Nuclex.Support.Collections {
|
||||||
/// be called frequently, because the TransformingReadOnlyCollection does
|
/// be called frequently, because the TransformingReadOnlyCollection does
|
||||||
/// not cache or otherwise store the transformed items.
|
/// not cache or otherwise store the transformed items.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
protected abstract ExposedItemType Transform(ContainedItemType item);
|
protected abstract TExposedItem Transform(TContainedItem item);
|
||||||
|
|
||||||
/// <summary>Items being transformed upon exposure by this collection</summary>
|
/// <summary>Items being transformed upon exposure by this collection</summary>
|
||||||
private IList<ContainedItemType> items;
|
private IList<TContainedItem> items;
|
||||||
/// <summary>Synchronization root for threaded accesses to this collection</summary>
|
/// <summary>Synchronization root for threaded accesses to this collection</summary>
|
||||||
private object syncRoot;
|
private object syncRoot;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -25,7 +25,7 @@ using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Nuclex.Support.Collections {
|
namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
partial class WeakCollection<ItemType> {
|
partial class WeakCollection<TItem> {
|
||||||
|
|
||||||
#region IEnumerable Members
|
#region IEnumerable Members
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ namespace Nuclex.Support.Collections {
|
||||||
/// The System.Collections.IList is read-only or the WeakCollection has a fixed size.
|
/// The System.Collections.IList is read-only or the WeakCollection has a fixed size.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
int IList.Add(object value) {
|
int IList.Add(object value) {
|
||||||
ItemType valueAsItemType = downcastToItemType(value);
|
TItem valueAsItemType = downcastToItemType(value);
|
||||||
return (this.items as IList).Add(new WeakReference<ItemType>(valueAsItemType));
|
return (this.items as IList).Add(new WeakReference<TItem>(valueAsItemType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -61,7 +61,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// True if the System.Object is found in the WeakCollection; otherwise, false.
|
/// True if the System.Object is found in the WeakCollection; otherwise, false.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
bool IList.Contains(object value) {
|
bool IList.Contains(object value) {
|
||||||
ItemType valueAsItemType = downcastToItemType(value);
|
TItem valueAsItemType = downcastToItemType(value);
|
||||||
return Contains(valueAsItemType);
|
return Contains(valueAsItemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// The index of value if found in the list; otherwise, -1.
|
/// The index of value if found in the list; otherwise, -1.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
int IList.IndexOf(object value) {
|
int IList.IndexOf(object value) {
|
||||||
ItemType valueAsItemType = downcastToItemType(value);
|
TItem valueAsItemType = downcastToItemType(value);
|
||||||
return IndexOf(valueAsItemType);
|
return IndexOf(valueAsItemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Value is null reference in the WeakCollection.
|
/// Value is null reference in the WeakCollection.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
void IList.Insert(int index, object value) {
|
void IList.Insert(int index, object value) {
|
||||||
ItemType valueAsItemType = downcastToItemType(value);
|
TItem valueAsItemType = downcastToItemType(value);
|
||||||
Insert(index, valueAsItemType);
|
Insert(index, valueAsItemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// The WeakCollection is read-only or the WeakCollection has a fixed size.
|
/// The WeakCollection is read-only or the WeakCollection has a fixed size.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
void IList.Remove(object value) {
|
void IList.Remove(object value) {
|
||||||
ItemType valueAsItemType = downcastToItemType(value);
|
TItem valueAsItemType = downcastToItemType(value);
|
||||||
Remove(valueAsItemType);
|
Remove(valueAsItemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ namespace Nuclex.Support.Collections {
|
||||||
object IList.this[int index] {
|
object IList.this[int index] {
|
||||||
get { return this[index]; }
|
get { return this[index]; }
|
||||||
set {
|
set {
|
||||||
ItemType valueAsItemType = downcastToItemType(value);
|
TItem valueAsItemType = downcastToItemType(value);
|
||||||
this[index] = valueAsItemType;
|
this[index] = valueAsItemType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// the destination array.
|
/// the destination array.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
void ICollection.CopyTo(Array array, int index) {
|
void ICollection.CopyTo(Array array, int index) {
|
||||||
CopyTo((ItemType[])array, index);
|
CopyTo((TItem[])array, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -196,8 +196,8 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// The specified object referecne as a reference to the collection's item type
|
/// The specified object referecne as a reference to the collection's item type
|
||||||
/// </returns>
|
/// </returns>
|
||||||
private static ItemType downcastToItemType(object value) {
|
private static TItem downcastToItemType(object value) {
|
||||||
ItemType valueAsItemType = value as ItemType;
|
TItem valueAsItemType = value as TItem;
|
||||||
if(!ReferenceEquals(value, null)) {
|
if(!ReferenceEquals(value, null)) {
|
||||||
if(valueAsItemType == null) {
|
if(valueAsItemType == null) {
|
||||||
throw new ArgumentException("Object is not of a compatible type", "value");
|
throw new ArgumentException("Object is not of a compatible type", "value");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Unit Test for the weak collection wrapper</summary>
|
/// <summary>Unit Test for the weak collection wrapper</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class WeakCollectionTest {
|
internal class WeakCollectionTest {
|
||||||
|
|
||||||
#region class Dummy
|
#region class Dummy
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -32,8 +32,8 @@ namespace Nuclex.Support.Collections {
|
||||||
/// when the collection detects that one of its items was garbage collected, it
|
/// when the collection detects that one of its items was garbage collected, it
|
||||||
/// will silently remove that item.
|
/// will silently remove that item.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public partial class WeakCollection<ItemType> : IList<ItemType>, IList
|
public partial class WeakCollection<TItem> : IList<TItem>, IList
|
||||||
where ItemType : class {
|
where TItem : class {
|
||||||
|
|
||||||
#region class UnpackingEnumerator
|
#region class UnpackingEnumerator
|
||||||
|
|
||||||
|
@ -41,14 +41,14 @@ namespace Nuclex.Support.Collections {
|
||||||
/// An enumerator that unpacks the items returned by an enumerator of the
|
/// An enumerator that unpacks the items returned by an enumerator of the
|
||||||
/// weak reference collection into the actual item type on-the-fly.
|
/// weak reference collection into the actual item type on-the-fly.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class UnpackingEnumerator : IEnumerator<ItemType> {
|
private class UnpackingEnumerator : IEnumerator<TItem> {
|
||||||
|
|
||||||
/// <summary>Initializes a new unpacking enumerator</summary>
|
/// <summary>Initializes a new unpacking enumerator</summary>
|
||||||
/// <param name="containedTypeEnumerator">
|
/// <param name="containedTypeEnumerator">
|
||||||
/// Enumerator of the weak reference collection
|
/// Enumerator of the weak reference collection
|
||||||
/// </param>
|
/// </param>
|
||||||
public UnpackingEnumerator(
|
public UnpackingEnumerator(
|
||||||
IEnumerator<WeakReference<ItemType>> containedTypeEnumerator
|
IEnumerator<WeakReference<TItem>> containedTypeEnumerator
|
||||||
) {
|
) {
|
||||||
this.containedTypeEnumerator = containedTypeEnumerator;
|
this.containedTypeEnumerator = containedTypeEnumerator;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The element in the collection at the current position of the enumerator.
|
/// The element in the collection at the current position of the enumerator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ItemType Current {
|
public TItem Current {
|
||||||
get { return this.containedTypeEnumerator.Current.Target; }
|
get { return this.containedTypeEnumerator.Current.Target; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>An enumerator from the wrapped collection</summary>
|
/// <summary>An enumerator from the wrapped collection</summary>
|
||||||
private IEnumerator<WeakReference<ItemType>> containedTypeEnumerator;
|
private IEnumerator<WeakReference<TItem>> containedTypeEnumerator;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,8 +107,8 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Internal list of weak references that are unpacking when accessed through
|
/// Internal list of weak references that are unpacking when accessed through
|
||||||
/// the WeakCollection's interface.
|
/// the WeakCollection's interface.
|
||||||
/// </param>
|
/// </param>
|
||||||
public WeakCollection(IList<WeakReference<ItemType>> items) :
|
public WeakCollection(IList<WeakReference<TItem>> items) :
|
||||||
this(items, EqualityComparer<ItemType>.Default) { }
|
this(items, EqualityComparer<TItem>.Default) { }
|
||||||
|
|
||||||
/// <summary>Initializes a new weak reference collection</summary>
|
/// <summary>Initializes a new weak reference collection</summary>
|
||||||
/// <param name="items">
|
/// <param name="items">
|
||||||
|
@ -119,7 +119,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Comparer used to identify and compare items to each other
|
/// Comparer used to identify and compare items to each other
|
||||||
/// </param>
|
/// </param>
|
||||||
public WeakCollection(
|
public WeakCollection(
|
||||||
IList<WeakReference<ItemType>> items, IEqualityComparer<ItemType> comparer
|
IList<WeakReference<TItem>> items, IEqualityComparer<TItem> comparer
|
||||||
) {
|
) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
this.comparer = comparer;
|
this.comparer = comparer;
|
||||||
|
@ -141,7 +141,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// looking for. It is recommended to provide a custom implementation of
|
/// looking for. It is recommended to provide a custom implementation of
|
||||||
/// this method, if possible.
|
/// this method, if possible.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public virtual bool Contains(ItemType item) {
|
public virtual bool Contains(TItem item) {
|
||||||
return (IndexOf(item) != -1);
|
return (IndexOf(item) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +167,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <exception cref="System.ArgumentNullException">
|
/// <exception cref="System.ArgumentNullException">
|
||||||
/// Array is null.
|
/// Array is null.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public void CopyTo(ItemType[] array, int index) {
|
public void CopyTo(TItem[] array, int index) {
|
||||||
if(this.items.Count > (array.Length - index)) {
|
if(this.items.Count > (array.Length - index)) {
|
||||||
throw new ArgumentException(
|
throw new ArgumentException(
|
||||||
"Array too small to fit the collection items starting at the specified index"
|
"Array too small to fit the collection items starting at the specified index"
|
||||||
|
@ -188,7 +188,7 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Returns an enumerator that iterates through the WeakCollection.
|
/// Returns an enumerator that iterates through the WeakCollection.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>An enumerator or the WeakCollection.</returns>
|
/// <returns>An enumerator or the WeakCollection.</returns>
|
||||||
public IEnumerator<ItemType> GetEnumerator() {
|
public IEnumerator<TItem> GetEnumerator() {
|
||||||
return new UnpackingEnumerator(this.items.GetEnumerator());
|
return new UnpackingEnumerator(this.items.GetEnumerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,9 +211,9 @@ namespace Nuclex.Support.Collections {
|
||||||
/// looking for. It is recommended to provide a custom implementation of
|
/// looking for. It is recommended to provide a custom implementation of
|
||||||
/// this method, if possible.
|
/// this method, if possible.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public int IndexOf(ItemType item) {
|
public int IndexOf(TItem item) {
|
||||||
for(int index = 0; index < this.items.Count; ++index) {
|
for(int index = 0; index < this.items.Count; ++index) {
|
||||||
ItemType itemAtIndex = this.items[index].Target;
|
TItem itemAtIndex = this.items[index].Target;
|
||||||
if((itemAtIndex == null) || (item == null)) {
|
if((itemAtIndex == null) || (item == null)) {
|
||||||
if(ReferenceEquals(item, itemAtIndex)) {
|
if(ReferenceEquals(item, itemAtIndex)) {
|
||||||
return index;
|
return index;
|
||||||
|
@ -242,9 +242,9 @@ namespace Nuclex.Support.Collections {
|
||||||
/// Index is less than zero or index is equal to or greater than
|
/// Index is less than zero or index is equal to or greater than
|
||||||
/// WeakCollection.Count.
|
/// WeakCollection.Count.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public ItemType this[int index] {
|
public TItem this[int index] {
|
||||||
get { return this.items[index].Target; }
|
get { return this.items[index].Target; }
|
||||||
set { this.items[index] = new WeakReference<ItemType>(value); }
|
set { this.items[index] = new WeakReference<TItem>(value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -254,9 +254,9 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// True if item was successfully removed from the WeakCollection; otherwise, false.
|
/// True if item was successfully removed from the WeakCollection; otherwise, false.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
public bool Remove(ItemType item) {
|
public bool Remove(TItem item) {
|
||||||
for(int index = 0; index < this.items.Count; ++index) {
|
for(int index = 0; index < this.items.Count; ++index) {
|
||||||
ItemType itemAtIndex = this.items[index].Target;
|
TItem itemAtIndex = this.items[index].Target;
|
||||||
if((itemAtIndex == null) || (item == null)) {
|
if((itemAtIndex == null) || (item == null)) {
|
||||||
if(ReferenceEquals(item, itemAtIndex)) {
|
if(ReferenceEquals(item, itemAtIndex)) {
|
||||||
this.items.RemoveAt(index);
|
this.items.RemoveAt(index);
|
||||||
|
@ -275,8 +275,8 @@ namespace Nuclex.Support.Collections {
|
||||||
|
|
||||||
/// <summary>Adds an item to the WeakCollection.</summary>
|
/// <summary>Adds an item to the WeakCollection.</summary>
|
||||||
/// <param name="item">The object to add to the WeakCollection</param>
|
/// <param name="item">The object to add to the WeakCollection</param>
|
||||||
public void Add(ItemType item) {
|
public void Add(TItem item) {
|
||||||
this.items.Add(new WeakReference<ItemType>(item));
|
this.items.Add(new WeakReference<TItem>(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Inserts an item to the WeakCollection at the specified index.</summary>
|
/// <summary>Inserts an item to the WeakCollection at the specified index.</summary>
|
||||||
|
@ -287,8 +287,8 @@ namespace Nuclex.Support.Collections {
|
||||||
/// <exception cref="System.ArgumentOutOfRangeException">
|
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||||
/// index is not a valid index in the WeakCollection.
|
/// index is not a valid index in the WeakCollection.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public void Insert(int index, ItemType item) {
|
public void Insert(int index, TItem item) {
|
||||||
this.items.Insert(index, new WeakReference<ItemType>(item));
|
this.items.Insert(index, new WeakReference<TItem>(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -329,9 +329,9 @@ namespace Nuclex.Support.Collections {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Weak references to the items contained in the collection</summary>
|
/// <summary>Weak references to the items contained in the collection</summary>
|
||||||
private IList<WeakReference<ItemType>> items;
|
private IList<WeakReference<TItem>> items;
|
||||||
/// <summary>Used to identify and compare items in the collection</summary>
|
/// <summary>Used to identify and compare items in the collection</summary>
|
||||||
private IEqualityComparer<ItemType> comparer;
|
private IEqualityComparer<TItem> comparer;
|
||||||
/// <summary>Synchronization root for threaded accesses to this collection</summary>
|
/// <summary>Synchronization root for threaded accesses to this collection</summary>
|
||||||
private object syncRoot;
|
private object syncRoot;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
/// <summary>Unit Test for the enumeration helper class</summary>
|
/// <summary>Unit Test for the enumeration helper class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class EnumHelperTest {
|
internal class EnumHelperTest {
|
||||||
|
|
||||||
#region enum TestEnumeration
|
#region enum TestEnumeration
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
/// <summary>Unit Test for the FloatHelper class</summary>
|
/// <summary>Unit Test for the FloatHelper class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class FloatHelperTest {
|
internal class FloatHelperTest {
|
||||||
|
|
||||||
/// <summary>Tests the floating point value comparison helper</summary>
|
/// <summary>Tests the floating point value comparison helper</summary>
|
||||||
[Test]
|
[Test]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.IO {
|
||||||
|
|
||||||
/// <summary>Unit Test for the stream chainer</summary>
|
/// <summary>Unit Test for the stream chainer</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class ChainStreamTest {
|
internal class ChainStreamTest {
|
||||||
|
|
||||||
#region class TestStream
|
#region class TestStream
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.IO {
|
||||||
|
|
||||||
/// <summary>Unit Test for the partial stream</summary>
|
/// <summary>Unit Test for the partial stream</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PartialStreamTest {
|
internal class PartialStreamTest {
|
||||||
|
|
||||||
#region class TestStream
|
#region class TestStream
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.IO {
|
||||||
|
|
||||||
/// <summary>Unit Test for the ring buffer class</summary>
|
/// <summary>Unit Test for the ring buffer class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class RingMemoryStreamTest {
|
internal class RingMemoryStreamTest {
|
||||||
|
|
||||||
/// <summary>Prepares some test data for the units test methods</summary>
|
/// <summary>Prepares some test data for the units test methods</summary>
|
||||||
[TestFixtureSetUp]
|
[TestFixtureSetUp]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
/// <summary>Contains unit tests for the integer helper class</summary>
|
/// <summary>Contains unit tests for the integer helper class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class IntegerHelperTest {
|
internal class IntegerHelperTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verifies that the next power of 2 calculation works for long integers
|
/// Verifies that the next power of 2 calculation works for long integers
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,18 +29,17 @@ namespace Nuclex.Support.Licensing {
|
||||||
|
|
||||||
/// <summary>Unit test for the license key class</summary>
|
/// <summary>Unit test for the license key class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class LicenseKeyTest {
|
internal class LicenseKeyTest {
|
||||||
|
|
||||||
/// <summary>Tests the default constructor of the license key class</summary>
|
/// <summary>Tests the default constructor of the license key class</summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDefaultConstructor() {
|
public void DefaultConstructorCanBeUsed() {
|
||||||
new LicenseKey();
|
Assert.IsNotNull(new LicenseKey()); // Nonsense, prevents compiler warning
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Validates the correct translation of keys to GUIDs and back</summary>
|
/// <summary>Validates the correct translation of keys to GUIDs and back</summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestGuidKeyConversion() {
|
public void LicenseKeysCanBeConvertedToGuidsAndBack() {
|
||||||
|
|
||||||
for(int i = 0; i < 128; ++i) {
|
for(int i = 0; i < 128; ++i) {
|
||||||
|
|
||||||
// Create a new BitArray with the n.th bit set
|
// Create a new BitArray with the n.th bit set
|
||||||
|
@ -60,12 +59,11 @@ namespace Nuclex.Support.Licensing {
|
||||||
Assert.AreEqual(originalGuid, rebuiltGuid, "Test for GUID bit " + i);
|
Assert.AreEqual(originalGuid, rebuiltGuid, "Test for GUID bit " + i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Tests whether license keys can be modified without destroying them</summary>
|
/// <summary>Tests whether license keys can be modified without destroying them</summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestKeyModification() {
|
public void LicenseKeysCanBeModified() {
|
||||||
|
|
||||||
for(int i = 0; i < 4; ++i) {
|
for(int i = 0; i < 4; ++i) {
|
||||||
for(int j = 0; j < 8; ++j) {
|
for(int j = 0; j < 8; ++j) {
|
||||||
|
@ -96,7 +94,7 @@ namespace Nuclex.Support.Licensing {
|
||||||
|
|
||||||
/// <summary>Tests whether license keys can be modified without destroying them</summary>
|
/// <summary>Tests whether license keys can be modified without destroying them</summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestParseInvalidLicenseKey() {
|
public void ParsingInvalidLicenseKeyThrowsArgumentException() {
|
||||||
Assert.Throws<ArgumentException>(
|
Assert.Throws<ArgumentException>(
|
||||||
delegate() { LicenseKey.Parse("hello world"); }
|
delegate() { LicenseKey.Parse("hello world"); }
|
||||||
);
|
);
|
||||||
|
@ -107,7 +105,7 @@ namespace Nuclex.Support.Licensing {
|
||||||
/// with an invalid index to retrieve a component of the key
|
/// with an invalid index to retrieve a component of the key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestGetByIndexerWithInvalidIndex() {
|
public void ReadingInvalidIndexThrowsIndexOutOfRangeException() {
|
||||||
LicenseKey key = new LicenseKey();
|
LicenseKey key = new LicenseKey();
|
||||||
Assert.Throws<IndexOutOfRangeException>(
|
Assert.Throws<IndexOutOfRangeException>(
|
||||||
delegate() { Console.WriteLine(key[-1]); }
|
delegate() { Console.WriteLine(key[-1]); }
|
||||||
|
@ -119,7 +117,7 @@ namespace Nuclex.Support.Licensing {
|
||||||
/// with an invalid index to set a component of the key
|
/// with an invalid index to set a component of the key
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSetByIndexerWithInvalidIndex() {
|
public void WritingInvalidIndexThrowsIndexOutOfRangeException() {
|
||||||
LicenseKey key = new LicenseKey();
|
LicenseKey key = new LicenseKey();
|
||||||
Assert.Throws<IndexOutOfRangeException>(
|
Assert.Throws<IndexOutOfRangeException>(
|
||||||
delegate() { key[-1] = 0; }
|
delegate() { key[-1] = 0; }
|
||||||
|
@ -130,7 +128,7 @@ namespace Nuclex.Support.Licensing {
|
||||||
/// Verifies that a license key can be converted into a byte array
|
/// Verifies that a license key can be converted into a byte array
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Test]
|
[Test]
|
||||||
public void TestToByteArray() {
|
public void LicenseKeyCanBeConvertedToByteArray() {
|
||||||
Guid someGuid = Guid.NewGuid();
|
Guid someGuid = Guid.NewGuid();
|
||||||
LicenseKey someKey = new LicenseKey(someGuid);
|
LicenseKey someKey = new LicenseKey(someGuid);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Parsing {
|
||||||
|
|
||||||
/// <summary>Ensures that the command line parser is working properly</summary>
|
/// <summary>Ensures that the command line parser is working properly</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class CommandLineTest {
|
internal class CommandLineTest {
|
||||||
|
|
||||||
#region class ArgumentTest
|
#region class ArgumentTest
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support {
|
||||||
|
|
||||||
/// <summary>Unit Test for the path helper class</summary>
|
/// <summary>Unit Test for the path helper class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PathHelperTest {
|
internal class PathHelperTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests whether the relative path creator keeps the absolute path if
|
/// Tests whether the relative path creator keeps the absolute path if
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -30,7 +30,7 @@ namespace Nuclex.Support.Plugins {
|
||||||
|
|
||||||
/// <summary>Unit Test for the assembly load event argument container</summary>
|
/// <summary>Unit Test for the assembly load event argument container</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class AssemblyLoadEventArgsTest {
|
internal class AssemblyLoadEventArgsTest {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests whether the argument container correctly stores an assembly reference
|
/// Tests whether the argument container correctly stores an assembly reference
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Plugins {
|
||||||
|
|
||||||
/// <summary>Unit Test for the employer class</summary>
|
/// <summary>Unit Test for the employer class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class EmployerTest {
|
internal class EmployerTest {
|
||||||
|
|
||||||
#region class TestEmployer
|
#region class TestEmployer
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
@ -29,7 +29,7 @@ namespace Nuclex.Support.Plugins {
|
||||||
|
|
||||||
/// <summary>Unit Test for the factory employer class</summary>
|
/// <summary>Unit Test for the factory employer class</summary>
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class FactoryEmployerTest {
|
internal class FactoryEmployerTest {
|
||||||
|
|
||||||
#region class Base
|
#region class Base
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#region CPL License
|
#region CPL License
|
||||||
/*
|
/*
|
||||||
Nuclex Framework
|
Nuclex Framework
|
||||||
Copyright (C) 2002-2010 Nuclex Development Labs
|
Copyright (C) 2002-2012 Nuclex Development Labs
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the IBM Common Public License as
|
modify it under the terms of the IBM Common Public License as
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user