diff --git a/.nuget/packages.config b/.nuget/packages.config new file mode 100644 index 0000000..4013011 --- /dev/null +++ b/.nuget/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/MvcExtensions.Foolproof.sln b/MvcExtensions.Foolproof.sln index b0f151c..7d0497a 100644 --- a/MvcExtensions.Foolproof.sln +++ b/MvcExtensions.Foolproof.sln @@ -24,11 +24,17 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Mvc3Debug|Any CPU = Mvc3Debug|Any CPU + Mvc3Release|Any CPU = Mvc3Release|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {7F5AD1CB-0B14-4BEC-A5F2-631CFE045732}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7F5AD1CB-0B14-4BEC-A5F2-631CFE045732}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F5AD1CB-0B14-4BEC-A5F2-631CFE045732}.Mvc3Debug|Any CPU.ActiveCfg = Mvc3Debug|Any CPU + {7F5AD1CB-0B14-4BEC-A5F2-631CFE045732}.Mvc3Debug|Any CPU.Build.0 = Mvc3Debug|Any CPU + {7F5AD1CB-0B14-4BEC-A5F2-631CFE045732}.Mvc3Release|Any CPU.ActiveCfg = Mvc3Release|Any CPU + {7F5AD1CB-0B14-4BEC-A5F2-631CFE045732}.Mvc3Release|Any CPU.Build.0 = Mvc3Release|Any CPU {7F5AD1CB-0B14-4BEC-A5F2-631CFE045732}.Release|Any CPU.ActiveCfg = Release|Any CPU {7F5AD1CB-0B14-4BEC-A5F2-631CFE045732}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/build/MvcTargets/Mvc3.References.targets b/build/MvcTargets/Mvc3.References.targets new file mode 100644 index 0000000..1b15bbe --- /dev/null +++ b/build/MvcTargets/Mvc3.References.targets @@ -0,0 +1,9 @@ + + + + + False + ..\..\references\AspNetMvc3\System.Web.Mvc.dll + + + \ No newline at end of file diff --git a/build/MvcTargets/Mvc4.References.targets b/build/MvcTargets/Mvc4.References.targets new file mode 100644 index 0000000..4444e6a --- /dev/null +++ b/build/MvcTargets/Mvc4.References.targets @@ -0,0 +1,29 @@ + + + + + True + ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll + + + True + ..\..\packages\Microsoft.AspNet.Mvc.4.0.20710.0\lib\net40\System.Web.Mvc.dll + + + True + ..\..\packages\Microsoft.AspNet.Razor.2.0.20715.0\lib\net40\System.Web.Razor.dll + + + True + ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll + + + True + ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll + + + True + ..\..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll + + + \ No newline at end of file diff --git a/build/MvcTargets/WepApi.References.targets b/build/MvcTargets/WepApi.References.targets new file mode 100644 index 0000000..fa6ddad --- /dev/null +++ b/build/MvcTargets/WepApi.References.targets @@ -0,0 +1,20 @@ + + + + + ..\..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.dll + + + ..\..\packages\Microsoft.AspNet.WebApi.Client.4.0.20710.0\lib\net40\System.Net.Http.Formatting.dll + + + ..\..\packages\Microsoft.Net.Http.2.0.20710.0\lib\net40\System.Net.Http.WebRequest.dll + + + ..\..\packages\Microsoft.AspNet.WebApi.Core.4.0.20710.0\lib\net40\System.Web.Http.dll + + + ..\..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.20710.0\lib\net40\System.Web.Http.WebHost.dll + + + \ No newline at end of file diff --git a/src/MvcExtensions.Foolproof/ContingentValidationAttributeMetadata.cs b/src/MvcExtensions.Foolproof/ContingentValidationAttributeMetadata.cs new file mode 100644 index 0000000..370ea2e --- /dev/null +++ b/src/MvcExtensions.Foolproof/ContingentValidationAttributeMetadata.cs @@ -0,0 +1,28 @@ +#region Copyright +// Copyright (c) 2009 - 2012, Kazi Manzur Rashid , (c) 2011 - 2012 hazzik . +// This source is subject to the Microsoft Public License. +// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL. +// All other rights reserved. +#endregion + +namespace MvcExtensions +{ + using Foolproof; + + /// + /// Holds metadata + /// + public class ContingentValidationAttributeMetadata : ModelAwareValidationAttributeMetadata + where TAttribute : ContingentValidationAttribute + { + /// + /// Gets or sets the other property. + /// + /// The property. + public string OtherProperty + { + get; + set; + } + } +} \ No newline at end of file diff --git a/src/MvcExtensions.Foolproof/IsAttributeMetadata.cs b/src/MvcExtensions.Foolproof/IsAttributeMetadata.cs index e46bb84..16af7a0 100644 --- a/src/MvcExtensions.Foolproof/IsAttributeMetadata.cs +++ b/src/MvcExtensions.Foolproof/IsAttributeMetadata.cs @@ -1,51 +1,42 @@ -namespace MvcExtensions -{ - using System.Web.Mvc; - using Foolproof; - - /// - /// Represents a class to store is validation metadata. - /// - public abstract class IsAttributeMetadata : ModelValidationMetadata - { - /// - /// Gets or sets whether validation shouldpass on null property value. - /// - /// The property. - public bool PassOnNull - { - get; - set; - } - - /// - /// Gets or sets the other property. - /// - /// The property. - public string OtherProperty - { - get; - set; - } - - /// - /// Creates the validator. - /// - /// The model metadata. - /// The context. - /// - protected sealed override ModelValidator CreateValidatorCore(ExtendedModelMetadata modelMetadata, ControllerContext context) - { - var attribute = CreateAttribute(); - attribute.PassOnNull = PassOnNull; - PopulateErrorMessage(attribute); - return new FoolproofValidator(modelMetadata, context, attribute); - } - - /// - /// Creates an instence of Foolproof attribute - /// - /// - protected abstract IsAttribute CreateAttribute(); - } +namespace MvcExtensions +{ + using System.ComponentModel.DataAnnotations; + using Foolproof; + + /// + /// Represents a class to store is validation metadata. + /// + public abstract class IsAttributeMetadata : ContingentValidationAttributeMetadata + { + /// + /// Gets or sets whether validation shouldpass on null property value. + /// + /// The property. + public bool PassOnNull + { + get; + set; + } + + /// + /// Creates validation attribute + /// + /// + /// Instance of ValidationAttribute type + /// + protected override ValidationAttribute CreateValidationAttribute() + { + var attribute = CreateAttribute(); + attribute.PassOnNull = PassOnNull; + PopulateErrorMessage(attribute); + + return attribute; + } + + /// + /// Creates an instence of Foolproof attribute + /// + /// + protected abstract IsAttribute CreateAttribute(); + } } \ No newline at end of file diff --git a/src/MvcExtensions.Foolproof/ModelAwareValidationAttributeMetadata.cs b/src/MvcExtensions.Foolproof/ModelAwareValidationAttributeMetadata.cs new file mode 100644 index 0000000..99dac39 --- /dev/null +++ b/src/MvcExtensions.Foolproof/ModelAwareValidationAttributeMetadata.cs @@ -0,0 +1,28 @@ +#region Copyright +// Copyright (c) 2009 - 2012, Kazi Manzur Rashid , (c) 2011 - 2012 hazzik . +// This source is subject to the Microsoft Public License. +// See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL. +// All other rights reserved. +#endregion +namespace MvcExtensions +{ + using System.Web.Mvc; + using Foolproof; + + /// + /// Holds metadata + /// + public class ModelAwareValidationAttributeMetadata : ModelValidationMetadata + { + /// + /// Creates the validator. + /// + /// The model metadata. + /// The context. + /// + protected override ModelValidator CreateValidatorCore(ExtendedModelMetadata modelMetadata, ControllerContext context) + { + return new FoolproofValidator(modelMetadata, context, (ModelAwareValidationAttribute)CreateValidationAttribute()); + } + } +} \ No newline at end of file diff --git a/src/MvcExtensions.Foolproof/MvcExtensions.Foolproof.csproj b/src/MvcExtensions.Foolproof/MvcExtensions.Foolproof.csproj index ee55729..988ecc8 100644 --- a/src/MvcExtensions.Foolproof/MvcExtensions.Foolproof.csproj +++ b/src/MvcExtensions.Foolproof/MvcExtensions.Foolproof.csproj @@ -34,41 +34,36 @@ 4 bin\Release\MvcExtensions.Foolproof.XML + + true + bin\Mvc3Debug\ + DEBUG;TRACE;MVC_3 + bin\Mvc3Debug\MvcExtensions.Foolproof.XML + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + + + bin\Mvc3Release\ + pdbonly + true + TRACE;MVC_3 + prompt + 4 + bin\Mvc3Release\MvcExtensions.Foolproof.XML + ..\..\packages\foolproof.0.9.4517\lib\MVC Foolproof Validation.dll - - ..\..\packages\MvcExtensions.FluentMetadata.3.0.0-alpha1014\lib\net40\MvcExtensions.FluentMetadata.dll - True + + False + ..\..\..\Core\src\MvcExtensions.FluentMetadata\bin\Debug\MvcExtensions.FluentMetadata.dll - - True - ..\..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.Helpers.dll - - - True - ..\..\packages\Microsoft.AspNet.Mvc.3.0.20105.1\lib\net40\System.Web.Mvc.dll - - - True - ..\..\packages\Microsoft.AspNet.Razor.1.0.20105.408\lib\net40\System.Web.Razor.dll - - - True - ..\..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.WebPages.dll - - - True - ..\..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.WebPages.Deployment.dll - - - True - ..\..\packages\Microsoft.AspNet.WebPages.1.0.20105.408\lib\net40\System.Web.WebPages.Razor.dll - @@ -79,7 +74,9 @@ Properties\CommonAssemblyInfo.cs + + @@ -123,6 +120,8 @@ Designer + +