cosmetic & doc

This commit is contained in:
sgay
2012-07-27 14:06:41 -02:00
parent 74dd444506
commit 83f76ed4a4
4 changed files with 48 additions and 24 deletions

View File

@@ -4,13 +4,13 @@ using System.Threading;
namespace Umbraco.Core.Resolving
{
/// <summary>
/// A Resolver to return and set a Multiply registered object.
/// A Resolver which manages an ordered list of objects.
/// </summary>
/// <typeparam name="TResolver"></typeparam>
/// <typeparam name="TResolved"></typeparam>
/// <typeparam name="TResolver">The type of the resolver.</typeparam>
/// <typeparam name="TResolved">The type of the resolved objects.</typeparam>
/// <remarks>
/// Used to resolve multiple types from a collection. The collection can also be modified at runtime/application startup.
/// An example of this is MVCs ViewEngines collection
/// An example of this is MVCs ViewEngines collection.
/// </remarks>
internal abstract class MultipleResolverBase<TResolver, TResolved> : ResolverBase<TResolver>
where TResolver : class
@@ -19,39 +19,60 @@ namespace Umbraco.Core.Resolving
readonly List<TResolved> _resolved;
protected readonly ReaderWriterLockSlim Lock = new ReaderWriterLockSlim();
/// <summary>
/// Initializes a new instance of the <see cref="MultipleResolverBase"/> class with an empty list of objects.
/// </summary>
protected MultipleResolverBase()
{
_resolved = new List<TResolved>();
}
/// <summary>
/// Initializes a new instance of the <see cref="MultipleResolverBase"/> class with an initial list of objects.
/// </summary>
/// <param name="values">The list of objects.</param>
protected MultipleResolverBase(IEnumerable<TResolved> value)
{
_resolved = new List<TResolved>(value);
}
}
protected IEnumerable<TResolved> Values
/// <summary>
/// Gets the list of objects.
/// </summary>
protected IEnumerable<TResolved> Values
{
get { return _resolved; }
}
public void Remove(TResolved item)
/// <summary>
/// Removes an object.
/// </summary>
/// <param name="value">The object to remove.</param>
public void Remove(TResolved value)
{
Resolution.EnsureNotFrozen();
using (new WriteLock(Lock))
{
_resolved.Remove(item);
_resolved.Remove(value);
}
}
public void Add(TResolved item)
/// <summary>
/// Adds an object to the end of the list.
/// </summary>
/// <param name="value">The object to be added.</param>
public void Add(TResolved value)
{
Resolution.EnsureNotFrozen();
using (new WriteLock(Lock))
{
_resolved.Add(item);
_resolved.Add(value);
}
}
/// <summary>
/// Clears the list.
/// </summary>
public void Clear()
{
Resolution.EnsureNotFrozen();
@@ -61,12 +82,17 @@ namespace Umbraco.Core.Resolving
}
}
public void Insert(int index, TResolved item)
/// <summary>
/// Inserts an object at the specified index.
/// </summary>
/// <param name="index">The zero-based index at which the object should be inserted.</param>
/// <param name="value">The object to insert.</param>
public void Insert(int index, TResolved value)
{
Resolution.EnsureNotFrozen();
using (new WriteLock(Lock))
{
_resolved.Insert(index, item);
_resolved.Insert(index, value);
}
}

View File

@@ -52,7 +52,7 @@ namespace Umbraco.Web.Routing
/// <summary>
/// Gets the <see cref="IDocumentLookup"/> implementations.
/// </summary>
public IEnumerable<IDocumentLookup> GetDocumentLookups
public IEnumerable<IDocumentLookup> DocumentLookups
{
get { return _lookups.Values; }
}

View File

@@ -202,7 +202,7 @@ namespace Umbraco.Web.Routing
// the first successful resolver, if any, will set this.Node, and may also set this.Template
// some lookups may implement caching
Trace.TraceInformation("{0}Begin resolvers", tracePrefix);
var lookups = RoutingContext.DocumentLookupsResolver.GetDocumentLookups;
var lookups = RoutingContext.DocumentLookupsResolver.DocumentLookups;
lookups.Any(lookup => lookup.TrySetDocument(this));
Trace.TraceInformation("{0}End resolvers, {1}", tracePrefix, (this.HasNode ? "a document was found" : "no document was found"));
@@ -243,7 +243,7 @@ namespace Umbraco.Web.Routing
Trace.TraceInformation("{0}No document, try last chance lookup", tracePrefix);
// if it fails then give up, there isn't much more that we can do
var lastChance = RoutingContext.DocumentLookupsResolver.RequestDocumentLastChanceResolver;
var lastChance = RoutingContext.DocumentLookupsResolver.DocumentLastChanceLookup;
if (lastChance == null || !lastChance.TrySetDocument(this))
{
Trace.TraceInformation("{0}Failed to find a document, give up", tracePrefix);

View File

@@ -240,8 +240,13 @@
<Compile Include="ContentStore.cs" />
<Compile Include="LegacyRequestInitializer.cs" />
<Compile Include="Mvc\ControllerExtensions.cs" />
<Compile Include="Routing\IRequestDocumentLastChanceResolver.cs" />
<Compile Include="Routing\IRequestDocumentResolver.cs" />
<Compile Include="Routing\DefaultLastChanceLookup.cs" />
<Compile Include="Routing\IDocumentLastChanceLookup.cs" />
<Compile Include="Routing\LookupByAlias.cs" />
<Compile Include="Routing\LookupById.cs" />
<Compile Include="Routing\LookupByNiceUrl.cs" />
<Compile Include="Routing\LookupByNiceUrlAndTemplate.cs" />
<Compile Include="Routing\LookupByProfile.cs" />
<Compile Include="Routing\NiceUrlProvider.cs" />
<Compile Include="PluginTypeResolverExtensions.cs" />
<Compile Include="Routing\Domains.cs" />
@@ -250,13 +255,6 @@
<Compile Include="Routing\IDocumentLookup.cs" />
<Compile Include="Routing\IRoutesCache.cs" />
<Compile Include="Routing\DefaultRoutesCache.cs" />
<Compile Include="Routing\RequestDocumentResolversResolver.cs" />
<Compile Include="Routing\ResolveByAlias.cs" />
<Compile Include="Routing\ResolveById.cs" />
<Compile Include="Routing\ResolveByNiceUrl.cs" />
<Compile Include="Routing\ResolveByNiceUrlAndTemplate.cs" />
<Compile Include="Routing\ResolveByProfile.cs" />
<Compile Include="Routing\ResolveLastChance.cs" />
<Compile Include="Routing\RoutesCacheResolver.cs" />
<Compile Include="Routing\RoutingContext.cs" />
<Compile Include="umbraco.presentation\EnsureSystemPathsApplicationStartupHandler.cs" />