trying to localize
This commit is contained in:
parent
a93573dce8
commit
b9a75b71b8
32 changed files with 510 additions and 68 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,15 +0,0 @@
|
|||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public class YaRegularExpression : System.ComponentModel.DataAnnotations.RegularExpressionAttribute {
|
||||
public YaRegularExpression(string pattern): base (pattern)
|
||||
{
|
||||
this.ErrorMessage = pattern;
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
return ResourcesHelpers.GlobalLocalizer[this.ErrorMessageResourceName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +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()
|
||||
{
|
||||
ErrorMessage = msg;
|
||||
}
|
||||
public YaRequiredAttribute ()
|
||||
{
|
||||
this.ErrorMessage = ResourcesHelpers.GlobalLocalizer["RequiredField"];
|
||||
|
||||
}
|
||||
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,58 +0,0 @@
|
|||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public class YaStringLength: YaValidationAttribute
|
||||
{
|
||||
public long MinLen { get; set; } = -1;
|
||||
private long maxLen;
|
||||
public YaStringLength(long maxLen) : base(
|
||||
()=>string.Format(
|
||||
ResourcesHelpers.GlobalLocalizer["BadStringLength"],
|
||||
maxLen))
|
||||
{
|
||||
this.maxLen = maxLen;
|
||||
}
|
||||
|
||||
private long excedent;
|
||||
private long manquant;
|
||||
|
||||
public override bool IsValid(object value) {
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
string stringValue = value as string;
|
||||
if (stringValue==null) return false;
|
||||
if (MinLen>=0)
|
||||
{
|
||||
if (stringValue.Length<MinLen)
|
||||
{
|
||||
manquant = MinLen-stringValue.Length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (maxLen>=0)
|
||||
{
|
||||
if (stringValue.Length>maxLen) {
|
||||
excedent = stringValue.Length-maxLen;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
if (MinLen<0) {
|
||||
// DetailledMaxStringLength
|
||||
return string.Format(
|
||||
ResourcesHelpers.GlobalLocalizer["DetailledMaxStringLength"],
|
||||
maxLen,
|
||||
excedent);
|
||||
} else
|
||||
return string.Format(
|
||||
ResourcesHelpers.GlobalLocalizer["DetailledMinMaxStringLength"],
|
||||
MinLen,
|
||||
maxLen,
|
||||
manquant,
|
||||
excedent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Yavsc.Attributes.Validation
|
||||
{
|
||||
public class YaValidationAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute
|
||||
{
|
||||
public YaValidationAttribute() : base(()=> ResourcesHelpers.GlobalLocalizer["validationError"])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public YaValidationAttribute(Func<string> acr): base(acr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
return ResourcesHelpers.GlobalLocalizer[name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ namespace Yavsc.Models.Blog
|
|||
[Key(), DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public long Id { get; set; }
|
||||
|
||||
[YaStringLength(1024)]
|
||||
[StringLength(1024)]
|
||||
public string Content { get; set; }
|
||||
|
||||
[ForeignKeyAttribute("PostId")][JsonIgnore]
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ namespace Yavsc.Models.IT.Evolution
|
|||
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public long Id { get; set; }
|
||||
|
||||
[YaStringLength(256,MinLen=3)]
|
||||
[StringLength(256)]
|
||||
public string ShortName { get; set; }
|
||||
|
||||
[YaStringLength(10*1024,MinLen=3)]
|
||||
[StringLength(10*1024)]
|
||||
public string Description { get; set; }
|
||||
|
||||
public FeatureStatus Status { get; set; }
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Attributes.Validation;
|
||||
using Yavsc.Models.IT.Evolution;
|
||||
|
||||
namespace Yavsc.Models.IT.Fixing
|
||||
{
|
||||
public class Bug
|
||||
{
|
||||
[Key,DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public long Id { get; set; }
|
||||
|
||||
[ForeignKey("FeatureId")]
|
||||
public virtual Feature False { get; set; }
|
||||
|
||||
public long? FeatureId { get; set; }
|
||||
|
||||
[YaStringLength(1024)]
|
||||
public string Title { get; set; }
|
||||
|
||||
[YaStringLength(4096)]
|
||||
public string Description { get; set; }
|
||||
|
||||
public BugStatus Status { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
namespace Yavsc.Models.IT.Fixing
|
||||
{
|
||||
/// <summary>
|
||||
/// Bug status:
|
||||
/// * Inserted -> Confirmed|FeatureRequest|Feature|Rejected
|
||||
/// * Confirmed -> Fixed
|
||||
/// * FeatureRequest -> Implemented
|
||||
/// </summary>
|
||||
public enum BugStatus : int
|
||||
{
|
||||
Inserted,
|
||||
Confirmed,
|
||||
Rejected,
|
||||
Feature,
|
||||
Fixed
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ namespace Yavsc.ViewModels.Account
|
|||
[YaRegularExpression(Constants.UserNameRegExp)]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[YaRequired()]
|
||||
[Required()]
|
||||
// [EmailAddress]
|
||||
[Display(Name = "Email")]
|
||||
public string Email { get; set; }
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
"userSecretsId": "aspnet5-YavscWeb-a0dadd21-2ced-43d3-96f9-7e504345102f",
|
||||
"buildOptions": {
|
||||
"debugType": "full",
|
||||
"emitEntryPoint": true,
|
||||
"outputName": "Yavsc",
|
||||
"emitEntryPoint": false,
|
||||
"outputName": "Yavsc.Server",
|
||||
"compile": {
|
||||
"include": "*.cs",
|
||||
"exclude": [
|
||||
|
|
@ -38,8 +38,10 @@
|
|||
]
|
||||
},
|
||||
"embed": [
|
||||
"Resources/**/*.resx"
|
||||
]
|
||||
"Resources/**/*.resx"
|
||||
],
|
||||
"publicSign": false,
|
||||
"keyFile": "../../../sgKey.snk"
|
||||
},
|
||||
"tooling": {
|
||||
"defaultNamespace": "Yavsc"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue