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">
|
||||
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
||||
</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.ValueCollection.cs">
|
||||
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
||||
|
@ -130,6 +134,10 @@
|
|||
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
||||
<DependentUpon>ObservableList.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
||||
|
@ -166,6 +174,10 @@
|
|||
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
||||
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
||||
|
|
|
@ -106,12 +106,12 @@
|
|||
<Compile Include="Source\Cloning\ExpressionTreeCloner.Test.cs">
|
||||
<DependentUpon>ExpressionTreeCloner.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Source\Cloning\ICloneFactory.cs" />
|
||||
<Compile Include="Source\Cloning\IStateCopier.cs" />
|
||||
<Compile Include="Source\Cloning\ReflectionCloner.cs" />
|
||||
<Compile Include="Source\Cloning\ReflectionCloner.Test.cs">
|
||||
<DependentUpon>ReflectionCloner.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Source\Cloning\ICloneFactory.cs" />
|
||||
<Compile Include="Source\Cloning\SerializationCloner.cs" />
|
||||
<Compile Include="Source\Cloning\SerializationCloner.Test.cs">
|
||||
<DependentUpon>SerializationCloner.cs</DependentUpon>
|
||||
|
@ -139,6 +139,10 @@
|
|||
<Compile Include="Source\Collections\ItemEventArgs.Test.cs">
|
||||
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
||||
</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.ValueCollection.cs">
|
||||
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
||||
|
@ -161,6 +165,10 @@
|
|||
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
||||
<DependentUpon>ObservableList.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
||||
|
@ -197,6 +205,10 @@
|
|||
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
||||
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
||||
|
@ -214,34 +226,6 @@
|
|||
<Compile Include="Source\Semaphore.Test.cs">
|
||||
<DependentUpon>Semaphore.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>PartialStream.cs</DependentUpon>
|
||||
|
@ -327,10 +311,6 @@
|
|||
<Compile Include="Source\Plugins\PluginRepository.Test.cs">
|
||||
<DependentUpon>PluginRepository.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>Shared.cs</DependentUpon>
|
||||
|
|
|
@ -117,12 +117,12 @@
|
|||
<Compile Include="Source\Cloning\ExpressionTreeCloner.Test.cs">
|
||||
<DependentUpon>ExpressionTreeCloner.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Source\Cloning\ICloneFactory.cs" />
|
||||
<Compile Include="Source\Cloning\IStateCopier.cs" />
|
||||
<Compile Include="Source\Cloning\ReflectionCloner.cs" />
|
||||
<Compile Include="Source\Cloning\ReflectionCloner.Test.cs">
|
||||
<DependentUpon>ReflectionCloner.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Source\Cloning\ICloneFactory.cs" />
|
||||
<Compile Include="Source\Cloning\SerializationCloner.cs" />
|
||||
<Compile Include="Source\Cloning\SerializationCloner.Test.cs">
|
||||
<DependentUpon>SerializationCloner.cs</DependentUpon>
|
||||
|
@ -150,6 +150,10 @@
|
|||
<Compile Include="Source\Collections\ItemEventArgs.Test.cs">
|
||||
<DependentUpon>ItemEventArgs.cs</DependentUpon>
|
||||
</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.ValueCollection.cs">
|
||||
<DependentUpon>MultiDictionary.cs</DependentUpon>
|
||||
|
@ -172,6 +176,10 @@
|
|||
<Compile Include="Source\Collections\ObservableList.Test.cs">
|
||||
<DependentUpon>ObservableList.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>PairPriorityQueue.cs</DependentUpon>
|
||||
|
@ -208,6 +216,10 @@
|
|||
<Compile Include="Source\Collections\ReadOnlyList.Test.cs">
|
||||
<DependentUpon>ReadOnlyList.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>ReverseComparer.cs</DependentUpon>
|
||||
|
@ -225,34 +237,6 @@
|
|||
<Compile Include="Source\Semaphore.Test.cs">
|
||||
<DependentUpon>Semaphore.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>PartialStream.cs</DependentUpon>
|
||||
|
@ -338,10 +322,6 @@
|
|||
<Compile Include="Source\Plugins\PluginRepository.Test.cs">
|
||||
<DependentUpon>PluginRepository.cs</DependentUpon>
|
||||
</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.Test.cs">
|
||||
<DependentUpon>Shared.cs</DependentUpon>
|
||||
|
@ -374,16 +354,16 @@
|
|||
<DependentUpon>XmlHelper.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Documents\CommandLine.txt" />
|
||||
<Content Include="Documents\Nuclex.Support.txt" />
|
||||
<Content Include="Documents\Request Framework.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Foundation.snk">
|
||||
<Link>Foundation.snk</Link>
|
||||
</None>
|
||||
</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="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
|
||||
<!--
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class AffineThreadPoolTest {
|
||||
internal class AffineThreadPoolTest {
|
||||
|
||||
#region class TestTask
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
/// <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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -24,15 +24,15 @@ using System.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>
|
||||
/// <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) {
|
||||
--this.firstBlockStartIndex;
|
||||
} 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;
|
||||
}
|
||||
|
||||
|
@ -45,11 +45,11 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
/// <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>
|
||||
public void AddLast(ItemType item) {
|
||||
public void AddLast(TItem item) {
|
||||
if(this.lastBlockEndIndex < this.blockSize) {
|
||||
++this.lastBlockEndIndex;
|
||||
} else { // Need to allocate a new block
|
||||
this.blocks.Add(new ItemType[this.blockSize]);
|
||||
this.blocks.Add(new TItem[this.blockSize]);
|
||||
this.lastBlockEndIndex = 1;
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>Inserts the item at the specified index</summary>
|
||||
/// <param name="index">Index the item will be inserted at</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;
|
||||
if(index < distanceToRightEnd) { // Are we closer to the left end?
|
||||
shiftLeftAndInsert(index, item);
|
||||
|
@ -81,7 +81,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// </summary>
|
||||
/// <param name="index">Index the item will be inserted at</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) {
|
||||
AddFirst(item);
|
||||
} else {
|
||||
|
@ -93,7 +93,7 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
// If the first block is full, we need to add another block
|
||||
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.firstBlockStartIndex = this.blockSize - 1;
|
||||
|
||||
|
@ -155,7 +155,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// </summary>
|
||||
/// <param name="index">Index the item will be inserted at</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) {
|
||||
AddLast(item);
|
||||
} else {
|
||||
|
@ -167,7 +167,7 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
// If the lastmost block is full, we need to add another block
|
||||
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.lastBlockEndIndex = 1;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -24,7 +24,7 @@ using System.Collections;
|
|||
|
||||
namespace Nuclex.Support.Collections {
|
||||
|
||||
partial class Deque<ItemType> {
|
||||
partial class Deque<TItem> {
|
||||
|
||||
#region IEnumerable members
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace Nuclex.Support.Collections {
|
|||
int IList.Add(object value) {
|
||||
verifyCompatibleObject(value);
|
||||
|
||||
AddLast((ItemType)value);
|
||||
AddLast((TItem)value);
|
||||
return this.count - 1;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <param name="value">Item the deque will be scanned for</param>
|
||||
/// <returns>True if the deque contained the specified item</returns>
|
||||
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>
|
||||
|
@ -60,7 +60,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <returns>The index of the specified item in the deque</returns>
|
||||
int IList.IndexOf(object value) {
|
||||
if(isCompatibleObject(value)) {
|
||||
return IndexOf((ItemType)value);
|
||||
return IndexOf((TItem)value);
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <param name="value">Item that will be inserted</param>
|
||||
void IList.Insert(int index, object value) {
|
||||
verifyCompatibleObject(value);
|
||||
Insert(index, (ItemType)value);
|
||||
Insert(index, (TItem)value);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
void IList.Remove(object value) {
|
||||
if(isCompatibleObject(value)) {
|
||||
Remove((ItemType)value);
|
||||
Remove((TItem)value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ namespace Nuclex.Support.Collections {
|
|||
get { return this[index]; }
|
||||
set {
|
||||
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>
|
||||
/// <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);
|
||||
}
|
||||
|
||||
/// <summary>Whether the collection is read-only</summary>
|
||||
bool ICollection<ItemType>.IsReadOnly {
|
||||
bool ICollection<TItem>.IsReadOnly {
|
||||
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="index">Index at which writing into the array will begin</param>
|
||||
void ICollection.CopyTo(Array array, int index) {
|
||||
if(!(array is ItemType[])) {
|
||||
if(!(array is TItem[])) {
|
||||
throw new ArgumentException("Incompatible array type", "array");
|
||||
}
|
||||
|
||||
CopyTo((ItemType[])array, index);
|
||||
CopyTo((TItem[])array, index);
|
||||
}
|
||||
|
||||
/// <summary>Whether the deque is thread-synchronized</summary>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -24,7 +24,7 @@ using System.Collections;
|
|||
|
||||
namespace Nuclex.Support.Collections {
|
||||
|
||||
partial class Deque<ItemType> {
|
||||
partial class Deque<TItem> {
|
||||
|
||||
/// <summary>Removes all items from the deque</summary>
|
||||
public void Clear() {
|
||||
|
@ -33,7 +33,7 @@ namespace Nuclex.Support.Collections {
|
|||
// Clear the items in the first block to avoid holding on to references
|
||||
// in memory unreachable to the user
|
||||
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
|
||||
|
@ -45,7 +45,7 @@ namespace Nuclex.Support.Collections {
|
|||
for(
|
||||
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>
|
||||
/// <param name="item">Item that will be removed from the deque</param>
|
||||
/// <returns>True if the item was found and removed</returns>
|
||||
public bool Remove(ItemType item) {
|
||||
public bool Remove(TItem item) {
|
||||
int index = IndexOf(item);
|
||||
if(index == -1) {
|
||||
return false;
|
||||
|
@ -83,7 +83,7 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
// This is necessary to make sure the deque doesn't hold dead objects alive
|
||||
// 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
|
||||
// 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
|
||||
// in unreachable spaces of its memory.
|
||||
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
|
||||
// not the last remaining block, remove it as well.
|
||||
|
@ -193,7 +193,7 @@ namespace Nuclex.Support.Collections {
|
|||
this.blocks.RemoveAt(0);
|
||||
this.firstBlockStartIndex = 0;
|
||||
} else {
|
||||
this.blocks[0][this.firstBlockStartIndex] = default(ItemType);
|
||||
this.blocks[0][this.firstBlockStartIndex] = default(TItem);
|
||||
++this.firstBlockStartIndex;
|
||||
}
|
||||
|
||||
|
@ -248,7 +248,7 @@ namespace Nuclex.Support.Collections {
|
|||
this.blocks.RemoveAt(lastBlock);
|
||||
this.lastBlockEndIndex = this.blockSize;
|
||||
} else {
|
||||
this.blocks[lastBlock][this.lastBlockEndIndex - 1] = default(ItemType);
|
||||
this.blocks[lastBlock][this.lastBlockEndIndex - 1] = default(TItem);
|
||||
--this.lastBlockEndIndex;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -24,17 +24,17 @@ using System.Collections;
|
|||
|
||||
namespace Nuclex.Support.Collections {
|
||||
|
||||
partial class Deque<ItemType> {
|
||||
partial class Deque<TItem> {
|
||||
|
||||
/// <summary>
|
||||
/// Determines the index of the first occurence of the specified item in the deque
|
||||
/// </summary>
|
||||
/// <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>
|
||||
public int IndexOf(ItemType item) {
|
||||
public int IndexOf(TItem item) {
|
||||
if(this.blocks.Count == 1) { // Only one block to scan?
|
||||
int length = this.lastBlockEndIndex - this.firstBlockStartIndex;
|
||||
int index = Array.IndexOf<ItemType>(
|
||||
int index = Array.IndexOf<TItem>(
|
||||
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
|
||||
int length = this.blockSize - this.firstBlockStartIndex;
|
||||
int index = Array.IndexOf<ItemType>(
|
||||
int index = Array.IndexOf<TItem>(
|
||||
this.blocks[0], item, this.firstBlockStartIndex, length
|
||||
);
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
int lastBlock = this.blocks.Count - 1;
|
||||
for(int tempIndex = 1; tempIndex < lastBlock; ++tempIndex) {
|
||||
index = Array.IndexOf<ItemType>(
|
||||
index = Array.IndexOf<TItem>(
|
||||
this.blocks[tempIndex], item, 0, this.blockSize
|
||||
);
|
||||
if(index != -1) {
|
||||
|
@ -69,7 +69,7 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
// Nothing found, continue the search in the
|
||||
index = Array.IndexOf<ItemType>(
|
||||
index = Array.IndexOf<TItem>(
|
||||
this.blocks[lastBlock], item, 0, this.lastBlockEndIndex
|
||||
);
|
||||
if(index == -1) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class DequeTest {
|
||||
internal class DequeTest {
|
||||
|
||||
/// <summary>Verifies that the AddLast() method of the deque is working</summary>
|
||||
[Test]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -25,7 +25,7 @@ using System.Collections;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <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>
|
||||
/// <para>
|
||||
/// 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.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public partial class Deque<ItemType> : IList<ItemType>, IList {
|
||||
public partial class Deque<TItem> : IList<TItem>, IList {
|
||||
|
||||
#region class Enumerator
|
||||
|
||||
/// <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>
|
||||
/// <param name="deque">Deque whose items will be enumerated</param>
|
||||
public Enumerator(Deque<ItemType> deque) {
|
||||
public Enumerator(Deque<TItem> deque) {
|
||||
this.deque = deque;
|
||||
this.blockSize = this.deque.blockSize;
|
||||
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>
|
||||
public ItemType Current {
|
||||
public TItem Current {
|
||||
get {
|
||||
#if DEBUG
|
||||
checkVersion();
|
||||
|
@ -143,7 +143,7 @@ namespace Nuclex.Support.Collections {
|
|||
#endif
|
||||
|
||||
/// <summary>Deque the enumerator belongs to</summary>
|
||||
private Deque<ItemType> deque;
|
||||
private Deque<TItem> deque;
|
||||
/// <summary>Size of the blocks in the deque</summary>
|
||||
private int blockSize;
|
||||
/// <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>
|
||||
private int currentBlockIndex;
|
||||
/// <summary>Reference to the block being enumerated</summary>
|
||||
private ItemType[] currentBlock;
|
||||
private TItem[] currentBlock;
|
||||
/// <summary>Index in the current block</summary>
|
||||
private int subIndex;
|
||||
#if DEBUG
|
||||
|
@ -173,8 +173,8 @@ namespace Nuclex.Support.Collections {
|
|||
public Deque(int blockSize) {
|
||||
this.blockSize = blockSize;
|
||||
|
||||
this.blocks = new List<ItemType[]>();
|
||||
this.blocks.Add(new ItemType[this.blockSize]);
|
||||
this.blocks = new List<TItem[]>();
|
||||
this.blocks.Add(new TItem[this.blockSize]);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="index">Index of the item that will be accessed</param>
|
||||
/// <returns>The item at the specified index</returns>
|
||||
public ItemType this[int index] {
|
||||
public TItem this[int index] {
|
||||
get {
|
||||
int blockIndex, 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>
|
||||
public ItemType First {
|
||||
public TItem First {
|
||||
get {
|
||||
if (this.count == 0) {
|
||||
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>
|
||||
public ItemType Last {
|
||||
public TItem Last {
|
||||
get {
|
||||
if (this.count == 0) {
|
||||
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>
|
||||
/// <param name="item">Item the deque will be scanned for</param>
|
||||
/// <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);
|
||||
}
|
||||
|
||||
/// <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="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)) {
|
||||
throw new ArgumentException(
|
||||
"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>
|
||||
/// <returns>The new enumerator</returns>
|
||||
public IEnumerator<ItemType> GetEnumerator() {
|
||||
public IEnumerator<TItem> GetEnumerator() {
|
||||
return new Enumerator(this);
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <param name="value">Value that will be checked for compatibility</param>
|
||||
/// <returns>True if the value can be placed in the deque</returns>
|
||||
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>
|
||||
|
@ -324,7 +324,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>Size of a single deque block</summary>
|
||||
private int blockSize;
|
||||
/// <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>
|
||||
private int firstBlockStartIndex;
|
||||
/// <summary>End index of data in the last block</summary>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -25,14 +25,19 @@ using System.Collections.ObjectModel;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <summary>Interface for collections that can be observed</summary>
|
||||
/// <typeparam name="ItemType">Type of items managed in the collection</typeparam>
|
||||
public interface IObservableCollection<ItemType> {
|
||||
/// <typeparam name="TItem">Type of items managed in the collection</typeparam>
|
||||
public interface IObservableCollection<TItem> {
|
||||
|
||||
/// <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>
|
||||
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>
|
||||
/// <remarks>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ItemEventArgsTest {
|
||||
internal class ItemEventArgsTest {
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether an integer argument can be stored in the argument container
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestIntegerArgument() {
|
||||
ItemEventArgs<int> test = new ItemEventArgs<int>(12345);
|
||||
public void IntegersCanBeCarried() {
|
||||
var test = new ItemEventArgs<int>(12345);
|
||||
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
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestStringArgument() {
|
||||
ItemEventArgs<string> test = new ItemEventArgs<string>("hello world");
|
||||
public void StringsCanBeCarried() {
|
||||
var test = new ItemEventArgs<string>("hello world");
|
||||
Assert.AreEqual("hello world", test.Item);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -24,23 +24,23 @@ using System.Collections.Generic;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <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>
|
||||
public class ItemEventArgs<ItemType> : EventArgs {
|
||||
public class ItemEventArgs<TItem> : EventArgs {
|
||||
|
||||
/// <summary>Initializes a new event arguments supplier</summary>
|
||||
/// <param name="item">Item to be supplied to the event handler</param>
|
||||
public ItemEventArgs(ItemType item) {
|
||||
public ItemEventArgs(TItem item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/// <summary>Obtains the collection item the event arguments are carrying</summary>
|
||||
public ItemType Item {
|
||||
public TItem Item {
|
||||
get { return this.item; }
|
||||
}
|
||||
|
||||
/// <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
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class MultiDictionaryTest {
|
||||
internal class MultiDictionaryTest {
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that new instances of the multi dictionary can be created
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ObservableCollectionTest {
|
||||
internal class ObservableCollectionTest {
|
||||
|
||||
#region interface IObservableCollectionSubscriber
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ObservableDictionaryTest {
|
||||
internal class ObservableDictionaryTest {
|
||||
|
||||
#region interface IObservableDictionarySubscriber
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ObservableListTest {
|
||||
internal class ObservableListTest {
|
||||
|
||||
#region interface IObservableCollectionSubscriber
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class PairPriorityQueueTest {
|
||||
internal class PairPriorityQueueTest {
|
||||
|
||||
/// <summary>Tests to ensure the count property is properly updated</summary>
|
||||
[Test]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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
|
||||
/// even
|
||||
/// </remarks>
|
||||
public class PairPriorityQueue<PriorityType, ItemType>
|
||||
: ICollection, IEnumerable<PriorityItemPair<PriorityType, ItemType>> {
|
||||
public class PairPriorityQueue<TPriority, TItem>
|
||||
: ICollection, IEnumerable<PriorityItemPair<TPriority, TItem>> {
|
||||
|
||||
#region class PairComparer
|
||||
|
||||
/// <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>
|
||||
/// <param name="priorityComparer">Comparer used to compare entry priorities</param>
|
||||
public PairComparer(IComparer<PriorityType> priorityComparer) {
|
||||
public PairComparer(IComparer<TPriority> priorityComparer) {
|
||||
this.priorityComparer = priorityComparer;
|
||||
}
|
||||
|
||||
|
@ -49,48 +49,48 @@ namespace Nuclex.Support.Collections {
|
|||
/// <param name="right">Entry on the right side</param>
|
||||
/// <returns>The relationship of the two entries</returns>
|
||||
public int Compare(
|
||||
PriorityItemPair<PriorityType, ItemType> left,
|
||||
PriorityItemPair<PriorityType, ItemType> right
|
||||
PriorityItemPair<TPriority, TItem> left,
|
||||
PriorityItemPair<TPriority, TItem> right
|
||||
) {
|
||||
return this.priorityComparer.Compare(left.Priority, right.Priority);
|
||||
}
|
||||
|
||||
/// <summary>Comparer used to compare the priorities of the entries</summary>
|
||||
private IComparer<PriorityType> priorityComparer;
|
||||
private IComparer<TPriority> priorityComparer;
|
||||
|
||||
}
|
||||
|
||||
#endregion // class EntryComparer
|
||||
|
||||
/// <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>
|
||||
/// <param name="priorityComparer">Comparer used to compare the item priorities</param>
|
||||
public PairPriorityQueue(IComparer<PriorityType> priorityComparer) {
|
||||
this.internalQueue = new PriorityQueue<PriorityItemPair<PriorityType, ItemType>>(
|
||||
public PairPriorityQueue(IComparer<TPriority> priorityComparer) {
|
||||
this.internalQueue = new PriorityQueue<PriorityItemPair<TPriority, TItem>>(
|
||||
new PairComparer(priorityComparer)
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>Returns the topmost item in the queue without dequeueing it</summary>
|
||||
/// <returns>The topmost item in the queue</returns>
|
||||
public PriorityItemPair<PriorityType, ItemType> Peek() {
|
||||
public PriorityItemPair<TPriority, TItem> Peek() {
|
||||
return this.internalQueue.Peek();
|
||||
}
|
||||
|
||||
/// <summary>Takes the item with the highest priority off from the queue</summary>
|
||||
/// <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();
|
||||
}
|
||||
|
||||
/// <summary>Puts an item into the priority queue</summary>
|
||||
/// <param name="priority">Priority of the 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(
|
||||
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>
|
||||
/// <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();
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
/// <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
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ParentableTest {
|
||||
internal class ParentableTest {
|
||||
|
||||
#region class TestParentable
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ParentingCollectionTest {
|
||||
internal class ParentingCollectionTest {
|
||||
|
||||
#region class TestParentable
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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<>
|
||||
/// base class.
|
||||
/// </remarks>
|
||||
/// <typeparam name="ParentType">Type of the parent object to assign to items</typeparam>
|
||||
/// <typeparam name="ItemType">Type of the items being managed in the collection</typeparam>
|
||||
public class ParentingCollection<ParentType, ItemType> : Collection<ItemType>
|
||||
where ItemType : Parentable<ParentType> {
|
||||
/// <typeparam name="TParent">Type of the parent object to assign to items</typeparam>
|
||||
/// <typeparam name="TItem">Type of the items being managed in the collection</typeparam>
|
||||
public class ParentingCollection<TParent, TItem> : Collection<TItem>
|
||||
where TItem : Parentable<TParent> {
|
||||
|
||||
/// <summary>Reparents all elements in the collection</summary>
|
||||
/// <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;
|
||||
|
||||
for(int index = 0; index < Count; ++index)
|
||||
|
@ -49,7 +49,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>Clears all elements from the collection</summary>
|
||||
protected override void ClearItems() {
|
||||
for(int index = 0; index < Count; ++index)
|
||||
base[index].SetParent(default(ParentType));
|
||||
base[index].SetParent(default(TParent));
|
||||
|
||||
base.ClearItems();
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>Inserts a new element into the collection</summary>
|
||||
/// <param name="index">Index at which to insert the element</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);
|
||||
item.SetParent(this.parent);
|
||||
}
|
||||
|
@ -65,15 +65,15 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>Removes an element from the collection</summary>
|
||||
/// <param name="index">Index of the element to remove</param>
|
||||
protected override void RemoveItem(int index) {
|
||||
base[index].SetParent(default(ParentType));
|
||||
base[index].SetParent(default(TParent));
|
||||
base.RemoveItem(index);
|
||||
}
|
||||
|
||||
/// <summary>Takes over a new element that is directly assigned</summary>
|
||||
/// <param name="index">Index of the element that was assigned</param>
|
||||
/// <param name="item">New item</param>
|
||||
protected override void SetItem(int index, ItemType item) {
|
||||
base[index].SetParent(default(ParentType));
|
||||
protected override void SetItem(int index, TItem item) {
|
||||
base[index].SetParent(default(TParent));
|
||||
base.SetItem(index, item);
|
||||
item.SetParent(this.parent);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
/// <summary>Parent this collection currently belongs to</summary>
|
||||
private ParentType parent;
|
||||
private TParent parent;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class PoolTest {
|
||||
internal class PoolTest {
|
||||
|
||||
#region class TestClass
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -25,7 +25,7 @@ using System.Text;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <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>
|
||||
/// <para>
|
||||
/// 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.
|
||||
/// </para>
|
||||
/// </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>
|
||||
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
|
||||
/// </summary>
|
||||
/// <returns>A new or recycled instance</returns>
|
||||
public ItemType Get() {
|
||||
public TItem Get() {
|
||||
lock(this) {
|
||||
if(this.items.Count > 0) {
|
||||
return this.items.Dequeue();
|
||||
} 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
|
||||
/// </summary>
|
||||
/// <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
|
||||
// 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; }
|
||||
set {
|
||||
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">
|
||||
/// Object whose Recycle() method will be called if supported by the object
|
||||
/// </param>
|
||||
private static void callRecycleIfSupported(ItemType item) {
|
||||
private static void callRecycleIfSupported(TItem item) {
|
||||
IRecyclable recycleable = item as IRecyclable;
|
||||
if(recycleable != null) {
|
||||
recycleable.Recycle();
|
||||
|
@ -119,7 +119,7 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
/// <summary>Objects being retained for recycling</summary>
|
||||
private Queue<ItemType> items;
|
||||
private Queue<TItem> items;
|
||||
/// <summary>Capacity of the pool</summary>
|
||||
/// <remarks>
|
||||
/// Required because the Queue class doesn't allow this value to be retrieved
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class PriorityItemPairTest {
|
||||
internal class PriorityItemPairTest {
|
||||
|
||||
#region class ToStringNullReturner
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -25,20 +25,20 @@ using System.Text;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <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>
|
||||
/// <param name="priority">Priority of the item 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.Item = item;
|
||||
}
|
||||
|
||||
/// <summary>Priority assigned to this priority / item pair</summary>
|
||||
public PriorityType Priority;
|
||||
public TPriority Priority;
|
||||
/// <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>
|
||||
/// <returns>A string describing the priority / item pair</returns>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class PriorityQueueTest {
|
||||
internal class PriorityQueueTest {
|
||||
|
||||
#region class FloatComparer
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -25,16 +25,16 @@ using System.Collections;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <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
|
||||
|
||||
/// <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>
|
||||
/// <param name="priorityQueue">Priority queue to be enumerated</param>
|
||||
public Enumerator(PriorityQueue<ItemType> priorityQueue) {
|
||||
public Enumerator(PriorityQueue<TItem> priorityQueue) {
|
||||
this.priorityQueue = priorityQueue;
|
||||
Reset();
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
/// <summary>The current item being enumerated</summary>
|
||||
ItemType IEnumerator<ItemType>.Current {
|
||||
TItem IEnumerator<TItem>.Current {
|
||||
get {
|
||||
#if DEBUG
|
||||
checkVersion();
|
||||
|
@ -95,7 +95,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>Index of the current item in the priority queue</summary>
|
||||
private int index;
|
||||
/// <summary>The priority queue whose items this instance enumerates</summary>
|
||||
private PriorityQueue<ItemType> priorityQueue;
|
||||
private PriorityQueue<TItem> priorityQueue;
|
||||
#if DEBUG
|
||||
/// <summary>Expected version of the priority queue</summary>
|
||||
private int expectedVersion;
|
||||
|
@ -108,19 +108,19 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>
|
||||
/// Initializes a new priority queue using IComparable for comparing items
|
||||
/// </summary>
|
||||
public PriorityQueue() : this(Comparer<ItemType>.Default) { }
|
||||
public PriorityQueue() : this(Comparer<TItem>.Default) { }
|
||||
|
||||
/// <summary>Initializes a new priority queue</summary>
|
||||
/// <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.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>
|
||||
/// <returns>The topmost item in the queue</returns>
|
||||
public ItemType Peek() {
|
||||
public TItem Peek() {
|
||||
if(this.count == 0) {
|
||||
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>
|
||||
/// <returns>The item with the highest priority in the list</returns>
|
||||
/// <exception cref="InvalidOperationException">When the queue is empty</exception>
|
||||
public ItemType Dequeue() {
|
||||
public TItem Dequeue() {
|
||||
if(this.count == 0) {
|
||||
throw new InvalidOperationException("No items available to dequeue");
|
||||
}
|
||||
|
||||
ItemType result = this.heap[0];
|
||||
TItem result = this.heap[0];
|
||||
--this.count;
|
||||
trickleDown(0, this.heap[this.count]);
|
||||
#if DEBUG
|
||||
|
@ -147,7 +147,7 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
/// <summary>Puts an item into the priority queue</summary>
|
||||
/// <param name="item">Item to be queued</param>
|
||||
public void Enqueue(ItemType item) {
|
||||
public void Enqueue(TItem item) {
|
||||
if(this.count == capacity)
|
||||
growHeap();
|
||||
|
||||
|
@ -194,14 +194,14 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
/// <summary>Returns a typesafe enumerator for the priority queue</summary>
|
||||
/// <returns>A new enumerator for the priority queue</returns>
|
||||
public IEnumerator<ItemType> GetEnumerator() {
|
||||
public IEnumerator<TItem> GetEnumerator() {
|
||||
return new Enumerator(this);
|
||||
}
|
||||
|
||||
/// <summary>Moves an item upwards in the heap tree</summary>
|
||||
/// <param name="index">Index of the 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);
|
||||
|
||||
// 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>
|
||||
/// <param name="index">Index of the 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);
|
||||
|
||||
while(child < this.count) {
|
||||
|
@ -256,7 +256,7 @@ namespace Nuclex.Support.Collections {
|
|||
private void growHeap() {
|
||||
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);
|
||||
this.heap = newHeap;
|
||||
}
|
||||
|
@ -268,13 +268,13 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
/// <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>
|
||||
private int count;
|
||||
/// <summary>Available space in the priority queue</summary>
|
||||
private int capacity;
|
||||
/// <summary>Tree containing the items in the priority queue</summary>
|
||||
private ItemType[] heap;
|
||||
private TItem[] heap;
|
||||
#if DEBUG
|
||||
/// <summary>Incremented whenever the priority queue is modified</summary>
|
||||
private int version;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ReadOnlyCollectionTest {
|
||||
internal class ReadOnlyCollectionTest {
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the copy constructor of the read only collection works
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -25,14 +25,14 @@ using System.Collections.Generic;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <summary>Wraps a Collection and prevents users from modifying it</summary>
|
||||
/// <typeparam name="ItemType">Type of items to manage in the Collection</typeparam>
|
||||
public class ReadOnlyCollection<ItemType> :
|
||||
ICollection<ItemType>,
|
||||
/// <typeparam name="TItem">Type of items to manage in the Collection</typeparam>
|
||||
public class ReadOnlyCollection<TItem> :
|
||||
ICollection<TItem>,
|
||||
ICollection {
|
||||
|
||||
/// <summary>Initializes a new read-only Collection wrapper</summary>
|
||||
/// <param name="collection">Collection that will be wrapped</param>
|
||||
public ReadOnlyCollection(ICollection<ItemType> collection) {
|
||||
public ReadOnlyCollection(ICollection<TItem> collection) {
|
||||
this.typedCollection = collection;
|
||||
this.objectCollection = (collection as ICollection);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <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(ItemType item) {
|
||||
public bool Contains(TItem item) {
|
||||
return this.typedCollection.Contains(item);
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <param name="arrayIndex">
|
||||
/// Starting index at which to begin filling the destination array
|
||||
/// </param>
|
||||
public void CopyTo(ItemType[] array, int arrayIndex) {
|
||||
public void CopyTo(TItem[] array, int 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>
|
||||
/// <returns>The new List contents enumerator</returns>
|
||||
public IEnumerator<ItemType> GetEnumerator() {
|
||||
public IEnumerator<TItem> GetEnumerator() {
|
||||
return this.typedCollection.GetEnumerator();
|
||||
}
|
||||
|
||||
|
@ -73,14 +73,14 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
/// <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<ItemType>.Add(ItemType item) {
|
||||
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<ItemType>.Clear() {
|
||||
void ICollection<TItem>.Clear() {
|
||||
throw new NotSupportedException(
|
||||
"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>
|
||||
/// <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<ItemType>.Remove(ItemType item) {
|
||||
bool ICollection<TItem>.Remove(TItem item) {
|
||||
throw new NotSupportedException(
|
||||
"Removing items is not supported by the read-only List"
|
||||
);
|
||||
|
@ -131,7 +131,7 @@ namespace Nuclex.Support.Collections {
|
|||
#endregion
|
||||
|
||||
/// <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>
|
||||
private ICollection objectCollection;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ReadOnlyDictionaryTest {
|
||||
internal class ReadOnlyDictionaryTest {
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the copy constructor of the read only dictionary works
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ReadOnlyListTest {
|
||||
internal class ReadOnlyListTest {
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the copy constructor of the read only list works
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -25,14 +25,12 @@ using System.Collections.Generic;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <summary>Wraps a List and prevents users from modifying it</summary>
|
||||
/// <typeparam name="ItemType">Type of items to manage in the List</typeparam>
|
||||
public class ReadOnlyList<ItemType> :
|
||||
IList<ItemType>,
|
||||
IList {
|
||||
/// <typeparam name="TItem">Type of items to manage in the List</typeparam>
|
||||
public class ReadOnlyList<TItem> : IList<TItem>, IList {
|
||||
|
||||
/// <summary>Initializes a new read-only List wrapper</summary>
|
||||
/// <param name="list">List that will be wrapped</param>
|
||||
public ReadOnlyList(IList<ItemType> list) {
|
||||
public ReadOnlyList(IList<TItem> list) {
|
||||
this.typedList = list;
|
||||
this.objectList = (list as IList);
|
||||
}
|
||||
|
@ -40,20 +38,20 @@ namespace Nuclex.Support.Collections {
|
|||
/// <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(ItemType item) {
|
||||
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 ItemType this[int index] {
|
||||
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(ItemType item) {
|
||||
public bool Contains(TItem item) {
|
||||
return this.typedList.Contains(item);
|
||||
}
|
||||
|
||||
|
@ -62,7 +60,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <param name="arrayIndex">
|
||||
/// Starting index at which to begin filling the destination array
|
||||
/// </param>
|
||||
public void CopyTo(ItemType[] array, int arrayIndex) {
|
||||
public void CopyTo(TItem[] array, int 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>
|
||||
/// <returns>The new List contents enumerator</returns>
|
||||
public IEnumerator<ItemType> GetEnumerator() {
|
||||
public IEnumerator<TItem> GetEnumerator() {
|
||||
return this.typedList.GetEnumerator();
|
||||
}
|
||||
|
||||
|
@ -87,7 +85,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <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<ItemType>.Insert(int index, ItemType item) {
|
||||
void IList<TItem>.Insert(int index, TItem item) {
|
||||
throw new NotSupportedException(
|
||||
"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>
|
||||
/// <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(
|
||||
"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>
|
||||
/// <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]; }
|
||||
set {
|
||||
throw new NotSupportedException(
|
||||
|
@ -118,14 +116,14 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
/// <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<ItemType>.Add(ItemType item) {
|
||||
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<ItemType>.Clear() {
|
||||
void ICollection<TItem>.Clear() {
|
||||
throw new NotSupportedException(
|
||||
"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>
|
||||
/// <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<ItemType>.Remove(ItemType item) {
|
||||
bool ICollection<TItem>.Remove(TItem item) {
|
||||
throw new NotSupportedException(
|
||||
"Removing items is not supported by the read-only List"
|
||||
);
|
||||
|
@ -251,7 +249,7 @@ namespace Nuclex.Support.Collections {
|
|||
#endregion
|
||||
|
||||
/// <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>
|
||||
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
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ReverseComparerTest {
|
||||
internal class ReverseComparerTest {
|
||||
|
||||
#region class FortyTwoComparer
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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
|
||||
// an inferior design to make collections "more convenient" for the user :/
|
||||
|
||||
partial class TransformingReadOnlyCollection<
|
||||
ContainedItemType, ExposedItemType
|
||||
> {
|
||||
partial class TransformingReadOnlyCollection<TContainedItem, TExposedItem> {
|
||||
|
||||
#region IList<ExposedItemType> Members
|
||||
#region IList<TExposedItem> Members
|
||||
|
||||
/// <summary>
|
||||
/// Inserts an item to the TransformingReadOnlyCollection at the specified index.
|
||||
|
@ -50,7 +48,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// index is not a valid index in the TransformingReadOnlyCollection.
|
||||
/// </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");
|
||||
}
|
||||
|
||||
|
@ -64,7 +62,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// Index is not a valid index in the TransformingReadOnlyCollection.
|
||||
/// </exception>
|
||||
void IList<ExposedItemType>.RemoveAt(int index) {
|
||||
void IList<TExposedItem>.RemoveAt(int index) {
|
||||
throw new NotSupportedException("The collection is ready-only");
|
||||
}
|
||||
|
||||
|
@ -77,7 +75,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <exception cref="System.NotSupportedException">
|
||||
/// The property is set and the TransformingReadOnlyCollection is read-only
|
||||
/// </exception>
|
||||
ExposedItemType IList<ExposedItemType>.this[int index] {
|
||||
TExposedItem IList<TExposedItem>.this[int index] {
|
||||
get {
|
||||
return this[index];
|
||||
}
|
||||
|
@ -88,14 +86,14 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
#endregion
|
||||
|
||||
#region ICollection<ExposedItemType> Members
|
||||
#region ICollection<TExposedItem> Members
|
||||
|
||||
/// <summary>Adds an item to the TransformingReadOnlyCollection.</summary>
|
||||
/// <param name="item">The object to add to the TransformingReadOnlyCollection</param>
|
||||
/// <exception cref="System.NotSupportedException">
|
||||
/// The TransformingReadOnlyCollection is read-only.
|
||||
/// </exception>
|
||||
void ICollection<ExposedItemType>.Add(ExposedItemType item) {
|
||||
void ICollection<TExposedItem>.Add(TExposedItem item) {
|
||||
throw new NotSupportedException("The collection is ready-only");
|
||||
}
|
||||
|
||||
|
@ -103,7 +101,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <exception cref="System.NotSupportedException">
|
||||
/// The TransformingReadOnlyCollection is read-only.
|
||||
/// </exception>
|
||||
void ICollection<ExposedItemType>.Clear() {
|
||||
void ICollection<TExposedItem>.Clear() {
|
||||
throw new NotSupportedException("The collection is ready-only");
|
||||
}
|
||||
|
||||
|
@ -122,7 +120,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <exception cref="System.NotSupportedException">
|
||||
/// The TransformingReadOnlyCollection is read-only.
|
||||
/// </exception>
|
||||
bool ICollection<ExposedItemType>.Remove(ExposedItemType item) {
|
||||
bool ICollection<TExposedItem>.Remove(TExposedItem item) {
|
||||
throw new NotSupportedException("The collection is ready-only");
|
||||
}
|
||||
|
||||
|
@ -175,7 +173,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// otherwise, false.
|
||||
/// </returns>
|
||||
bool IList.Contains(object value) {
|
||||
return Contains((ExposedItemType)value);
|
||||
return Contains((TExposedItem)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -188,7 +186,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// The index of value if found in the list; otherwise, -1.
|
||||
/// </returns>
|
||||
int IList.IndexOf(object value) {
|
||||
return IndexOf((ExposedItemType)value);
|
||||
return IndexOf((TExposedItem)value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -301,7 +299,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// automatically to the type of the destination array.
|
||||
/// </exception>
|
||||
void ICollection.CopyTo(Array array, int index) {
|
||||
CopyTo((ExposedItemType[])array, index);
|
||||
CopyTo((TExposedItem[])array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class TransformingReadOnlyCollectionTest {
|
||||
internal class TransformingReadOnlyCollectionTest {
|
||||
|
||||
#region class StringTransformer
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -26,10 +26,10 @@ using System.Collections.ObjectModel;
|
|||
namespace Nuclex.Support.Collections {
|
||||
|
||||
/// <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.
|
||||
/// </typeparam>
|
||||
/// <typeparam name="ExposedItemType">
|
||||
/// <typeparam name="TExposedItem">
|
||||
/// Type this collection exposes its items as.
|
||||
/// </typeparam>
|
||||
/// <remarks>
|
||||
|
@ -49,8 +49,8 @@ namespace Nuclex.Support.Collections {
|
|||
/// </para>
|
||||
/// </remarks>
|
||||
public abstract partial class TransformingReadOnlyCollection<
|
||||
ContainedItemType, ExposedItemType
|
||||
> : IList<ExposedItemType>, IList {
|
||||
TContainedItem, TExposedItem
|
||||
> : IList<TExposedItem>, IList {
|
||||
|
||||
#region class TransformingEnumerator
|
||||
|
||||
|
@ -58,14 +58,14 @@ namespace Nuclex.Support.Collections {
|
|||
/// An enumerator that transforms the items returned by an enumerator of the
|
||||
/// wrapped collection into the exposed type on-the-fly.
|
||||
/// </summary>
|
||||
private class TransformingEnumerator : IEnumerator<ExposedItemType> {
|
||||
private class TransformingEnumerator : IEnumerator<TExposedItem> {
|
||||
|
||||
/// <summary>Initializes a new transforming enumerator</summary>
|
||||
/// <param name="transformer">Owner; used to invoke the Transform() method</param>
|
||||
/// <param name="containedTypeEnumerator">Enumerator of the wrapped collection</param>
|
||||
public TransformingEnumerator(
|
||||
TransformingReadOnlyCollection<ContainedItemType, ExposedItemType> transformer,
|
||||
IEnumerator<ContainedItemType> containedTypeEnumerator
|
||||
TransformingReadOnlyCollection<TContainedItem, TExposedItem> transformer,
|
||||
IEnumerator<TContainedItem> containedTypeEnumerator
|
||||
) {
|
||||
this.transformer = transformer;
|
||||
this.containedTypeEnumerator = containedTypeEnumerator;
|
||||
|
@ -79,7 +79,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>
|
||||
/// The element in the collection at the current position of the enumerator.
|
||||
/// </summary>
|
||||
public ExposedItemType Current {
|
||||
public TExposedItem Current {
|
||||
get {
|
||||
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
|
||||
/// transformation method.
|
||||
/// </summary>
|
||||
private TransformingReadOnlyCollection<ContainedItemType, ExposedItemType> transformer;
|
||||
private TransformingReadOnlyCollection<TContainedItem, TExposedItem> transformer;
|
||||
/// <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
|
||||
/// accessed through the TransformingReadOnlyCollection.
|
||||
/// </param>
|
||||
public TransformingReadOnlyCollection(IList<ContainedItemType> items) {
|
||||
public TransformingReadOnlyCollection(IList<TContainedItem> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// looking for. It is recommended to provide a custom implementation of
|
||||
/// this method, if possible.
|
||||
/// </remarks>
|
||||
public virtual bool Contains(ExposedItemType item) {
|
||||
public virtual bool Contains(TExposedItem item) {
|
||||
return (IndexOf(item) != -1);
|
||||
}
|
||||
|
||||
|
@ -180,7 +180,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <exception cref="System.ArgumentNullException">
|
||||
/// Array is null.
|
||||
/// </exception>
|
||||
public void CopyTo(ExposedItemType[] array, int index) {
|
||||
public void CopyTo(TExposedItem[] array, int index) {
|
||||
if(this.items.Count > (array.Length - index)) {
|
||||
throw new ArgumentException(
|
||||
"Array too small to fit the collection items starting at the specified index"
|
||||
|
@ -198,7 +198,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <returns>
|
||||
/// An enumerator or the TransformingReadOnlyCollection.
|
||||
/// </returns>
|
||||
public IEnumerator<ExposedItemType> GetEnumerator() {
|
||||
public IEnumerator<TExposedItem> 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
|
||||
/// this method, if possible.
|
||||
/// </remarks>
|
||||
public int IndexOf(ExposedItemType item) {
|
||||
public int IndexOf(TExposedItem item) {
|
||||
|
||||
if(item == null) {
|
||||
|
||||
|
@ -233,9 +233,7 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
} else {
|
||||
|
||||
EqualityComparer<ExposedItemType> comparer =
|
||||
EqualityComparer<ExposedItemType>.Default;
|
||||
|
||||
var comparer = EqualityComparer<TExposedItem>.Default;
|
||||
for(int index = 0; index < this.items.Count; ++index) {
|
||||
if(comparer.Equals(Transform(this.items[index]), item)) {
|
||||
return index;
|
||||
|
@ -262,7 +260,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// Index is less than zero or index is equal to or greater than
|
||||
/// TransformingReadOnlyCollection.Count.
|
||||
/// </exception>
|
||||
public ExposedItemType this[int index] {
|
||||
public TExposedItem this[int index] {
|
||||
get { return Transform(this.items[index]); }
|
||||
}
|
||||
|
||||
|
@ -280,10 +278,10 @@ namespace Nuclex.Support.Collections {
|
|||
/// be called frequently, because the TransformingReadOnlyCollection does
|
||||
/// not cache or otherwise store the transformed items.
|
||||
/// </remarks>
|
||||
protected abstract ExposedItemType Transform(ContainedItemType item);
|
||||
protected abstract TExposedItem Transform(TContainedItem item);
|
||||
|
||||
/// <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>
|
||||
private object syncRoot;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
@ -25,7 +25,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Nuclex.Support.Collections {
|
||||
|
||||
partial class WeakCollection<ItemType> {
|
||||
partial class WeakCollection<TItem> {
|
||||
|
||||
#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.
|
||||
/// </exception>
|
||||
int IList.Add(object value) {
|
||||
ItemType valueAsItemType = downcastToItemType(value);
|
||||
return (this.items as IList).Add(new WeakReference<ItemType>(valueAsItemType));
|
||||
TItem valueAsItemType = downcastToItemType(value);
|
||||
return (this.items as IList).Add(new WeakReference<TItem>(valueAsItemType));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -61,7 +61,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// True if the System.Object is found in the WeakCollection; otherwise, false.
|
||||
/// </returns>
|
||||
bool IList.Contains(object value) {
|
||||
ItemType valueAsItemType = downcastToItemType(value);
|
||||
TItem valueAsItemType = downcastToItemType(value);
|
||||
return Contains(valueAsItemType);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// The index of value if found in the list; otherwise, -1.
|
||||
/// </returns>
|
||||
int IList.IndexOf(object value) {
|
||||
ItemType valueAsItemType = downcastToItemType(value);
|
||||
TItem valueAsItemType = downcastToItemType(value);
|
||||
return IndexOf(valueAsItemType);
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// Value is null reference in the WeakCollection.
|
||||
/// </exception>
|
||||
void IList.Insert(int index, object value) {
|
||||
ItemType valueAsItemType = downcastToItemType(value);
|
||||
TItem valueAsItemType = downcastToItemType(value);
|
||||
Insert(index, valueAsItemType);
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// The WeakCollection is read-only or the WeakCollection has a fixed size.
|
||||
/// </exception>
|
||||
void IList.Remove(object value) {
|
||||
ItemType valueAsItemType = downcastToItemType(value);
|
||||
TItem valueAsItemType = downcastToItemType(value);
|
||||
Remove(valueAsItemType);
|
||||
}
|
||||
|
||||
|
@ -124,7 +124,7 @@ namespace Nuclex.Support.Collections {
|
|||
object IList.this[int index] {
|
||||
get { return this[index]; }
|
||||
set {
|
||||
ItemType valueAsItemType = downcastToItemType(value);
|
||||
TItem valueAsItemType = downcastToItemType(value);
|
||||
this[index] = valueAsItemType;
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// the destination array.
|
||||
/// </exception>
|
||||
void ICollection.CopyTo(Array array, int index) {
|
||||
CopyTo((ItemType[])array, index);
|
||||
CopyTo((TItem[])array, index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -196,8 +196,8 @@ namespace Nuclex.Support.Collections {
|
|||
/// <returns>
|
||||
/// The specified object referecne as a reference to the collection's item type
|
||||
/// </returns>
|
||||
private static ItemType downcastToItemType(object value) {
|
||||
ItemType valueAsItemType = value as ItemType;
|
||||
private static TItem downcastToItemType(object value) {
|
||||
TItem valueAsItemType = value as TItem;
|
||||
if(!ReferenceEquals(value, null)) {
|
||||
if(valueAsItemType == null) {
|
||||
throw new ArgumentException("Object is not of a compatible type", "value");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class WeakCollectionTest {
|
||||
internal class WeakCollectionTest {
|
||||
|
||||
#region class Dummy
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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
|
||||
/// will silently remove that item.
|
||||
/// </remarks>
|
||||
public partial class WeakCollection<ItemType> : IList<ItemType>, IList
|
||||
where ItemType : class {
|
||||
public partial class WeakCollection<TItem> : IList<TItem>, IList
|
||||
where TItem : class {
|
||||
|
||||
#region class UnpackingEnumerator
|
||||
|
||||
|
@ -41,14 +41,14 @@ namespace Nuclex.Support.Collections {
|
|||
/// An enumerator that unpacks the items returned by an enumerator of the
|
||||
/// weak reference collection into the actual item type on-the-fly.
|
||||
/// </summary>
|
||||
private class UnpackingEnumerator : IEnumerator<ItemType> {
|
||||
private class UnpackingEnumerator : IEnumerator<TItem> {
|
||||
|
||||
/// <summary>Initializes a new unpacking enumerator</summary>
|
||||
/// <param name="containedTypeEnumerator">
|
||||
/// Enumerator of the weak reference collection
|
||||
/// </param>
|
||||
public UnpackingEnumerator(
|
||||
IEnumerator<WeakReference<ItemType>> containedTypeEnumerator
|
||||
IEnumerator<WeakReference<TItem>> containedTypeEnumerator
|
||||
) {
|
||||
this.containedTypeEnumerator = containedTypeEnumerator;
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <summary>
|
||||
/// The element in the collection at the current position of the enumerator.
|
||||
/// </summary>
|
||||
public ItemType Current {
|
||||
public TItem Current {
|
||||
get { return this.containedTypeEnumerator.Current.Target; }
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
/// <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
|
||||
/// the WeakCollection's interface.
|
||||
/// </param>
|
||||
public WeakCollection(IList<WeakReference<ItemType>> items) :
|
||||
this(items, EqualityComparer<ItemType>.Default) { }
|
||||
public WeakCollection(IList<WeakReference<TItem>> items) :
|
||||
this(items, EqualityComparer<TItem>.Default) { }
|
||||
|
||||
/// <summary>Initializes a new weak reference collection</summary>
|
||||
/// <param name="items">
|
||||
|
@ -119,7 +119,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// Comparer used to identify and compare items to each other
|
||||
/// </param>
|
||||
public WeakCollection(
|
||||
IList<WeakReference<ItemType>> items, IEqualityComparer<ItemType> comparer
|
||||
IList<WeakReference<TItem>> items, IEqualityComparer<TItem> comparer
|
||||
) {
|
||||
this.items = items;
|
||||
this.comparer = comparer;
|
||||
|
@ -141,7 +141,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// looking for. It is recommended to provide a custom implementation of
|
||||
/// this method, if possible.
|
||||
/// </remarks>
|
||||
public virtual bool Contains(ItemType item) {
|
||||
public virtual bool Contains(TItem item) {
|
||||
return (IndexOf(item) != -1);
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ namespace Nuclex.Support.Collections {
|
|||
/// <exception cref="System.ArgumentNullException">
|
||||
/// Array is null.
|
||||
/// </exception>
|
||||
public void CopyTo(ItemType[] array, int index) {
|
||||
public void CopyTo(TItem[] array, int index) {
|
||||
if(this.items.Count > (array.Length - index)) {
|
||||
throw new ArgumentException(
|
||||
"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.
|
||||
/// </summary>
|
||||
/// <returns>An enumerator or the WeakCollection.</returns>
|
||||
public IEnumerator<ItemType> GetEnumerator() {
|
||||
public IEnumerator<TItem> 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
|
||||
/// this method, if possible.
|
||||
/// </remarks>
|
||||
public int IndexOf(ItemType item) {
|
||||
public int IndexOf(TItem item) {
|
||||
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(ReferenceEquals(item, itemAtIndex)) {
|
||||
return index;
|
||||
|
@ -242,9 +242,9 @@ namespace Nuclex.Support.Collections {
|
|||
/// Index is less than zero or index is equal to or greater than
|
||||
/// WeakCollection.Count.
|
||||
/// </exception>
|
||||
public ItemType this[int index] {
|
||||
public TItem this[int index] {
|
||||
get { return this.items[index].Target; }
|
||||
set { this.items[index] = new WeakReference<ItemType>(value); }
|
||||
set { this.items[index] = new WeakReference<TItem>(value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -254,9 +254,9 @@ namespace Nuclex.Support.Collections {
|
|||
/// <returns>
|
||||
/// True if item was successfully removed from the WeakCollection; otherwise, false.
|
||||
/// </returns>
|
||||
public bool Remove(ItemType item) {
|
||||
public bool Remove(TItem item) {
|
||||
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(ReferenceEquals(item, itemAtIndex)) {
|
||||
this.items.RemoveAt(index);
|
||||
|
@ -275,8 +275,8 @@ namespace Nuclex.Support.Collections {
|
|||
|
||||
/// <summary>Adds an item to the WeakCollection.</summary>
|
||||
/// <param name="item">The object to add to the WeakCollection</param>
|
||||
public void Add(ItemType item) {
|
||||
this.items.Add(new WeakReference<ItemType>(item));
|
||||
public void Add(TItem item) {
|
||||
this.items.Add(new WeakReference<TItem>(item));
|
||||
}
|
||||
|
||||
/// <summary>Inserts an item to the WeakCollection at the specified index.</summary>
|
||||
|
@ -287,8 +287,8 @@ namespace Nuclex.Support.Collections {
|
|||
/// <exception cref="System.ArgumentOutOfRangeException">
|
||||
/// index is not a valid index in the WeakCollection.
|
||||
/// </exception>
|
||||
public void Insert(int index, ItemType item) {
|
||||
this.items.Insert(index, new WeakReference<ItemType>(item));
|
||||
public void Insert(int index, TItem item) {
|
||||
this.items.Insert(index, new WeakReference<TItem>(item));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -329,9 +329,9 @@ namespace Nuclex.Support.Collections {
|
|||
}
|
||||
|
||||
/// <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>
|
||||
private IEqualityComparer<ItemType> comparer;
|
||||
private IEqualityComparer<TItem> comparer;
|
||||
/// <summary>Synchronization root for threaded accesses to this collection</summary>
|
||||
private object syncRoot;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class EnumHelperTest {
|
||||
internal class EnumHelperTest {
|
||||
|
||||
#region enum TestEnumeration
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class FloatHelperTest {
|
||||
internal class FloatHelperTest {
|
||||
|
||||
/// <summary>Tests the floating point value comparison helper</summary>
|
||||
[Test]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class ChainStreamTest {
|
||||
internal class ChainStreamTest {
|
||||
|
||||
#region class TestStream
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class PartialStreamTest {
|
||||
internal class PartialStreamTest {
|
||||
|
||||
#region class TestStream
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class RingMemoryStreamTest {
|
||||
internal class RingMemoryStreamTest {
|
||||
|
||||
/// <summary>Prepares some test data for the units test methods</summary>
|
||||
[TestFixtureSetUp]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class IntegerHelperTest {
|
||||
internal class IntegerHelperTest {
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that the next power of 2 calculation works for long integers
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class LicenseKeyTest {
|
||||
internal class LicenseKeyTest {
|
||||
|
||||
/// <summary>Tests the default constructor of the license key class</summary>
|
||||
[Test]
|
||||
public void TestDefaultConstructor() {
|
||||
new LicenseKey();
|
||||
public void DefaultConstructorCanBeUsed() {
|
||||
Assert.IsNotNull(new LicenseKey()); // Nonsense, prevents compiler warning
|
||||
}
|
||||
|
||||
/// <summary>Validates the correct translation of keys to GUIDs and back</summary>
|
||||
[Test]
|
||||
public void TestGuidKeyConversion() {
|
||||
|
||||
public void LicenseKeysCanBeConvertedToGuidsAndBack() {
|
||||
for(int i = 0; i < 128; ++i) {
|
||||
|
||||
// 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>Tests whether license keys can be modified without destroying them</summary>
|
||||
[Test]
|
||||
public void TestKeyModification() {
|
||||
public void LicenseKeysCanBeModified() {
|
||||
|
||||
for(int i = 0; i < 4; ++i) {
|
||||
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>
|
||||
[Test]
|
||||
public void TestParseInvalidLicenseKey() {
|
||||
public void ParsingInvalidLicenseKeyThrowsArgumentException() {
|
||||
Assert.Throws<ArgumentException>(
|
||||
delegate() { LicenseKey.Parse("hello world"); }
|
||||
);
|
||||
|
@ -107,7 +105,7 @@ namespace Nuclex.Support.Licensing {
|
|||
/// with an invalid index to retrieve a component of the key
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestGetByIndexerWithInvalidIndex() {
|
||||
public void ReadingInvalidIndexThrowsIndexOutOfRangeException() {
|
||||
LicenseKey key = new LicenseKey();
|
||||
Assert.Throws<IndexOutOfRangeException>(
|
||||
delegate() { Console.WriteLine(key[-1]); }
|
||||
|
@ -119,7 +117,7 @@ namespace Nuclex.Support.Licensing {
|
|||
/// with an invalid index to set a component of the key
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestSetByIndexerWithInvalidIndex() {
|
||||
public void WritingInvalidIndexThrowsIndexOutOfRangeException() {
|
||||
LicenseKey key = new LicenseKey();
|
||||
Assert.Throws<IndexOutOfRangeException>(
|
||||
delegate() { key[-1] = 0; }
|
||||
|
@ -130,7 +128,7 @@ namespace Nuclex.Support.Licensing {
|
|||
/// Verifies that a license key can be converted into a byte array
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void TestToByteArray() {
|
||||
public void LicenseKeyCanBeConvertedToByteArray() {
|
||||
Guid someGuid = Guid.NewGuid();
|
||||
LicenseKey someKey = new LicenseKey(someGuid);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class CommandLineTest {
|
||||
internal class CommandLineTest {
|
||||
|
||||
#region class ArgumentTest
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class PathHelperTest {
|
||||
internal class PathHelperTest {
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the relative path creator keeps the absolute path if
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class AssemblyLoadEventArgsTest {
|
||||
internal class AssemblyLoadEventArgsTest {
|
||||
|
||||
/// <summary>
|
||||
/// Tests whether the argument container correctly stores an assembly reference
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class EmployerTest {
|
||||
internal class EmployerTest {
|
||||
|
||||
#region class TestEmployer
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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>
|
||||
[TestFixture]
|
||||
public class FactoryEmployerTest {
|
||||
internal class FactoryEmployerTest {
|
||||
|
||||
#region class Base
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
modify it under the terms of the IBM Common Public License as
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#region CPL License
|
||||
/*
|
||||
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
|
||||
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