Permalink
Browse files

Removed FluentValidation.dll dependency and merged the FluentValidati…

…on src into the ServiceStack.ServiceInterface's project.

Modified ServiceBase to return a HttpError for exceptions
  • Loading branch information...
1 parent 96c576d commit b2c28c72bfbbd685f9acef5cfc1e0ec29ab4cb8c @mythz mythz committed Dec 23, 2011
Showing with 7,086 additions and 729 deletions.
  1. BIN lib/FluentValidation.dll
  2. +6 −0 src/ServiceStack.Common/Web/HttpError.cs
  3. +0 −157 src/ServiceStack.ServiceInterface/Deprecated.Session/CachedUserSessionManager.cs
  4. +0 −80 src/ServiceStack.ServiceInterface/Deprecated.Session/IUserSessionManager.cs
  5. +0 −30 src/ServiceStack.ServiceInterface/Deprecated.Session/PublicAndPrivateClientSessions.cs
  6. +0 −86 src/ServiceStack.ServiceInterface/Deprecated.Session/UserClientSession.cs
  7. +0 −174 src/ServiceStack.ServiceInterface/Deprecated.Session/UserSession.cs
  8. +206 −0 src/ServiceStack.ServiceInterface/FluentValidation/AbstractValidator.cs
  9. +114 −0 src/ServiceStack.ServiceInterface/FluentValidation/AssemblyScanner.cs
  10. +51 −0 src/ServiceStack.ServiceInterface/FluentValidation/Attributes/AttributedValidatorFactory.cs
  11. +42 −0 src/ServiceStack.ServiceInterface/FluentValidation/Attributes/ValidatorAttribute.cs
  12. +74 −0 src/ServiceStack.ServiceInterface/FluentValidation/CollectionValidatorExtensions.cs
  13. +604 −0 src/ServiceStack.ServiceInterface/FluentValidation/DefaultValidatorExtensions.cs
  14. +261 −0 src/ServiceStack.ServiceInterface/FluentValidation/DefaultValidatorOptions.cs
  15. +48 −0 src/ServiceStack.ServiceInterface/FluentValidation/Enums.cs
  16. +46 −0 src/ServiceStack.ServiceInterface/FluentValidation/IValidationRule.cs
  17. +74 −0 src/ServiceStack.ServiceInterface/FluentValidation/IValidator.cs
  18. +52 −0 src/ServiceStack.ServiceInterface/FluentValidation/IValidatorDescriptor.cs
  19. +37 −0 src/ServiceStack.ServiceInterface/FluentValidation/IValidatorFactory.cs
  20. +51 −0 src/ServiceStack.ServiceInterface/FluentValidation/InlineValidator.cs
  21. +39 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/DefaultValidatorSelector.cs
  22. +83 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/DelegateValidator.cs
  23. +172 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/Extensions.cs
  24. +38 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/IConfigurable.cs
  25. +36 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/IFluentInterface.cs
  26. +35 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/IValidatorSelector.cs
  27. +65 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/InstanceCache.cs
  28. +71 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/MemberNameValidatorSelector.cs
  29. +75 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/MessageFormatter.cs
  30. +138 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/PropertyChain.cs
  31. +248 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/PropertyRule.cs
  32. +88 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/RuleBuilder.cs
  33. +34 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/RulesetValidatorSelector.cs
  34. +64 −0 src/ServiceStack.ServiceInterface/FluentValidation/Internal/TrackingCollection.cs
  35. +80 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/IResourceAccessorBuilder.cs
  36. +44 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/IStringSource.cs
  37. +92 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/LocalizedStringSource.cs
  38. +208 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.Designer.cs
  39. +165 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.de.resx
  40. +156 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.es.resx
  41. +156 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.fr.resx
  42. +165 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.it.resx
  43. +156 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.nl.resx
  44. +165 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.pl.resx
  45. +165 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.pt.resx
  46. +168 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.resx
  47. +165 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/Messages.sv.resx
  48. +59 −0 src/ServiceStack.ServiceInterface/FluentValidation/Resources/StaticStringSource.cs
  49. +69 −0 src/ServiceStack.ServiceInterface/FluentValidation/Results/ValidationFailure.cs
  50. +46 −0 src/ServiceStack.ServiceInterface/FluentValidation/Results/ValidationResult.cs
  51. +70 −0 src/ServiceStack.ServiceInterface/FluentValidation/Syntax.cs
  52. +27 −0 src/ServiceStack.ServiceInterface/FluentValidation/TestHelper/ValidationTestException.cs
  53. +61 −0 src/ServiceStack.ServiceInterface/FluentValidation/TestHelper/ValidatorTestExtensions.cs
  54. +71 −0 src/ServiceStack.ServiceInterface/FluentValidation/TestHelper/ValidatorTester.cs
  55. +65 −0 src/ServiceStack.ServiceInterface/FluentValidation/ValidationContext.cs
  56. +38 −0 src/ServiceStack.ServiceInterface/FluentValidation/ValidationException.cs
  57. +78 −0 src/ServiceStack.ServiceInterface/FluentValidation/ValidatorDescriptor.cs
  58. +35 −0 src/ServiceStack.ServiceInterface/FluentValidation/ValidatorFactoryBase.cs
  59. +115 −0 src/ServiceStack.ServiceInterface/FluentValidation/ValidatorOptions.cs
  60. +88 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/AbstractComparisonValidator.cs
  61. +76 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/ChildCollectionValidatorAdaptor.cs
  62. +53 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/ChildValidatorAdaptor.cs
  63. +64 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/CreditCardValidator.cs
  64. +69 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/DelegatingValidator.cs
  65. +56 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/EmailValidator.cs
  66. +90 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/EqualValidator.cs
  67. +58 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/ExclusiveBetweenValidator.cs
  68. +42 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/GreaterThanOrEqualValidator.cs
  69. +43 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/GreaterThanValidator.cs
  70. +38 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/IPropertyValidator.cs
  71. +63 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/InclusiveBetweenValidator.cs
  72. +69 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/LengthValidator.cs
  73. +50 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/LessThanOrEqualValidator.cs
  74. +44 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/LessThanValidator.cs
  75. +48 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/NoopPropertyValidator.cs
  76. +69 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/NotEmptyValidator.cs
  77. +90 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/NotEqualValidator.cs
  78. +37 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/NotNullValidator.cs
  79. +47 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/PredicateValidator.cs
  80. +93 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/PropertyValidator.cs
  81. +81 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/PropertyValidatorContext.cs
  82. +53 −0 src/ServiceStack.ServiceInterface/FluentValidation/Validators/RegularExpressionValidator.cs
  83. +6 −1 src/ServiceStack.ServiceInterface/README.md
  84. +9 −1 src/ServiceStack.ServiceInterface/ServiceBase.cs
  85. +0 −108 src/ServiceStack.ServiceInterface/ServiceRoutesExtension.cs
  86. +86 −68 src/ServiceStack.ServiceInterface/ServiceRoutesExtensions.cs
  87. +79 −10 src/ServiceStack.ServiceInterface/ServiceStack.ServiceInterface.csproj
  88. +2 −2 src/ServiceStack.ServiceInterface/Validation/MultiRuleSetValidatorSelector.cs
  89. +6 −6 src/ServiceStack.ServiceInterface/Validation/ValidationFilter.cs
  90. +2 −2 src/ServiceStack.ServiceInterface/Validation/ValidationHandler.cs
  91. +3 −3 src/ServiceStack.ServiceInterface/Validation/ValidationResultExtensions.cs
  92. +1 −1 tests/ServiceStack.WebHost.IntegrationTests/Services/FileUploadService.cs
Binary file not shown.
@@ -15,6 +15,12 @@ public HttpError(string message)
public HttpError(HttpStatusCode statusCode, string errorCode)
: this(statusCode, errorCode, null) {}
+ public HttpError(object responseDto, HttpStatusCode statusCode, string errorCode, string errorMessage)
+ : this(statusCode, errorCode, errorMessage)
+ {
+ this.Response = responseDto;
+ }
+
public HttpError(HttpStatusCode statusCode, string errorCode, string errorMessage)
: base(errorMessage ?? errorCode)
{
@@ -1,157 +0,0 @@
-/*
-// $Id: CachedUserSessionManager.cs 13365 2010-03-08 18:59:26Z DDNGLOBAL\Demis $
-//
-// Revision : $Revision: 13365 $
-// Modified Date : $LastChangedDate: 2010-03-08 18:59:26 +0000 (Mon, 08 Mar 2010) $
-// Modified By : $LastChangedBy: DDNGLOBAL\Demis $
-//
-// (c) Copyright 2010 Liquidbit Ltd
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using ServiceStack.CacheAccess;
-using ServiceStack.Logging;
-
-namespace ServiceStack.ServiceInterface.Deprecated.Session
-{
- /// <summary>
- /// Manages all the User Sessions into the ICacheClient provided
- /// </summary>
- public class CachedUserSessionManager
- : IUserSessionManager
- {
- private static readonly ILog Log = LogManager.GetLogger(typeof(CachedUserSessionManager));
-
- private readonly ICacheClient cacheClient;
-
- /// <summary>
- /// Big perf hit if we Log on every session change
- /// </summary>
- /// <param name="fmt">The FMT.</param>
- /// <param name="args">The args.</param>
- [Conditional("DEBUG")]
- protected void LogIfDebug(string fmt, params object[] args)
- {
- if (args.Length > 0)
- Log.DebugFormat(fmt, args);
- else
- Log.Debug(fmt);
- }
-
- public CachedUserSessionManager(ICacheClient cacheClient)
- {
- this.cacheClient = cacheClient;
- }
-
- /// <summary>
- /// Removes the client session.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <param name="clientSessionIds">The client session ids.</param>
- public void RemoveClientSession(Guid userId, ICollection<Guid> clientSessionIds)
- {
- var userSession = this.GetUserSession(userId);
- if (userSession == null) return;
-
- foreach (var clientSessionId in clientSessionIds)
- {
- userSession.RemoveClientSession(clientSessionId);
- }
- this.UpdateUserSession(userSession);
- }
-
- /// <summary>
- /// Adds a new client session.
- /// Should this be changed to GetOrCreateClientSession?
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <param name="userName">Title of the user.</param>
- /// <param name="shardId">The shard id.</param>
- /// <param name="ipAddress">The ip address.</param>
- /// <param name="userAgent"></param>
- /// <param name="base64ClientModulus">The base64 client modulus.</param>
- /// <param name="userClientGlobalId">The user client global id.</param>
- /// <returns></returns>
- public UserClientSession StoreClientSession(Guid userId, string userName, string shardId, string ipAddress, string userAgent, string base64ClientModulus, Guid userClientGlobalId)
- {
- var userSession = this.GetOrCreateSession(userId, userName, shardId);
-
- var existingClientSession = userSession.GetClientSessionWithClientId(userClientGlobalId);
- if (existingClientSession != null)
- {
- userSession.RemoveClientSession(existingClientSession.Id);
- }
-
- var newClientSession = userSession.CreateNewClientSession(
- ipAddress, userAgent, base64ClientModulus, userClientGlobalId);
-
- this.UpdateUserSession(userSession);
-
- return newClientSession;
- }
-
- /// <summary>
- /// Updates the UserSession in the cache, or removes expired ones.
- /// </summary>
- /// <param name="userSession">The user session.</param>
- public void UpdateUserSession(UserSession userSession)
- {
- var hasSessionExpired = userSession.HasExpired();
- if (hasSessionExpired)
- {
- LogIfDebug("Session has expired, removing: " + userSession.ToCacheKey());
- this.cacheClient.Remove(userSession.ToCacheKey());
- }
- else
- {
- LogIfDebug("Updating session: " + userSession.ToCacheKey());
- this.cacheClient.Replace(userSession.ToCacheKey(), userSession, userSession.ExpiryDate.Value);
- }
- }
-
- /// <summary>
- /// Gets the user session if it exists or null.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <returns></returns>
- public UserSession GetUserSession(Guid userId)
- {
- var cacheKey = UserSession.ToCacheKey(userId);
- return this.cacheClient.Get<UserSession>(cacheKey);
- }
-
- /// <summary>
- /// Gets or create a user session if one doesn't exist.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <param name="userName">Title of the user.</param>
- /// <param name="shardId"></param>
- /// <returns></returns>
- public UserSession GetOrCreateSession(Guid userId, string userName, string shardId)
- {
- var userSession = this.GetUserSession(userId);
- if (userSession == null)
- {
- userSession = new UserSession(userId, userName, shardId);
-
- this.cacheClient.Add(userSession.ToCacheKey(), userSession,
- userSession.ExpiryDate.GetValueOrDefault(DateTime.UtcNow) + TimeSpan.FromHours(1));
- }
- return userSession;
- }
-
- /// <summary>
- /// Gets the user client session identified by the id if exists otherwise null.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <param name="clientSessionId">The client session id.</param>
- /// <returns></returns>
- public UserClientSession GetUserClientSession(Guid userId, Guid clientSessionId)
- {
- var userSession = this.GetUserSession(userId);
- return userSession != null ? userSession.GetClientSession(clientSessionId) : null;
- }
- }
-}
@@ -1,80 +0,0 @@
-/*
-// $Id: IUserSessionManager.cs 13365 2010-03-08 18:59:26Z DDNGLOBAL\Demis $
-//
-// Revision : $Revision: 13365 $
-// Modified Date : $LastChangedDate: 2010-03-08 18:59:26 +0000 (Mon, 08 Mar 2010) $
-// Modified By : $LastChangedBy: DDNGLOBAL\Demis $
-//
-// (c) Copyright 2010 Liquidbit Ltd
-*/
-
-using System;
-using System.Collections.Generic;
-
-namespace ServiceStack.ServiceInterface.Deprecated.Session
-{
- /// <summary>
- /// Manager Interface listing all the methods required to manage a users session.
- /// </summary>
- public interface IUserSessionManager
- {
- /// <summary>
- /// Removes the client session.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <param name="clientSessionIds">The client session ids.</param>
- void RemoveClientSession(
- Guid userId,
- ICollection<Guid> clientSessionIds);
-
- /// <summary>
- /// Adds a new client session.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <param name="userName">Title of the user.</param>
- /// <param name="shardId">The shard id.</param>
- /// <param name="ipAddress">The ip address.</param>
- /// <param name="userAgent">The user agent.</param>
- /// <param name="base64ClientModulus">The base64 client modulus.</param>
- /// <param name="userClientGlobalId">The user client global id.</param>
- /// <returns></returns>
- UserClientSession StoreClientSession(
- Guid userId,
- string userName,
- string shardId,
- string ipAddress,
- string userAgent,
- string base64ClientModulus,
- Guid userClientGlobalId);
-
- /// <summary>
- /// Updates the UserSession in the cache, or removes expired ones.
- /// </summary>
- /// <param name="userSession">The user session.</param>
- void UpdateUserSession(UserSession userSession);
-
- /// <summary>
- /// Gets the user session if it exists or null.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <returns></returns>
- UserSession GetUserSession(Guid userId);
-
- /// <summary>
- /// Gets or create a user session if one doesn't exist.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <param name="userName">Title of the user.</param>
- /// <param name="shardId"></param>
- /// <returns></returns>
- UserSession GetOrCreateSession(Guid userId, string userName, string shardId);
-
- /// <summary>
- /// Gets the user client session identified by the id if exists otherwise null.
- /// </summary>
- /// <param name="userId">The user global id.</param>
- /// <param name="clientSessionId">The client session id.</param>
- /// <returns></returns>
- UserClientSession GetUserClientSession(Guid userId, Guid clientSessionId);
- }
-}
@@ -1,30 +0,0 @@
-/*
-// $Id: PublicAndPrivateClientSessions.cs 3595 2009-05-20 09:57:17Z Demis Bellot $
-//
-// Revision : $Revision: 3595 $
-// Modified Date : $LastChangedDate: 2009-05-20 10:57:17 +0100 (Wed, 20 May 2009) $
-// Modified By : $LastChangedBy: Demis Bellot $
-//
-// (c) Copyright 2010 Liquidbit Ltd
-*/
-
-
-namespace ServiceStack.ServiceInterface.Deprecated.Session
-{
- /// <summary>
- /// Holds a 'Secure' and 'Unsecure' client session for the user.
- /// The secure client session should only be transported over a secure channel.
- /// </summary>
- public class PublicAndPrivateClientSessions
- {
- public PublicAndPrivateClientSessions(
- UserClientSession unsecureClientSession, UserClientSession secureClientSession)
- {
- this.UnsecureClientSession = unsecureClientSession;
- this.SecureClientSession = secureClientSession;
- }
-
- public UserClientSession UnsecureClientSession { get; private set; }
- public UserClientSession SecureClientSession { get; private set; }
- }
-}
@@ -1,86 +0,0 @@
-/*
-// $Id: UserClientSession.cs 13369 2010-03-08 19:09:44Z DDNGLOBAL\Demis $
-//
-// Revision : $Revision: 13369 $
-// Modified Date : $LastChangedDate: 2010-03-08 19:09:44 +0000 (Mon, 08 Mar 2010) $
-// Modified By : $LastChangedBy: DDNGLOBAL\Demis $
-//
-// (c) Copyright 2010 Liquidbit Ltd
-*/
-
-using System;
-using ServiceStack.DesignPatterns.Model;
-
-namespace ServiceStack.ServiceInterface.Deprecated.Session
-{
- /// <summary>
- /// Holds information on a single 'User Client' session.
- ///
- /// A user can have multiple of these client sessions,
- /// each from a different web browser or client application.
- /// </summary>
- public class UserClientSession
- : IHasGuidId
- {
- private const int ValidForTwoWeeks = 14;
-
- /// <summary>
- /// Unique Id for this session
- /// </summary>
- public Guid Id { get; set; }
-
- /// <summary>
- /// Id of the User for this session
- /// </summary>
- public Guid UserId { get; set; }
-
- /// <summary>
- /// If provided stores the clients public key to enable secure transmission
- /// </summary>
- public string Base64ClientModulus { get; set; }
-
- /// <summary>
- /// The unique global and persistent id for the client application.
- /// (Can be stored in a persistent cookie)
- /// </summary>
- public Guid UserClientGlobalId { get; set; }
-
- /// <summary>
- /// The IpAddress for the client
- /// </summary>
- public string IpAddress { get; private set; }
-
- /// <summary>
- /// Holds meta-information about the operating environment of this client
- /// </summary>
- public string UserAgent { get; private set; }
-
- /// <summary>
- /// When this client session expires
- /// </summary>
- public DateTime ExpiryDate { get; set; }
-
- /// <summary>
- /// Empty constructor required for TypeSerializer
- /// </summary>
- public UserClientSession() {}
-
- public UserClientSession(
- Guid sessionId,
- Guid userId,
- string ipAddress,
- string userAgent,
- string base64ClientModulus,
- Guid userClientGlobalId)
- {
- this.Id = sessionId;
- this.UserId = userId;
- this.IpAddress = ipAddress;
- this.UserAgent = userAgent;
- this.Base64ClientModulus = base64ClientModulus;
- this.UserClientGlobalId = userClientGlobalId;
- this.ExpiryDate = DateTime.UtcNow.AddDays(ValidForTwoWeeks);
- }
- }
-
-}
Oops, something went wrong.

2 comments on commit b2c28c7

@graffic

Hmmm, are you sure it's better to merge the code? Bug fixes and new functionality in FluentValidation will need new merges instead just an updated reference.

@mythz
Member
mythz commented on b2c28c7 Dec 27, 2011

There were 2 options:

  • To include it as src so we don't increase the dll dependency count (annoying for users who don't use it to be forced to ref an external FluentValidation.dll).
  • Or leave it separate and have a wrapper project with ServiceStack extensions requiring a NuGet pull and to ref an extra 2 dlls for those that a) know that it exists. b) know how to install it.

I went with option 1, since ServiceStack doesn't really have a Validation library and I want to ship a 'complete stack' to build web services with. Also by having an opinionated validation library included as src I can add deep integration hooks so it works seamlessly with the ServiceStack request pipeline. I can also eventually ship some javascript client libraries that make it seamless to work with - which will be the end goal.

I've purposely moved it into a different namespace (i.e. prefixed with 'ServiceStack.') so it doesn't conflict and prevent others to include an official FluentValidation.dll if they want to use that instead - and they can simply use that instead and forget this version exists.

Please sign in to comment.