REORG
This commit is contained in:
parent
8d68ee380a
commit
45514010f2
3505 changed files with 154 additions and 523 deletions
|
|
@ -1,19 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Yavsc.Attributes
|
||||
{
|
||||
public class ActivityBillingAttribute : Attribute
|
||||
{
|
||||
public string BillingCode { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Identifie une entité de facturation
|
||||
/// </summary>
|
||||
/// <param name="billingCode">Code de facturation,
|
||||
/// Il doit avoir une valeur unique par usage.
|
||||
/// </param>
|
||||
public ActivityBillingAttribute(string billingCode) {
|
||||
BillingCode = billingCode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Yavsc.Attributes
|
||||
{
|
||||
public class ActivitySettingsAttribute : Attribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
/// <summary>
|
||||
/// Valid Remote User Dir Attribute
|
||||
/// </summary>
|
||||
public class ValidRemoteUserFilePathAttribute : ValidationAttribute
|
||||
{
|
||||
public ValidRemoteUserFilePathAttribute()
|
||||
{
|
||||
UseDefaultErrorMessage();
|
||||
}
|
||||
void UseDefaultErrorMessage()
|
||||
{
|
||||
if (ErrorMessageResourceType==null) {
|
||||
ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
|
||||
ErrorMessageResourceName = "InvalidPath";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
if (value == null) return true;
|
||||
var str = (string) value;
|
||||
return str.IsValidYavscPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public class YaRegularExpression : System.ComponentModel.DataAnnotations.RegularExpressionAttribute {
|
||||
public YaRegularExpression(string pattern): base (pattern)
|
||||
{
|
||||
this.ErrorMessage = "RegularExpression: "+ pattern;
|
||||
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
if (ErrorMessageResourceType==null || string.IsNullOrEmpty(ErrorMessageResourceName))
|
||||
return ErrorMessage;
|
||||
var prop = this.ErrorMessageResourceType.GetProperty(ErrorMessageResourceName);
|
||||
return (string) prop.GetValue(null, BindingFlags.Static, null, null, System.Globalization.CultureInfo.CurrentUICulture);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
|
||||
public class YaRequiredAttribute : YaValidationAttribute
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a flag indicating whether the attribute should allow empty strings.
|
||||
/// </summary>
|
||||
public bool AllowEmptyStrings { get; set; }
|
||||
public YaRequiredAttribute (string msg) : base(msg)
|
||||
{
|
||||
ErrorMessage = msg;
|
||||
}
|
||||
public YaRequiredAttribute () : base("Required Field")
|
||||
{
|
||||
ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
|
||||
ErrorMessageResourceName = "FieldRequired";
|
||||
}
|
||||
|
||||
public override bool IsValid(object value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// only check string length if empty strings are not allowed
|
||||
var stringValue = value as string;
|
||||
if (stringValue != null && !AllowEmptyStrings) {
|
||||
return stringValue.Trim().Length != 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public partial class YaStringLength: YaValidationAttribute
|
||||
{
|
||||
public long MinimumLength { get; set; } = 0;
|
||||
private readonly long maxLen;
|
||||
public YaStringLength(long maxLen) : base( ()=> "BadStringLength")
|
||||
{
|
||||
this.maxLen = maxLen;
|
||||
UseDefaultErrorMessage();
|
||||
}
|
||||
public YaStringLength(long minLen, long maxLen) : base( ()=> "BadStringLength")
|
||||
{
|
||||
this.maxLen = maxLen;
|
||||
this.MinimumLength=minLen;
|
||||
UseDefaultErrorMessage();
|
||||
}
|
||||
void UseDefaultErrorMessage()
|
||||
{
|
||||
if (ErrorMessageResourceType==null) {
|
||||
ErrorMessageResourceType = typeof(Yavsc.Attributes.Validation.Resources);
|
||||
ErrorMessageResourceName = "InvalidStringLength";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsValid(object value) {
|
||||
|
||||
string stringValue = value as string;
|
||||
if (stringValue==null) return MinimumLength <= 0;
|
||||
if (MinimumLength>=0)
|
||||
{
|
||||
if (stringValue.Length< MinimumLength) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (maxLen>=0)
|
||||
{
|
||||
if (stringValue.Length>maxLen) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
var temp = base.FormatErrorMessage(name);
|
||||
return string.Format(temp, MinimumLength, maxLen);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public class YaValidationAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
|
||||
{
|
||||
public YaValidationAttribute(string msg) : base(msg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public YaValidationAttribute(Func<string> acr): base(acr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get given string from resources
|
||||
/// specified by ErrorMessageResourceType
|
||||
/// </summary>
|
||||
/// <param name="stringName"></param>
|
||||
/// <returns></returns>
|
||||
public virtual string GetResourceString(string stringName)
|
||||
{
|
||||
var prop = this.ErrorMessageResourceType.GetProperty(stringName);
|
||||
if (prop==null)
|
||||
{
|
||||
return " !e! noprop "+stringName+" in "+ErrorMessageResourceType.Name;
|
||||
}
|
||||
else {
|
||||
return (string) prop.GetValue(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
if (ErrorMessageResourceType == null) // failed :/
|
||||
{
|
||||
return base.FormatErrorMessage(name);
|
||||
}
|
||||
if (ErrorMessageResourceName == null) // re failed :/
|
||||
return base.FormatErrorMessage(name);
|
||||
|
||||
return GetResourceString(ErrorMessageResourceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue