Permalink
Browse files

Set default Id to type of Guid. Also broke all the tests and a couple…

… of other things. Got rid of commands for now.
  • Loading branch information...
geoffreysmith committed Jun 14, 2011
1 parent 448ecb9 commit 2ee9f36cbf9b56101936857b22ed184feea05c0c
Showing with 25 additions and 522 deletions.
  1. +0 −20 Solutions/SharpArch.Domain/Commands/CommandBase.cs
  2. +0 −12 Solutions/SharpArch.Domain/Commands/CommandHandlerNotFoundException.cs
  3. +0 −30 Solutions/SharpArch.Domain/Commands/CommandProcessor.cs
  4. +0 −12 Solutions/SharpArch.Domain/Commands/CommandResult.cs
  5. +0 −31 Solutions/SharpArch.Domain/Commands/CommandResults.cs
  6. +0 −11 Solutions/SharpArch.Domain/Commands/ICommand.cs
  7. +0 −7 Solutions/SharpArch.Domain/Commands/ICommandHandler.cs
  8. +0 −7 Solutions/SharpArch.Domain/Commands/ICommandProcessor.cs
  9. +0 −7 Solutions/SharpArch.Domain/Commands/ICommandResult.cs
  10. +0 −9 Solutions/SharpArch.Domain/Commands/ICommandResults.cs
  11. +1 −1 Solutions/SharpArch.Domain/DomainModel/Entity.cs
  12. +0 −51 Solutions/SharpArch.Domain/Events/DomainEvents.cs
  13. +0 −6 Solutions/SharpArch.Domain/Events/IDomainEvent.cs
  14. +0 −7 Solutions/SharpArch.Domain/Events/IHandles.cs
  15. +3 −1 Solutions/SharpArch.Domain/PersistenceSupport/IRepository.cs
  16. +0 −13 Solutions/SharpArch.Domain/SharpArch.Domain.csproj
  17. +3 −1 Solutions/SharpArch.NHibernate/Contracts/Repositories/INHibernateRepository.cs
  18. +3 −1 Solutions/SharpArch.NHibernate/NHibernateRepository.cs
  19. +0 −1 Solutions/SharpArch.Specifications/SharpArch.Domain/DomainModel/EntityWithTypedIdSpecs.cs
  20. +0 −4 Solutions/SharpArch.Specifications/SharpArch.Specifications.csproj
  21. +0 −122 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/CommandProcessorTests.cs
  22. +0 −39 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/CommandTests.cs
  23. +0 −15 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/InvalidCommand.cs
  24. +0 −9 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommand.cs
  25. +0 −21 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommandHandler.cs
  26. +0 −9 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/TestCommandResult.cs
  27. +0 −17 Solutions/SharpArch.Tests/SharpArch.Domain/Commands/ValidCommand.cs
  28. +8 −7 Solutions/SharpArch.Tests/SharpArch.Domain/DomainModel/BaseObjectEqualityComparerTests.cs
  29. +6 −4 Solutions/SharpArch.Tests/SharpArch.Domain/DomainModel/EntityTests.cs
  30. +0 −7 Solutions/SharpArch.Tests/SharpArch.Tests.csproj
  31. +1 −1 Solutions/SharpArch.Tests/SharpArch.Web.Mvc/ModelBinder/SharpModelBinderTests.cs
  32. +0 −39 Solutions/SharpArch.sln
@@ -1,20 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
-
- public class CommandBase : ICommand
- {
- public virtual bool IsValid()
- {
- return ValidationResults().Count == 0;
- }
-
- public virtual ICollection<ValidationResult> ValidationResults()
- {
- var validationResults = new List<ValidationResult>();
- Validator.TryValidateObject(this, new ValidationContext(this, null, null), validationResults, true);
- return validationResults;
- }
- }
-}
@@ -1,12 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System;
-
- public class CommandHandlerNotFoundException : Exception
- {
- public CommandHandlerNotFoundException(Type type)
- : base(string.Format("Command handler not found for command type: {0}", type))
- {
- }
- }
-}
@@ -1,30 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
-
- using Microsoft.Practices.ServiceLocation;
-
- public class CommandProcessor : ICommandProcessor
- {
- public ICommandResults Process<TCommand>(TCommand command) where TCommand : ICommand
- {
- Validator.ValidateObject(command, new ValidationContext(command, null, null), true);
-
- var results = new CommandResults();
-
- var handlers = ServiceLocator.Current.GetAllInstances<ICommandHandler<TCommand>>();
- if (handlers == null || !handlers.Any())
- {
- throw new CommandHandlerNotFoundException(typeof(TCommand));
- }
-
- foreach (var result in handlers.Select(handler => handler.Handle(command)))
- {
- results.AddResult(result);
- }
-
- return results;
- }
- }
-}
@@ -1,12 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public class CommandResult : ICommandResult
- {
- protected CommandResult(bool success)
- {
- this.Success = success;
- }
-
- public bool Success { get; protected set; }
- }
-}
@@ -1,31 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System.Collections.Generic;
- using System.Linq;
-
- public class CommandResults : ICommandResults
- {
- private readonly List<ICommandResult> results = new List<ICommandResult>();
-
- public bool Success
- {
- get
- {
- return this.results.All(result => result.Success);
- }
- }
-
- public ICommandResult[] Results
- {
- get
- {
- return this.results.ToArray();
- }
- }
-
- public void AddResult(ICommandResult result)
- {
- this.results.Add(result);
- }
- }
-}
@@ -1,11 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
-
- public interface ICommand
- {
- bool IsValid();
- ICollection<ValidationResult> ValidationResults();
- }
-}
@@ -1,7 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public interface ICommandHandler<in TCommand> where TCommand : ICommand
- {
- ICommandResult Handle(TCommand command);
- }
-}
@@ -1,7 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public interface ICommandProcessor
- {
- ICommandResults Process<TCommand>(TCommand command) where TCommand : ICommand;
- }
-}
@@ -1,7 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public interface ICommandResult
- {
- bool Success { get; }
- }
-}
@@ -1,9 +0,0 @@
-namespace SharpArch.Domain.Commands
-{
- public interface ICommandResults
- {
- bool Success { get; }
-
- ICommandResult[] Results { get; }
- }
-}
@@ -12,7 +12,7 @@
/// than int, such as string, then use <see cref = "EntityWithTypedId{IdT}" /> instead.
/// </summary>
[Serializable]
- public abstract class Entity : EntityWithTypedId<int>
+ public abstract class Entity : EntityWithTypedId<Guid>
{
}
}
@@ -1,51 +0,0 @@
-namespace SharpArch.Domain.Events
-{
- using System;
- using System.Collections.Generic;
-
- using Microsoft.Practices.ServiceLocation;
-
- public class DomainEvents
- {
- [ThreadStatic]
- private static List<Delegate> actions;
-
- public static IServiceLocator ServiceLocator { get; set; }
-
- public static void ClearCallbacks()
- {
- actions = null;
- }
-
- public static void Raise<T>(T args) where T : IDomainEvent
- {
- if (ServiceLocator != null)
- {
- foreach (var handler in ServiceLocator.GetAllInstances<IHandles<T>>())
- {
- handler.Handle(args);
- }
- }
-
- if (actions != null)
- {
- foreach (var action in actions)
- {
- if (action is Action<T>)
- {
- ((Action<T>)action)(args);
- }
- }
- }
- }
-
- public static void Register<T>(Action<T> callback) where T : IDomainEvent
- {
- if (actions == null)
- {
- actions = new List<Delegate>();
- }
- actions.Add(callback);
- }
- }
-}
@@ -1,6 +0,0 @@
-namespace SharpArch.Domain.Events
-{
- public interface IDomainEvent
- {
- }
-}
@@ -1,7 +0,0 @@
-namespace SharpArch.Domain.Events
-{
- public interface IHandles<in T> where T : IDomainEvent
- {
- void Handle(T args);
- }
-}
@@ -1,13 +1,15 @@
namespace SharpArch.Domain.PersistenceSupport
{
+ using System;
+
/// <summary>
/// Provides a standard interface for DAOs which are data-access mechanism agnostic.
///
/// Since nearly all of the domain objects you create will have a type of int Id, this
/// base Idao leverages this assumption. If you want an entity with a type
/// other than int, such as string, then use <see cref = "IRepositoryWithTypedId{T, IdT}" />.
/// </summary>
- public interface IRepository<T> : IRepositoryWithTypedId<T, int>
+ public interface IRepository<T> : IRepositoryWithTypedId<T, Guid>
{
}
}
@@ -78,23 +78,11 @@
<Compile Include="..\..\Common\CommonAssemblyInfo.cs">
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
- <Compile Include="Commands\CommandBase.cs" />
- <Compile Include="Commands\CommandHandlerNotFoundException.cs" />
- <Compile Include="Commands\CommandProcessor.cs" />
- <Compile Include="Commands\CommandResult.cs" />
- <Compile Include="Commands\CommandResults.cs" />
- <Compile Include="Commands\ICommand.cs" />
- <Compile Include="Commands\ICommandHandler.cs" />
- <Compile Include="Commands\ICommandProcessor.cs" />
- <Compile Include="Commands\ICommandResult.cs" />
- <Compile Include="Commands\ICommandResults.cs" />
<Compile Include="DesignByContract\Check.cs" />
<Compile Include="DesignByContract\DesignByContractException.cs" />
<Compile Include="DesignByContract\InvariantException.cs" />
<Compile Include="DesignByContract\PostconditionException.cs" />
<Compile Include="DesignByContract\PreconditionException.cs" />
- <Compile Include="Events\DomainEvents.cs" />
- <Compile Include="Events\IDomainEvent.cs" />
<Compile Include="DomainModel\BaseObject.cs" />
<Compile Include="DesignByContract\AssertionException.cs" />
<Compile Include="DomainModel\BaseObjectEqualityComparer.cs" />
@@ -105,7 +93,6 @@
<Compile Include="DomainModel\IHasAssignedId.cs" />
<Compile Include="DomainModel\ValidatableObject.cs" />
<Compile Include="DomainModel\ValueObject.cs" />
- <Compile Include="Events\IHandles.cs" />
<Compile Include="FileCache.cs" />
<Compile Include="PersistenceSupport\IDbContext.cs" />
<Compile Include="PersistenceSupport\ILinqRepository.cs" />
@@ -1,5 +1,7 @@
namespace SharpArch.NHibernate.Contracts.Repositories
{
+ using System;
+
using SharpArch.Domain.PersistenceSupport;
/// <summary>
@@ -8,7 +10,7 @@ namespace SharpArch.NHibernate.Contracts.Repositories
/// assembly. For looser coupling, the "Core" layers of the SharpArch library and of your
/// application should not have a reference to the NHibernate assembly.
/// </summary>
- public interface INHibernateRepository<T> : INHibernateRepositoryWithTypedId<T, int>, IRepository<T>
+ public interface INHibernateRepository<T> : INHibernateRepositoryWithTypedId<T, Guid>, IRepository<T>
{
}
}
@@ -1,5 +1,7 @@
namespace SharpArch.NHibernate
{
+ using System;
+
using SharpArch.NHibernate.Contracts.Repositories;
/// <summary>
@@ -8,7 +10,7 @@
/// an entity with a type other than int, such as string, then use
/// <see cref = "NHibernateRepositoryWithTypedId{T, IdT}" />.
/// </summary>
- public class NHibernateRepository<T> : NHibernateRepositoryWithTypedId<T, int>, INHibernateRepository<T>
+ public class NHibernateRepository<T> : NHibernateRepositoryWithTypedId<T, Guid>, INHibernateRepository<T>
{
}
}
@@ -18,7 +18,6 @@ namespace SharpArch.Specifications.SharpArch.Domain.DomainModel
using Machine.Specifications;
- using Tests.SharpArch.Domain;
public class entity_with_type_id_specs
{
@@ -95,10 +95,6 @@
<Project>{0BD77F13-8DF6-4C16-9508-33AA4CF0677A}</Project>
<Name>SharpArch.NHibernate</Name>
</ProjectReference>
- <ProjectReference Include="..\SharpArch.Tests\SharpArch.Tests.csproj">
- <Project>{C201296D-09B7-4BAE-96F0-AB59F624DB36}</Project>
- <Name>SharpArch.Tests</Name>
- </ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Oops, something went wrong.

0 comments on commit 2ee9f36

Please sign in to comment.