This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel.DataAnnotations; | |
using System.Globalization; | |
namespace Asset.Web.Filters | |
{ | |
/// <summary> | |
/// Checks if an enumeration is valid. Will return true if no value is specified. | |
/// </summary> | |
public class EnumAttribute: ValidationAttribute |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.DataAnnotations; | |
using System.Linq; | |
using System.Web; | |
namespace Areas.Cms.Validation | |
{ | |
public class ValidateExtensionAttribute : ValidationAttribute | |
{ | |
public override bool IsValid(object value) | |
{ | |
HttpPostedFileBase file = value as HttpPostedFileBase; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.ComponentModel.DataAnnotations; | |
namespace Springsteen.WebApi.Contract | |
{ | |
public class RequiredUnlessSeqNumAttribute : ValidationAttribute | |
{ | |
protected override ValidationResult IsValid(object value, ValidationContext validationContext) | |
{ | |
int seqNum; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// This is used on mostly checkboxes that ensure that they are ticked such as terms and conditions. | |
/// </summary> | |
public class MustBeTrueAttribute : ValidationAttribute | |
{ | |
public override bool IsValid(object value) | |
{ | |
if (value == null) return false; | |
if (value.GetType() != typeof(bool)) return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PasswordsMustMatchAttribute : ValidationAttribute | |
{ | |
protected override ValidationResult IsValid( | |
object value, ValidationContext validationContext) | |
{ | |
var model = validationContext.ObjectInstance as Person; | |
if (model.Password == model.PasswordConfirm) | |
{ | |
return ValidationResult.Success; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.ComponentModel.DataAnnotations; | |
using DataValidation; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace CHR.API.Provisioning.ATT.Web.Tests | |
{ | |
[TestClass] | |
public class OneOfValidationTests | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MustBeEmptyAttribute : ValidationAttribute | |
{ | |
public override bool IsValid(object value) | |
{ | |
if (value == null) | |
{ | |
return true; | |
} | |
if (value is string) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
using System.Web.Http.Filters; | |
namespace ServiceFabric.WebApi.Filters | |
{ | |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)] | |
public class ResourceNotFoundAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wrap ASF Stateless Service. Customer would implement this base class instead of StatelessService | |
public abstract class NServiceBusStatelessService : StatelessService, IProvideEndPointConfiguration | |
{ | |
//plumbing for starting NSB on Service start | |
protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners() | |
{ | |
yield return new ServiceInstanceListener( | |
createCommunicationListener: | |
_ => new NServiceBusCommunicationsListener(this), | |
name: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Net; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace AppHarbor.Web { | |
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, | |
AllowMultiple = false)] |